001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.journal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.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                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
711                            new Object[] {
712                                    journalArticle.getUuid(),
713                                    Long.valueOf(journalArticle.getGroupId())
714                            });
715    
716                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
717                            new Object[] {
718                                    Long.valueOf(journalArticle.getGroupId()),
719                                    Long.valueOf(journalArticle.getClassNameId()),
720                                    
721                            journalArticle.getStructureId()
722                            });
723    
724                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
725                            new Object[] {
726                                    Long.valueOf(journalArticle.getGroupId()),
727                                    
728                            journalArticle.getArticleId(),
729                                    Double.valueOf(journalArticle.getVersion())
730                            });
731            }
732    
733            /**
734             * Creates a new journal article with the primary key. Does not add the journal article to the database.
735             *
736             * @param id the primary key for the new journal article
737             * @return the new journal article
738             */
739            public JournalArticle create(long id) {
740                    JournalArticle journalArticle = new JournalArticleImpl();
741    
742                    journalArticle.setNew(true);
743                    journalArticle.setPrimaryKey(id);
744    
745                    String uuid = PortalUUIDUtil.generate();
746    
747                    journalArticle.setUuid(uuid);
748    
749                    return journalArticle;
750            }
751    
752            /**
753             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
754             *
755             * @param primaryKey the primary key of the journal article
756             * @return the journal article that was removed
757             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
758             * @throws SystemException if a system exception occurred
759             */
760            @Override
761            public JournalArticle remove(Serializable primaryKey)
762                    throws NoSuchModelException, SystemException {
763                    return remove(((Long)primaryKey).longValue());
764            }
765    
766            /**
767             * Removes the journal article with the primary key from the database. Also notifies the appropriate model listeners.
768             *
769             * @param id the primary key of the journal article
770             * @return the journal article that was removed
771             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
772             * @throws SystemException if a system exception occurred
773             */
774            public JournalArticle remove(long id)
775                    throws NoSuchArticleException, SystemException {
776                    Session session = null;
777    
778                    try {
779                            session = openSession();
780    
781                            JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
782                                            Long.valueOf(id));
783    
784                            if (journalArticle == null) {
785                                    if (_log.isWarnEnabled()) {
786                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
787                                    }
788    
789                                    throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
790                                            id);
791                            }
792    
793                            return journalArticlePersistence.remove(journalArticle);
794                    }
795                    catch (NoSuchArticleException nsee) {
796                            throw nsee;
797                    }
798                    catch (Exception e) {
799                            throw processException(e);
800                    }
801                    finally {
802                            closeSession(session);
803                    }
804            }
805    
806            /**
807             * Removes the journal article from the database. Also notifies the appropriate model listeners.
808             *
809             * @param journalArticle the journal article
810             * @return the journal article that was removed
811             * @throws SystemException if a system exception occurred
812             */
813            @Override
814            public JournalArticle remove(JournalArticle journalArticle)
815                    throws SystemException {
816                    return super.remove(journalArticle);
817            }
818    
819            @Override
820            protected JournalArticle removeImpl(JournalArticle journalArticle)
821                    throws SystemException {
822                    journalArticle = toUnwrappedModel(journalArticle);
823    
824                    Session session = null;
825    
826                    try {
827                            session = openSession();
828    
829                            BatchSessionUtil.delete(session, journalArticle);
830                    }
831                    catch (Exception e) {
832                            throw processException(e);
833                    }
834                    finally {
835                            closeSession(session);
836                    }
837    
838                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
839                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
840    
841                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
842    
843                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
844                            new Object[] {
845                                    journalArticleModelImpl.getUuid(),
846                                    Long.valueOf(journalArticleModelImpl.getGroupId())
847                            });
848    
849                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
850                            new Object[] {
851                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
852                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
853                                    
854                            journalArticleModelImpl.getStructureId()
855                            });
856    
857                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
858                            new Object[] {
859                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
860                                    
861                            journalArticleModelImpl.getArticleId(),
862                                    Double.valueOf(journalArticleModelImpl.getVersion())
863                            });
864    
865                    EntityCacheUtil.removeResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
866                            JournalArticleImpl.class, journalArticle.getPrimaryKey());
867    
868                    return journalArticle;
869            }
870    
871            @Override
872            public JournalArticle updateImpl(
873                    com.liferay.portlet.journal.model.JournalArticle journalArticle,
874                    boolean merge) throws SystemException {
875                    journalArticle = toUnwrappedModel(journalArticle);
876    
877                    boolean isNew = journalArticle.isNew();
878    
879                    JournalArticleModelImpl journalArticleModelImpl = (JournalArticleModelImpl)journalArticle;
880    
881                    if (Validator.isNull(journalArticle.getUuid())) {
882                            String uuid = PortalUUIDUtil.generate();
883    
884                            journalArticle.setUuid(uuid);
885                    }
886    
887                    Session session = null;
888    
889                    try {
890                            session = openSession();
891    
892                            BatchSessionUtil.update(session, journalArticle, merge);
893    
894                            journalArticle.setNew(false);
895                    }
896                    catch (Exception e) {
897                            throw processException(e);
898                    }
899                    finally {
900                            closeSession(session);
901                    }
902    
903                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
904    
905                    if (isNew || !JournalArticleModelImpl.COLUMN_BITMASK_ENABLED) {
906                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
907                    }
908    
909                    else {
910                            if ((journalArticleModelImpl.getColumnBitmask() &
911                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
912                                    Object[] args = new Object[] {
913                                                    journalArticleModelImpl.getOriginalUuid()
914                                            };
915    
916                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
917                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
918                                            args);
919    
920                                    args = new Object[] { journalArticleModelImpl.getUuid() };
921    
922                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
923                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
924                                            args);
925                            }
926    
927                            if ((journalArticleModelImpl.getColumnBitmask() &
928                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY.getColumnBitmask()) != 0) {
929                                    Object[] args = new Object[] {
930                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey())
931                                            };
932    
933                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
934                                            args);
935                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
936                                            args);
937    
938                                    args = new Object[] {
939                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey())
940                                            };
941    
942                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
943                                            args);
944                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY,
945                                            args);
946                            }
947    
948                            if ((journalArticleModelImpl.getColumnBitmask() &
949                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
950                                    Object[] args = new Object[] {
951                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
952                                            };
953    
954                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
955                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
956                                            args);
957    
958                                    args = new Object[] {
959                                                    Long.valueOf(journalArticleModelImpl.getGroupId())
960                                            };
961    
962                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
963                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
964                                            args);
965                            }
966    
967                            if ((journalArticleModelImpl.getColumnBitmask() &
968                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
969                                    Object[] args = new Object[] {
970                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId())
971                                            };
972    
973                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
974                                            args);
975                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
976                                            args);
977    
978                                    args = new Object[] {
979                                                    Long.valueOf(journalArticleModelImpl.getCompanyId())
980                                            };
981    
982                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
983                                            args);
984                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
985                                            args);
986                            }
987    
988                            if ((journalArticleModelImpl.getColumnBitmask() &
989                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID.getColumnBitmask()) != 0) {
990                                    Object[] args = new Object[] {
991                                                    Long.valueOf(journalArticleModelImpl.getOriginalSmallImageId())
992                                            };
993    
994                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
995                                            args);
996                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
997                                            args);
998    
999                                    args = new Object[] {
1000                                                    Long.valueOf(journalArticleModelImpl.getSmallImageId())
1001                                            };
1002    
1003                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
1004                                            args);
1005                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID,
1006                                            args);
1007                            }
1008    
1009                            if ((journalArticleModelImpl.getColumnBitmask() &
1010                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST.getColumnBitmask()) != 0) {
1011                                    Object[] args = new Object[] {
1012                                                    Long.valueOf(journalArticleModelImpl.getOriginalResourcePrimKey()),
1013                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1014                                            };
1015    
1016                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1017                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1018                                            args);
1019    
1020                                    args = new Object[] {
1021                                                    Long.valueOf(journalArticleModelImpl.getResourcePrimKey()),
1022                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1023                                            };
1024    
1025                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_ST, args);
1026                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST,
1027                                            args);
1028                            }
1029    
1030                            if ((journalArticleModelImpl.getColumnBitmask() &
1031                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A.getColumnBitmask()) != 0) {
1032                                    Object[] args = new Object[] {
1033                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1034                                                    
1035                                                    journalArticleModelImpl.getOriginalArticleId()
1036                                            };
1037    
1038                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1039                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1040                                            args);
1041    
1042                                    args = new Object[] {
1043                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1044                                                    
1045                                                    journalArticleModelImpl.getArticleId()
1046                                            };
1047    
1048                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A, args);
1049                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A,
1050                                            args);
1051                            }
1052    
1053                            if ((journalArticleModelImpl.getColumnBitmask() &
1054                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT.getColumnBitmask()) != 0) {
1055                                    Object[] args = new Object[] {
1056                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1057                                                    
1058                                                    journalArticleModelImpl.getOriginalUrlTitle()
1059                                            };
1060    
1061                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1062                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1063                                            args);
1064    
1065                                    args = new Object[] {
1066                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1067                                                    
1068                                                    journalArticleModelImpl.getUrlTitle()
1069                                            };
1070    
1071                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1072                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT,
1073                                            args);
1074                            }
1075    
1076                            if ((journalArticleModelImpl.getColumnBitmask() &
1077                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
1078                                    Object[] args = new Object[] {
1079                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1080                                                    
1081                                                    journalArticleModelImpl.getOriginalStructureId()
1082                                            };
1083    
1084                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1085                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1086                                            args);
1087    
1088                                    args = new Object[] {
1089                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1090                                                    
1091                                                    journalArticleModelImpl.getStructureId()
1092                                            };
1093    
1094                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
1095                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
1096                                            args);
1097                            }
1098    
1099                            if ((journalArticleModelImpl.getColumnBitmask() &
1100                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
1101                                    Object[] args = new Object[] {
1102                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1103                                                    
1104                                                    journalArticleModelImpl.getOriginalTemplateId()
1105                                            };
1106    
1107                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1108                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1109                                            args);
1110    
1111                                    args = new Object[] {
1112                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1113                                                    
1114                                                    journalArticleModelImpl.getTemplateId()
1115                                            };
1116    
1117                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
1118                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
1119                                            args);
1120                            }
1121    
1122                            if ((journalArticleModelImpl.getColumnBitmask() &
1123                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L.getColumnBitmask()) != 0) {
1124                                    Object[] args = new Object[] {
1125                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1126                                                    
1127                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1128                                            };
1129    
1130                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1131                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1132                                            args);
1133    
1134                                    args = new Object[] {
1135                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1136                                                    
1137                                                    journalArticleModelImpl.getLayoutUuid()
1138                                            };
1139    
1140                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_L, args);
1141                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L,
1142                                            args);
1143                            }
1144    
1145                            if ((journalArticleModelImpl.getColumnBitmask() &
1146                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST.getColumnBitmask()) != 0) {
1147                                    Object[] args = new Object[] {
1148                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1149                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1150                                            };
1151    
1152                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1153                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1154                                            args);
1155    
1156                                    args = new Object[] {
1157                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1158                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1159                                            };
1160    
1161                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_ST, args);
1162                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST,
1163                                            args);
1164                            }
1165    
1166                            if ((journalArticleModelImpl.getColumnBitmask() &
1167                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V.getColumnBitmask()) != 0) {
1168                                    Object[] args = new Object[] {
1169                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1170                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1171                                            };
1172    
1173                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1174                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1175                                            args);
1176    
1177                                    args = new Object[] {
1178                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1179                                                    Double.valueOf(journalArticleModelImpl.getVersion())
1180                                            };
1181    
1182                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V, args);
1183                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V,
1184                                            args);
1185                            }
1186    
1187                            if ((journalArticleModelImpl.getColumnBitmask() &
1188                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST.getColumnBitmask()) != 0) {
1189                                    Object[] args = new Object[] {
1190                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1191                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1192                                            };
1193    
1194                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1195                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1196                                            args);
1197    
1198                                    args = new Object[] {
1199                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1200                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1201                                            };
1202    
1203                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_ST, args);
1204                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST,
1205                                            args);
1206                            }
1207    
1208                            if ((journalArticleModelImpl.getColumnBitmask() &
1209                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
1210                                    Object[] args = new Object[] {
1211                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1212                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1213                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassPK())
1214                                            };
1215    
1216                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1217                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1218                                            args);
1219    
1220                                    args = new Object[] {
1221                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1222                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1223                                                    Long.valueOf(journalArticleModelImpl.getClassPK())
1224                                            };
1225    
1226                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
1227                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
1228                                            args);
1229                            }
1230    
1231                            if ((journalArticleModelImpl.getColumnBitmask() &
1232                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T.getColumnBitmask()) != 0) {
1233                                    Object[] args = new Object[] {
1234                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1235                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1236                                                    
1237                                                    journalArticleModelImpl.getOriginalTemplateId()
1238                                            };
1239    
1240                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1241                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1242                                            args);
1243    
1244                                    args = new Object[] {
1245                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1246                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1247                                                    
1248                                                    journalArticleModelImpl.getTemplateId()
1249                                            };
1250    
1251                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_T, args);
1252                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T,
1253                                            args);
1254                            }
1255    
1256                            if ((journalArticleModelImpl.getColumnBitmask() &
1257                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L.getColumnBitmask()) != 0) {
1258                                    Object[] args = new Object[] {
1259                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1260                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1261                                                    
1262                                                    journalArticleModelImpl.getOriginalLayoutUuid()
1263                                            };
1264    
1265                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1266                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1267                                            args);
1268    
1269                                    args = new Object[] {
1270                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1271                                                    Long.valueOf(journalArticleModelImpl.getClassNameId()),
1272                                                    
1273                                                    journalArticleModelImpl.getLayoutUuid()
1274                                            };
1275    
1276                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_L, args);
1277                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L,
1278                                            args);
1279                            }
1280    
1281                            if ((journalArticleModelImpl.getColumnBitmask() &
1282                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST.getColumnBitmask()) != 0) {
1283                                    Object[] args = new Object[] {
1284                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1285                                                    
1286                                                    journalArticleModelImpl.getOriginalArticleId(),
1287                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1288                                            };
1289    
1290                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1291                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1292                                            args);
1293    
1294                                    args = new Object[] {
1295                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1296                                                    
1297                                                    journalArticleModelImpl.getArticleId(),
1298                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1299                                            };
1300    
1301                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_ST, args);
1302                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST,
1303                                            args);
1304                            }
1305    
1306                            if ((journalArticleModelImpl.getColumnBitmask() &
1307                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST.getColumnBitmask()) != 0) {
1308                                    Object[] args = new Object[] {
1309                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1310                                                    
1311                                                    journalArticleModelImpl.getOriginalUrlTitle(),
1312                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1313                                            };
1314    
1315                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1316                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1317                                            args);
1318    
1319                                    args = new Object[] {
1320                                                    Long.valueOf(journalArticleModelImpl.getGroupId()),
1321                                                    
1322                                                    journalArticleModelImpl.getUrlTitle(),
1323                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1324                                            };
1325    
1326                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT_ST, args);
1327                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST,
1328                                            args);
1329                            }
1330    
1331                            if ((journalArticleModelImpl.getColumnBitmask() &
1332                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST.getColumnBitmask()) != 0) {
1333                                    Object[] args = new Object[] {
1334                                                    Long.valueOf(journalArticleModelImpl.getOriginalCompanyId()),
1335                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion()),
1336                                                    Integer.valueOf(journalArticleModelImpl.getOriginalStatus())
1337                                            };
1338    
1339                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1340                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1341                                            args);
1342    
1343                                    args = new Object[] {
1344                                                    Long.valueOf(journalArticleModelImpl.getCompanyId()),
1345                                                    Double.valueOf(journalArticleModelImpl.getVersion()),
1346                                                    Integer.valueOf(journalArticleModelImpl.getStatus())
1347                                            };
1348    
1349                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_V_ST, args);
1350                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST,
1351                                            args);
1352                            }
1353                    }
1354    
1355                    EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1356                            JournalArticleImpl.class, journalArticle.getPrimaryKey(),
1357                            journalArticle);
1358    
1359                    if (isNew) {
1360                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1361                                    new Object[] {
1362                                            journalArticle.getUuid(),
1363                                            Long.valueOf(journalArticle.getGroupId())
1364                                    }, journalArticle);
1365    
1366                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1367                                    new Object[] {
1368                                            Long.valueOf(journalArticle.getGroupId()),
1369                                            Long.valueOf(journalArticle.getClassNameId()),
1370                                            
1371                                    journalArticle.getStructureId()
1372                                    }, journalArticle);
1373    
1374                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1375                                    new Object[] {
1376                                            Long.valueOf(journalArticle.getGroupId()),
1377                                            
1378                                    journalArticle.getArticleId(),
1379                                            Double.valueOf(journalArticle.getVersion())
1380                                    }, journalArticle);
1381                    }
1382                    else {
1383                            if ((journalArticleModelImpl.getColumnBitmask() &
1384                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1385                                    Object[] args = new Object[] {
1386                                                    journalArticleModelImpl.getOriginalUuid(),
1387                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId())
1388                                            };
1389    
1390                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1391                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1392    
1393                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1394                                            new Object[] {
1395                                                    journalArticle.getUuid(),
1396                                                    Long.valueOf(journalArticle.getGroupId())
1397                                            }, journalArticle);
1398                            }
1399    
1400                            if ((journalArticleModelImpl.getColumnBitmask() &
1401                                            FINDER_PATH_FETCH_BY_G_C_S.getColumnBitmask()) != 0) {
1402                                    Object[] args = new Object[] {
1403                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1404                                                    Long.valueOf(journalArticleModelImpl.getOriginalClassNameId()),
1405                                                    
1406                                                    journalArticleModelImpl.getOriginalStructureId()
1407                                            };
1408    
1409                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_S, args);
1410                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S, args);
1411    
1412                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
1413                                            new Object[] {
1414                                                    Long.valueOf(journalArticle.getGroupId()),
1415                                                    Long.valueOf(journalArticle.getClassNameId()),
1416                                                    
1417                                            journalArticle.getStructureId()
1418                                            }, journalArticle);
1419                            }
1420    
1421                            if ((journalArticleModelImpl.getColumnBitmask() &
1422                                            FINDER_PATH_FETCH_BY_G_A_V.getColumnBitmask()) != 0) {
1423                                    Object[] args = new Object[] {
1424                                                    Long.valueOf(journalArticleModelImpl.getOriginalGroupId()),
1425                                                    
1426                                                    journalArticleModelImpl.getOriginalArticleId(),
1427                                                    Double.valueOf(journalArticleModelImpl.getOriginalVersion())
1428                                            };
1429    
1430                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_A_V, args);
1431                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V, args);
1432    
1433                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
1434                                            new Object[] {
1435                                                    Long.valueOf(journalArticle.getGroupId()),
1436                                                    
1437                                            journalArticle.getArticleId(),
1438                                                    Double.valueOf(journalArticle.getVersion())
1439                                            }, journalArticle);
1440                            }
1441                    }
1442    
1443                    return journalArticle;
1444            }
1445    
1446            protected JournalArticle toUnwrappedModel(JournalArticle journalArticle) {
1447                    if (journalArticle instanceof JournalArticleImpl) {
1448                            return journalArticle;
1449                    }
1450    
1451                    JournalArticleImpl journalArticleImpl = new JournalArticleImpl();
1452    
1453                    journalArticleImpl.setNew(journalArticle.isNew());
1454                    journalArticleImpl.setPrimaryKey(journalArticle.getPrimaryKey());
1455    
1456                    journalArticleImpl.setUuid(journalArticle.getUuid());
1457                    journalArticleImpl.setId(journalArticle.getId());
1458                    journalArticleImpl.setResourcePrimKey(journalArticle.getResourcePrimKey());
1459                    journalArticleImpl.setGroupId(journalArticle.getGroupId());
1460                    journalArticleImpl.setCompanyId(journalArticle.getCompanyId());
1461                    journalArticleImpl.setUserId(journalArticle.getUserId());
1462                    journalArticleImpl.setUserName(journalArticle.getUserName());
1463                    journalArticleImpl.setCreateDate(journalArticle.getCreateDate());
1464                    journalArticleImpl.setModifiedDate(journalArticle.getModifiedDate());
1465                    journalArticleImpl.setClassNameId(journalArticle.getClassNameId());
1466                    journalArticleImpl.setClassPK(journalArticle.getClassPK());
1467                    journalArticleImpl.setArticleId(journalArticle.getArticleId());
1468                    journalArticleImpl.setVersion(journalArticle.getVersion());
1469                    journalArticleImpl.setTitle(journalArticle.getTitle());
1470                    journalArticleImpl.setUrlTitle(journalArticle.getUrlTitle());
1471                    journalArticleImpl.setDescription(journalArticle.getDescription());
1472                    journalArticleImpl.setContent(journalArticle.getContent());
1473                    journalArticleImpl.setType(journalArticle.getType());
1474                    journalArticleImpl.setStructureId(journalArticle.getStructureId());
1475                    journalArticleImpl.setTemplateId(journalArticle.getTemplateId());
1476                    journalArticleImpl.setLayoutUuid(journalArticle.getLayoutUuid());
1477                    journalArticleImpl.setDisplayDate(journalArticle.getDisplayDate());
1478                    journalArticleImpl.setExpirationDate(journalArticle.getExpirationDate());
1479                    journalArticleImpl.setReviewDate(journalArticle.getReviewDate());
1480                    journalArticleImpl.setIndexable(journalArticle.isIndexable());
1481                    journalArticleImpl.setSmallImage(journalArticle.isSmallImage());
1482                    journalArticleImpl.setSmallImageId(journalArticle.getSmallImageId());
1483                    journalArticleImpl.setSmallImageURL(journalArticle.getSmallImageURL());
1484                    journalArticleImpl.setStatus(journalArticle.getStatus());
1485                    journalArticleImpl.setStatusByUserId(journalArticle.getStatusByUserId());
1486                    journalArticleImpl.setStatusByUserName(journalArticle.getStatusByUserName());
1487                    journalArticleImpl.setStatusDate(journalArticle.getStatusDate());
1488    
1489                    return journalArticleImpl;
1490            }
1491    
1492            /**
1493             * Returns the journal article with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1494             *
1495             * @param primaryKey the primary key of the journal article
1496             * @return the journal article
1497             * @throws com.liferay.portal.NoSuchModelException if a journal article with the primary key could not be found
1498             * @throws SystemException if a system exception occurred
1499             */
1500            @Override
1501            public JournalArticle findByPrimaryKey(Serializable primaryKey)
1502                    throws NoSuchModelException, SystemException {
1503                    return findByPrimaryKey(((Long)primaryKey).longValue());
1504            }
1505    
1506            /**
1507             * Returns the journal article with the primary key or throws a {@link com.liferay.portlet.journal.NoSuchArticleException} if it could not be found.
1508             *
1509             * @param id the primary key of the journal article
1510             * @return the journal article
1511             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1512             * @throws SystemException if a system exception occurred
1513             */
1514            public JournalArticle findByPrimaryKey(long id)
1515                    throws NoSuchArticleException, SystemException {
1516                    JournalArticle journalArticle = fetchByPrimaryKey(id);
1517    
1518                    if (journalArticle == null) {
1519                            if (_log.isWarnEnabled()) {
1520                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
1521                            }
1522    
1523                            throw new NoSuchArticleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1524                                    id);
1525                    }
1526    
1527                    return journalArticle;
1528            }
1529    
1530            /**
1531             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1532             *
1533             * @param primaryKey the primary key of the journal article
1534             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1535             * @throws SystemException if a system exception occurred
1536             */
1537            @Override
1538            public JournalArticle fetchByPrimaryKey(Serializable primaryKey)
1539                    throws SystemException {
1540                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1541            }
1542    
1543            /**
1544             * Returns the journal article with the primary key or returns <code>null</code> if it could not be found.
1545             *
1546             * @param id the primary key of the journal article
1547             * @return the journal article, or <code>null</code> if a journal article with the primary key could not be found
1548             * @throws SystemException if a system exception occurred
1549             */
1550            public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
1551                    JournalArticle journalArticle = (JournalArticle)EntityCacheUtil.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1552                                    JournalArticleImpl.class, id);
1553    
1554                    if (journalArticle == _nullJournalArticle) {
1555                            return null;
1556                    }
1557    
1558                    if (journalArticle == null) {
1559                            Session session = null;
1560    
1561                            boolean hasException = false;
1562    
1563                            try {
1564                                    session = openSession();
1565    
1566                                    journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
1567                                                    Long.valueOf(id));
1568                            }
1569                            catch (Exception e) {
1570                                    hasException = true;
1571    
1572                                    throw processException(e);
1573                            }
1574                            finally {
1575                                    if (journalArticle != null) {
1576                                            cacheResult(journalArticle);
1577                                    }
1578                                    else if (!hasException) {
1579                                            EntityCacheUtil.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
1580                                                    JournalArticleImpl.class, id, _nullJournalArticle);
1581                                    }
1582    
1583                                    closeSession(session);
1584                            }
1585                    }
1586    
1587                    return journalArticle;
1588            }
1589    
1590            /**
1591             * Returns all the journal articles where uuid = &#63;.
1592             *
1593             * @param uuid the uuid
1594             * @return the matching journal articles
1595             * @throws SystemException if a system exception occurred
1596             */
1597            public List<JournalArticle> findByUuid(String uuid)
1598                    throws SystemException {
1599                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1600            }
1601    
1602            /**
1603             * Returns a range of all the journal articles where uuid = &#63;.
1604             *
1605             * <p>
1606             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1607             * </p>
1608             *
1609             * @param uuid the uuid
1610             * @param start the lower bound of the range of journal articles
1611             * @param end the upper bound of the range of journal articles (not inclusive)
1612             * @return the range of matching journal articles
1613             * @throws SystemException if a system exception occurred
1614             */
1615            public List<JournalArticle> findByUuid(String uuid, int start, int end)
1616                    throws SystemException {
1617                    return findByUuid(uuid, start, end, null);
1618            }
1619    
1620            /**
1621             * Returns an ordered range of all the journal articles where uuid = &#63;.
1622             *
1623             * <p>
1624             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1625             * </p>
1626             *
1627             * @param uuid the uuid
1628             * @param start the lower bound of the range of journal articles
1629             * @param end the upper bound of the range of journal articles (not inclusive)
1630             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1631             * @return the ordered range of matching journal articles
1632             * @throws SystemException if a system exception occurred
1633             */
1634            public List<JournalArticle> findByUuid(String uuid, int start, int end,
1635                    OrderByComparator orderByComparator) throws SystemException {
1636                    FinderPath finderPath = null;
1637                    Object[] finderArgs = null;
1638    
1639                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1640                                    (orderByComparator == null)) {
1641                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1642                            finderArgs = new Object[] { uuid };
1643                    }
1644                    else {
1645                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1646                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1647                    }
1648    
1649                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
1650                                    finderArgs, this);
1651    
1652                    if (list == null) {
1653                            StringBundler query = null;
1654    
1655                            if (orderByComparator != null) {
1656                                    query = new StringBundler(3 +
1657                                                    (orderByComparator.getOrderByFields().length * 3));
1658                            }
1659                            else {
1660                                    query = new StringBundler(3);
1661                            }
1662    
1663                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1664    
1665                            if (uuid == null) {
1666                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1667                            }
1668                            else {
1669                                    if (uuid.equals(StringPool.BLANK)) {
1670                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1671                                    }
1672                                    else {
1673                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1674                                    }
1675                            }
1676    
1677                            if (orderByComparator != null) {
1678                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1679                                            orderByComparator);
1680                            }
1681    
1682                            else {
1683                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1684                            }
1685    
1686                            String sql = query.toString();
1687    
1688                            Session session = null;
1689    
1690                            try {
1691                                    session = openSession();
1692    
1693                                    Query q = session.createQuery(sql);
1694    
1695                                    QueryPos qPos = QueryPos.getInstance(q);
1696    
1697                                    if (uuid != null) {
1698                                            qPos.add(uuid);
1699                                    }
1700    
1701                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
1702                                                    start, end);
1703                            }
1704                            catch (Exception e) {
1705                                    throw processException(e);
1706                            }
1707                            finally {
1708                                    if (list == null) {
1709                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1710                                    }
1711                                    else {
1712                                            cacheResult(list);
1713    
1714                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1715                                    }
1716    
1717                                    closeSession(session);
1718                            }
1719                    }
1720    
1721                    return list;
1722            }
1723    
1724            /**
1725             * Returns the first journal article in the ordered set where uuid = &#63;.
1726             *
1727             * <p>
1728             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1729             * </p>
1730             *
1731             * @param uuid the uuid
1732             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1733             * @return the first matching journal article
1734             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1735             * @throws SystemException if a system exception occurred
1736             */
1737            public JournalArticle findByUuid_First(String uuid,
1738                    OrderByComparator orderByComparator)
1739                    throws NoSuchArticleException, SystemException {
1740                    List<JournalArticle> list = findByUuid(uuid, 0, 1, orderByComparator);
1741    
1742                    if (list.isEmpty()) {
1743                            StringBundler msg = new StringBundler(4);
1744    
1745                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1746    
1747                            msg.append("uuid=");
1748                            msg.append(uuid);
1749    
1750                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1751    
1752                            throw new NoSuchArticleException(msg.toString());
1753                    }
1754                    else {
1755                            return list.get(0);
1756                    }
1757            }
1758    
1759            /**
1760             * Returns the last journal article in the ordered set where uuid = &#63;.
1761             *
1762             * <p>
1763             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1764             * </p>
1765             *
1766             * @param uuid the uuid
1767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1768             * @return the last matching journal article
1769             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1770             * @throws SystemException if a system exception occurred
1771             */
1772            public JournalArticle findByUuid_Last(String uuid,
1773                    OrderByComparator orderByComparator)
1774                    throws NoSuchArticleException, SystemException {
1775                    int count = countByUuid(uuid);
1776    
1777                    List<JournalArticle> list = findByUuid(uuid, count - 1, count,
1778                                    orderByComparator);
1779    
1780                    if (list.isEmpty()) {
1781                            StringBundler msg = new StringBundler(4);
1782    
1783                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1784    
1785                            msg.append("uuid=");
1786                            msg.append(uuid);
1787    
1788                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1789    
1790                            throw new NoSuchArticleException(msg.toString());
1791                    }
1792                    else {
1793                            return list.get(0);
1794                    }
1795            }
1796    
1797            /**
1798             * Returns the journal articles before and after the current journal article in the ordered set where uuid = &#63;.
1799             *
1800             * <p>
1801             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1802             * </p>
1803             *
1804             * @param id the primary key of the current journal article
1805             * @param uuid the uuid
1806             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1807             * @return the previous, current, and next journal article
1808             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
1809             * @throws SystemException if a system exception occurred
1810             */
1811            public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
1812                    OrderByComparator orderByComparator)
1813                    throws NoSuchArticleException, SystemException {
1814                    JournalArticle journalArticle = findByPrimaryKey(id);
1815    
1816                    Session session = null;
1817    
1818                    try {
1819                            session = openSession();
1820    
1821                            JournalArticle[] array = new JournalArticleImpl[3];
1822    
1823                            array[0] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1824                                            orderByComparator, true);
1825    
1826                            array[1] = journalArticle;
1827    
1828                            array[2] = getByUuid_PrevAndNext(session, journalArticle, uuid,
1829                                            orderByComparator, false);
1830    
1831                            return array;
1832                    }
1833                    catch (Exception e) {
1834                            throw processException(e);
1835                    }
1836                    finally {
1837                            closeSession(session);
1838                    }
1839            }
1840    
1841            protected JournalArticle getByUuid_PrevAndNext(Session session,
1842                    JournalArticle journalArticle, String uuid,
1843                    OrderByComparator orderByComparator, boolean previous) {
1844                    StringBundler query = null;
1845    
1846                    if (orderByComparator != null) {
1847                            query = new StringBundler(6 +
1848                                            (orderByComparator.getOrderByFields().length * 6));
1849                    }
1850                    else {
1851                            query = new StringBundler(3);
1852                    }
1853    
1854                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
1855    
1856                    if (uuid == null) {
1857                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1858                    }
1859                    else {
1860                            if (uuid.equals(StringPool.BLANK)) {
1861                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1862                            }
1863                            else {
1864                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1865                            }
1866                    }
1867    
1868                    if (orderByComparator != null) {
1869                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1870    
1871                            if (orderByConditionFields.length > 0) {
1872                                    query.append(WHERE_AND);
1873                            }
1874    
1875                            for (int i = 0; i < orderByConditionFields.length; i++) {
1876                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1877                                    query.append(orderByConditionFields[i]);
1878    
1879                                    if ((i + 1) < orderByConditionFields.length) {
1880                                            if (orderByComparator.isAscending() ^ previous) {
1881                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1882                                            }
1883                                            else {
1884                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1885                                            }
1886                                    }
1887                                    else {
1888                                            if (orderByComparator.isAscending() ^ previous) {
1889                                                    query.append(WHERE_GREATER_THAN);
1890                                            }
1891                                            else {
1892                                                    query.append(WHERE_LESSER_THAN);
1893                                            }
1894                                    }
1895                            }
1896    
1897                            query.append(ORDER_BY_CLAUSE);
1898    
1899                            String[] orderByFields = orderByComparator.getOrderByFields();
1900    
1901                            for (int i = 0; i < orderByFields.length; i++) {
1902                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1903                                    query.append(orderByFields[i]);
1904    
1905                                    if ((i + 1) < orderByFields.length) {
1906                                            if (orderByComparator.isAscending() ^ previous) {
1907                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1908                                            }
1909                                            else {
1910                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1911                                            }
1912                                    }
1913                                    else {
1914                                            if (orderByComparator.isAscending() ^ previous) {
1915                                                    query.append(ORDER_BY_ASC);
1916                                            }
1917                                            else {
1918                                                    query.append(ORDER_BY_DESC);
1919                                            }
1920                                    }
1921                            }
1922                    }
1923    
1924                    else {
1925                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
1926                    }
1927    
1928                    String sql = query.toString();
1929    
1930                    Query q = session.createQuery(sql);
1931    
1932                    q.setFirstResult(0);
1933                    q.setMaxResults(2);
1934    
1935                    QueryPos qPos = QueryPos.getInstance(q);
1936    
1937                    if (uuid != null) {
1938                            qPos.add(uuid);
1939                    }
1940    
1941                    if (orderByComparator != null) {
1942                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
1943    
1944                            for (Object value : values) {
1945                                    qPos.add(value);
1946                            }
1947                    }
1948    
1949                    List<JournalArticle> list = q.list();
1950    
1951                    if (list.size() == 2) {
1952                            return list.get(1);
1953                    }
1954                    else {
1955                            return null;
1956                    }
1957            }
1958    
1959            /**
1960             * 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.
1961             *
1962             * @param uuid the uuid
1963             * @param groupId the group ID
1964             * @return the matching journal article
1965             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
1966             * @throws SystemException if a system exception occurred
1967             */
1968            public JournalArticle findByUUID_G(String uuid, long groupId)
1969                    throws NoSuchArticleException, SystemException {
1970                    JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
1971    
1972                    if (journalArticle == null) {
1973                            StringBundler msg = new StringBundler(6);
1974    
1975                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1976    
1977                            msg.append("uuid=");
1978                            msg.append(uuid);
1979    
1980                            msg.append(", groupId=");
1981                            msg.append(groupId);
1982    
1983                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1984    
1985                            if (_log.isWarnEnabled()) {
1986                                    _log.warn(msg.toString());
1987                            }
1988    
1989                            throw new NoSuchArticleException(msg.toString());
1990                    }
1991    
1992                    return journalArticle;
1993            }
1994    
1995            /**
1996             * 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.
1997             *
1998             * @param uuid the uuid
1999             * @param groupId the group ID
2000             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2001             * @throws SystemException if a system exception occurred
2002             */
2003            public JournalArticle fetchByUUID_G(String uuid, long groupId)
2004                    throws SystemException {
2005                    return fetchByUUID_G(uuid, groupId, true);
2006            }
2007    
2008            /**
2009             * 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.
2010             *
2011             * @param uuid the uuid
2012             * @param groupId the group ID
2013             * @param retrieveFromCache whether to use the finder cache
2014             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
2015             * @throws SystemException if a system exception occurred
2016             */
2017            public JournalArticle fetchByUUID_G(String uuid, long groupId,
2018                    boolean retrieveFromCache) throws SystemException {
2019                    Object[] finderArgs = new Object[] { uuid, groupId };
2020    
2021                    Object result = null;
2022    
2023                    if (retrieveFromCache) {
2024                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
2025                                            finderArgs, this);
2026                    }
2027    
2028                    if (result == null) {
2029                            StringBundler query = new StringBundler(4);
2030    
2031                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2032    
2033                            if (uuid == null) {
2034                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2035                            }
2036                            else {
2037                                    if (uuid.equals(StringPool.BLANK)) {
2038                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2039                                    }
2040                                    else {
2041                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2042                                    }
2043                            }
2044    
2045                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2046    
2047                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2048    
2049                            String sql = query.toString();
2050    
2051                            Session session = null;
2052    
2053                            try {
2054                                    session = openSession();
2055    
2056                                    Query q = session.createQuery(sql);
2057    
2058                                    QueryPos qPos = QueryPos.getInstance(q);
2059    
2060                                    if (uuid != null) {
2061                                            qPos.add(uuid);
2062                                    }
2063    
2064                                    qPos.add(groupId);
2065    
2066                                    List<JournalArticle> list = q.list();
2067    
2068                                    result = list;
2069    
2070                                    JournalArticle journalArticle = null;
2071    
2072                                    if (list.isEmpty()) {
2073                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2074                                                    finderArgs, list);
2075                                    }
2076                                    else {
2077                                            journalArticle = list.get(0);
2078    
2079                                            cacheResult(journalArticle);
2080    
2081                                            if ((journalArticle.getUuid() == null) ||
2082                                                            !journalArticle.getUuid().equals(uuid) ||
2083                                                            (journalArticle.getGroupId() != groupId)) {
2084                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2085                                                            finderArgs, journalArticle);
2086                                            }
2087                                    }
2088    
2089                                    return journalArticle;
2090                            }
2091                            catch (Exception e) {
2092                                    throw processException(e);
2093                            }
2094                            finally {
2095                                    if (result == null) {
2096                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
2097                                                    finderArgs);
2098                                    }
2099    
2100                                    closeSession(session);
2101                            }
2102                    }
2103                    else {
2104                            if (result instanceof List<?>) {
2105                                    return null;
2106                            }
2107                            else {
2108                                    return (JournalArticle)result;
2109                            }
2110                    }
2111            }
2112    
2113            /**
2114             * Returns all the journal articles where resourcePrimKey = &#63;.
2115             *
2116             * @param resourcePrimKey the resource prim key
2117             * @return the matching journal articles
2118             * @throws SystemException if a system exception occurred
2119             */
2120            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey)
2121                    throws SystemException {
2122                    return findByResourcePrimKey(resourcePrimKey, QueryUtil.ALL_POS,
2123                            QueryUtil.ALL_POS, null);
2124            }
2125    
2126            /**
2127             * Returns a range of all the journal articles where resourcePrimKey = &#63;.
2128             *
2129             * <p>
2130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2131             * </p>
2132             *
2133             * @param resourcePrimKey the resource prim key
2134             * @param start the lower bound of the range of journal articles
2135             * @param end the upper bound of the range of journal articles (not inclusive)
2136             * @return the range of matching journal articles
2137             * @throws SystemException if a system exception occurred
2138             */
2139            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2140                    int start, int end) throws SystemException {
2141                    return findByResourcePrimKey(resourcePrimKey, start, end, null);
2142            }
2143    
2144            /**
2145             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63;.
2146             *
2147             * <p>
2148             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2149             * </p>
2150             *
2151             * @param resourcePrimKey the resource prim key
2152             * @param start the lower bound of the range of journal articles
2153             * @param end the upper bound of the range of journal articles (not inclusive)
2154             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2155             * @return the ordered range of matching journal articles
2156             * @throws SystemException if a system exception occurred
2157             */
2158            public List<JournalArticle> findByResourcePrimKey(long resourcePrimKey,
2159                    int start, int end, OrderByComparator orderByComparator)
2160                    throws SystemException {
2161                    FinderPath finderPath = null;
2162                    Object[] finderArgs = null;
2163    
2164                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2165                                    (orderByComparator == null)) {
2166                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2167                            finderArgs = new Object[] { resourcePrimKey };
2168                    }
2169                    else {
2170                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEPRIMKEY;
2171                            finderArgs = new Object[] {
2172                                            resourcePrimKey,
2173                                            
2174                                            start, end, orderByComparator
2175                                    };
2176                    }
2177    
2178                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2179                                    finderArgs, this);
2180    
2181                    if (list == null) {
2182                            StringBundler query = null;
2183    
2184                            if (orderByComparator != null) {
2185                                    query = new StringBundler(3 +
2186                                                    (orderByComparator.getOrderByFields().length * 3));
2187                            }
2188                            else {
2189                                    query = new StringBundler(3);
2190                            }
2191    
2192                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2193    
2194                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2195    
2196                            if (orderByComparator != null) {
2197                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2198                                            orderByComparator);
2199                            }
2200    
2201                            else {
2202                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2203                            }
2204    
2205                            String sql = query.toString();
2206    
2207                            Session session = null;
2208    
2209                            try {
2210                                    session = openSession();
2211    
2212                                    Query q = session.createQuery(sql);
2213    
2214                                    QueryPos qPos = QueryPos.getInstance(q);
2215    
2216                                    qPos.add(resourcePrimKey);
2217    
2218                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2219                                                    start, end);
2220                            }
2221                            catch (Exception e) {
2222                                    throw processException(e);
2223                            }
2224                            finally {
2225                                    if (list == null) {
2226                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2227                                    }
2228                                    else {
2229                                            cacheResult(list);
2230    
2231                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2232                                    }
2233    
2234                                    closeSession(session);
2235                            }
2236                    }
2237    
2238                    return list;
2239            }
2240    
2241            /**
2242             * Returns the first journal article in the ordered set where resourcePrimKey = &#63;.
2243             *
2244             * <p>
2245             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2246             * </p>
2247             *
2248             * @param resourcePrimKey the resource prim key
2249             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2250             * @return the first matching journal article
2251             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2252             * @throws SystemException if a system exception occurred
2253             */
2254            public JournalArticle findByResourcePrimKey_First(long resourcePrimKey,
2255                    OrderByComparator orderByComparator)
2256                    throws NoSuchArticleException, SystemException {
2257                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey, 0,
2258                                    1, orderByComparator);
2259    
2260                    if (list.isEmpty()) {
2261                            StringBundler msg = new StringBundler(4);
2262    
2263                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2264    
2265                            msg.append("resourcePrimKey=");
2266                            msg.append(resourcePrimKey);
2267    
2268                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2269    
2270                            throw new NoSuchArticleException(msg.toString());
2271                    }
2272                    else {
2273                            return list.get(0);
2274                    }
2275            }
2276    
2277            /**
2278             * Returns the last journal article in the ordered set where resourcePrimKey = &#63;.
2279             *
2280             * <p>
2281             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2282             * </p>
2283             *
2284             * @param resourcePrimKey the resource prim key
2285             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2286             * @return the last matching journal article
2287             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2288             * @throws SystemException if a system exception occurred
2289             */
2290            public JournalArticle findByResourcePrimKey_Last(long resourcePrimKey,
2291                    OrderByComparator orderByComparator)
2292                    throws NoSuchArticleException, SystemException {
2293                    int count = countByResourcePrimKey(resourcePrimKey);
2294    
2295                    List<JournalArticle> list = findByResourcePrimKey(resourcePrimKey,
2296                                    count - 1, count, orderByComparator);
2297    
2298                    if (list.isEmpty()) {
2299                            StringBundler msg = new StringBundler(4);
2300    
2301                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2302    
2303                            msg.append("resourcePrimKey=");
2304                            msg.append(resourcePrimKey);
2305    
2306                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2307    
2308                            throw new NoSuchArticleException(msg.toString());
2309                    }
2310                    else {
2311                            return list.get(0);
2312                    }
2313            }
2314    
2315            /**
2316             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63;.
2317             *
2318             * <p>
2319             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2320             * </p>
2321             *
2322             * @param id the primary key of the current journal article
2323             * @param resourcePrimKey the resource prim key
2324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2325             * @return the previous, current, and next journal article
2326             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2327             * @throws SystemException if a system exception occurred
2328             */
2329            public JournalArticle[] findByResourcePrimKey_PrevAndNext(long id,
2330                    long resourcePrimKey, OrderByComparator orderByComparator)
2331                    throws NoSuchArticleException, SystemException {
2332                    JournalArticle journalArticle = findByPrimaryKey(id);
2333    
2334                    Session session = null;
2335    
2336                    try {
2337                            session = openSession();
2338    
2339                            JournalArticle[] array = new JournalArticleImpl[3];
2340    
2341                            array[0] = getByResourcePrimKey_PrevAndNext(session,
2342                                            journalArticle, resourcePrimKey, orderByComparator, true);
2343    
2344                            array[1] = journalArticle;
2345    
2346                            array[2] = getByResourcePrimKey_PrevAndNext(session,
2347                                            journalArticle, resourcePrimKey, orderByComparator, false);
2348    
2349                            return array;
2350                    }
2351                    catch (Exception e) {
2352                            throw processException(e);
2353                    }
2354                    finally {
2355                            closeSession(session);
2356                    }
2357            }
2358    
2359            protected JournalArticle getByResourcePrimKey_PrevAndNext(Session session,
2360                    JournalArticle journalArticle, long resourcePrimKey,
2361                    OrderByComparator orderByComparator, boolean previous) {
2362                    StringBundler query = null;
2363    
2364                    if (orderByComparator != null) {
2365                            query = new StringBundler(6 +
2366                                            (orderByComparator.getOrderByFields().length * 6));
2367                    }
2368                    else {
2369                            query = new StringBundler(3);
2370                    }
2371    
2372                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2373    
2374                    query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
2375    
2376                    if (orderByComparator != null) {
2377                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2378    
2379                            if (orderByConditionFields.length > 0) {
2380                                    query.append(WHERE_AND);
2381                            }
2382    
2383                            for (int i = 0; i < orderByConditionFields.length; i++) {
2384                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2385                                    query.append(orderByConditionFields[i]);
2386    
2387                                    if ((i + 1) < orderByConditionFields.length) {
2388                                            if (orderByComparator.isAscending() ^ previous) {
2389                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2390                                            }
2391                                            else {
2392                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2393                                            }
2394                                    }
2395                                    else {
2396                                            if (orderByComparator.isAscending() ^ previous) {
2397                                                    query.append(WHERE_GREATER_THAN);
2398                                            }
2399                                            else {
2400                                                    query.append(WHERE_LESSER_THAN);
2401                                            }
2402                                    }
2403                            }
2404    
2405                            query.append(ORDER_BY_CLAUSE);
2406    
2407                            String[] orderByFields = orderByComparator.getOrderByFields();
2408    
2409                            for (int i = 0; i < orderByFields.length; i++) {
2410                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2411                                    query.append(orderByFields[i]);
2412    
2413                                    if ((i + 1) < orderByFields.length) {
2414                                            if (orderByComparator.isAscending() ^ previous) {
2415                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2416                                            }
2417                                            else {
2418                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2419                                            }
2420                                    }
2421                                    else {
2422                                            if (orderByComparator.isAscending() ^ previous) {
2423                                                    query.append(ORDER_BY_ASC);
2424                                            }
2425                                            else {
2426                                                    query.append(ORDER_BY_DESC);
2427                                            }
2428                                    }
2429                            }
2430                    }
2431    
2432                    else {
2433                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2434                    }
2435    
2436                    String sql = query.toString();
2437    
2438                    Query q = session.createQuery(sql);
2439    
2440                    q.setFirstResult(0);
2441                    q.setMaxResults(2);
2442    
2443                    QueryPos qPos = QueryPos.getInstance(q);
2444    
2445                    qPos.add(resourcePrimKey);
2446    
2447                    if (orderByComparator != null) {
2448                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2449    
2450                            for (Object value : values) {
2451                                    qPos.add(value);
2452                            }
2453                    }
2454    
2455                    List<JournalArticle> list = q.list();
2456    
2457                    if (list.size() == 2) {
2458                            return list.get(1);
2459                    }
2460                    else {
2461                            return null;
2462                    }
2463            }
2464    
2465            /**
2466             * Returns all the journal articles where groupId = &#63;.
2467             *
2468             * @param groupId the group ID
2469             * @return the matching journal articles
2470             * @throws SystemException if a system exception occurred
2471             */
2472            public List<JournalArticle> findByGroupId(long groupId)
2473                    throws SystemException {
2474                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2475            }
2476    
2477            /**
2478             * Returns a range of all the journal articles where groupId = &#63;.
2479             *
2480             * <p>
2481             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2482             * </p>
2483             *
2484             * @param groupId the group ID
2485             * @param start the lower bound of the range of journal articles
2486             * @param end the upper bound of the range of journal articles (not inclusive)
2487             * @return the range of matching journal articles
2488             * @throws SystemException if a system exception occurred
2489             */
2490            public List<JournalArticle> findByGroupId(long groupId, int start, int end)
2491                    throws SystemException {
2492                    return findByGroupId(groupId, start, end, null);
2493            }
2494    
2495            /**
2496             * Returns an ordered range of all the journal articles where groupId = &#63;.
2497             *
2498             * <p>
2499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2500             * </p>
2501             *
2502             * @param groupId the group ID
2503             * @param start the lower bound of the range of journal articles
2504             * @param end the upper bound of the range of journal articles (not inclusive)
2505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2506             * @return the ordered range of matching journal articles
2507             * @throws SystemException if a system exception occurred
2508             */
2509            public List<JournalArticle> findByGroupId(long groupId, int start, int end,
2510                    OrderByComparator orderByComparator) throws SystemException {
2511                    FinderPath finderPath = null;
2512                    Object[] finderArgs = null;
2513    
2514                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2515                                    (orderByComparator == null)) {
2516                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2517                            finderArgs = new Object[] { groupId };
2518                    }
2519                    else {
2520                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2521                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2522                    }
2523    
2524                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
2525                                    finderArgs, this);
2526    
2527                    if (list == null) {
2528                            StringBundler query = null;
2529    
2530                            if (orderByComparator != null) {
2531                                    query = new StringBundler(3 +
2532                                                    (orderByComparator.getOrderByFields().length * 3));
2533                            }
2534                            else {
2535                                    query = new StringBundler(3);
2536                            }
2537    
2538                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2539    
2540                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2541    
2542                            if (orderByComparator != null) {
2543                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2544                                            orderByComparator);
2545                            }
2546    
2547                            else {
2548                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2549                            }
2550    
2551                            String sql = query.toString();
2552    
2553                            Session session = null;
2554    
2555                            try {
2556                                    session = openSession();
2557    
2558                                    Query q = session.createQuery(sql);
2559    
2560                                    QueryPos qPos = QueryPos.getInstance(q);
2561    
2562                                    qPos.add(groupId);
2563    
2564                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
2565                                                    start, end);
2566                            }
2567                            catch (Exception e) {
2568                                    throw processException(e);
2569                            }
2570                            finally {
2571                                    if (list == null) {
2572                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2573                                    }
2574                                    else {
2575                                            cacheResult(list);
2576    
2577                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2578                                    }
2579    
2580                                    closeSession(session);
2581                            }
2582                    }
2583    
2584                    return list;
2585            }
2586    
2587            /**
2588             * Returns the first journal article in the ordered set where groupId = &#63;.
2589             *
2590             * <p>
2591             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2592             * </p>
2593             *
2594             * @param groupId the group ID
2595             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2596             * @return the first matching journal article
2597             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2598             * @throws SystemException if a system exception occurred
2599             */
2600            public JournalArticle findByGroupId_First(long groupId,
2601                    OrderByComparator orderByComparator)
2602                    throws NoSuchArticleException, SystemException {
2603                    List<JournalArticle> list = findByGroupId(groupId, 0, 1,
2604                                    orderByComparator);
2605    
2606                    if (list.isEmpty()) {
2607                            StringBundler msg = new StringBundler(4);
2608    
2609                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2610    
2611                            msg.append("groupId=");
2612                            msg.append(groupId);
2613    
2614                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2615    
2616                            throw new NoSuchArticleException(msg.toString());
2617                    }
2618                    else {
2619                            return list.get(0);
2620                    }
2621            }
2622    
2623            /**
2624             * Returns the last journal article in the ordered set where groupId = &#63;.
2625             *
2626             * <p>
2627             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2628             * </p>
2629             *
2630             * @param groupId the group ID
2631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2632             * @return the last matching journal article
2633             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
2634             * @throws SystemException if a system exception occurred
2635             */
2636            public JournalArticle findByGroupId_Last(long groupId,
2637                    OrderByComparator orderByComparator)
2638                    throws NoSuchArticleException, SystemException {
2639                    int count = countByGroupId(groupId);
2640    
2641                    List<JournalArticle> list = findByGroupId(groupId, count - 1, count,
2642                                    orderByComparator);
2643    
2644                    if (list.isEmpty()) {
2645                            StringBundler msg = new StringBundler(4);
2646    
2647                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2648    
2649                            msg.append("groupId=");
2650                            msg.append(groupId);
2651    
2652                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2653    
2654                            throw new NoSuchArticleException(msg.toString());
2655                    }
2656                    else {
2657                            return list.get(0);
2658                    }
2659            }
2660    
2661            /**
2662             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63;.
2663             *
2664             * <p>
2665             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2666             * </p>
2667             *
2668             * @param id the primary key of the current journal article
2669             * @param groupId the group ID
2670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2671             * @return the previous, current, and next journal article
2672             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2673             * @throws SystemException if a system exception occurred
2674             */
2675            public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
2676                    OrderByComparator orderByComparator)
2677                    throws NoSuchArticleException, SystemException {
2678                    JournalArticle journalArticle = findByPrimaryKey(id);
2679    
2680                    Session session = null;
2681    
2682                    try {
2683                            session = openSession();
2684    
2685                            JournalArticle[] array = new JournalArticleImpl[3];
2686    
2687                            array[0] = getByGroupId_PrevAndNext(session, journalArticle,
2688                                            groupId, orderByComparator, true);
2689    
2690                            array[1] = journalArticle;
2691    
2692                            array[2] = getByGroupId_PrevAndNext(session, journalArticle,
2693                                            groupId, orderByComparator, false);
2694    
2695                            return array;
2696                    }
2697                    catch (Exception e) {
2698                            throw processException(e);
2699                    }
2700                    finally {
2701                            closeSession(session);
2702                    }
2703            }
2704    
2705            protected JournalArticle getByGroupId_PrevAndNext(Session session,
2706                    JournalArticle journalArticle, long groupId,
2707                    OrderByComparator orderByComparator, boolean previous) {
2708                    StringBundler query = null;
2709    
2710                    if (orderByComparator != null) {
2711                            query = new StringBundler(6 +
2712                                            (orderByComparator.getOrderByFields().length * 6));
2713                    }
2714                    else {
2715                            query = new StringBundler(3);
2716                    }
2717    
2718                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
2719    
2720                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2721    
2722                    if (orderByComparator != null) {
2723                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2724    
2725                            if (orderByConditionFields.length > 0) {
2726                                    query.append(WHERE_AND);
2727                            }
2728    
2729                            for (int i = 0; i < orderByConditionFields.length; i++) {
2730                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2731                                    query.append(orderByConditionFields[i]);
2732    
2733                                    if ((i + 1) < orderByConditionFields.length) {
2734                                            if (orderByComparator.isAscending() ^ previous) {
2735                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2736                                            }
2737                                            else {
2738                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2739                                            }
2740                                    }
2741                                    else {
2742                                            if (orderByComparator.isAscending() ^ previous) {
2743                                                    query.append(WHERE_GREATER_THAN);
2744                                            }
2745                                            else {
2746                                                    query.append(WHERE_LESSER_THAN);
2747                                            }
2748                                    }
2749                            }
2750    
2751                            query.append(ORDER_BY_CLAUSE);
2752    
2753                            String[] orderByFields = orderByComparator.getOrderByFields();
2754    
2755                            for (int i = 0; i < orderByFields.length; i++) {
2756                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2757                                    query.append(orderByFields[i]);
2758    
2759                                    if ((i + 1) < orderByFields.length) {
2760                                            if (orderByComparator.isAscending() ^ previous) {
2761                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2762                                            }
2763                                            else {
2764                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2765                                            }
2766                                    }
2767                                    else {
2768                                            if (orderByComparator.isAscending() ^ previous) {
2769                                                    query.append(ORDER_BY_ASC);
2770                                            }
2771                                            else {
2772                                                    query.append(ORDER_BY_DESC);
2773                                            }
2774                                    }
2775                            }
2776                    }
2777    
2778                    else {
2779                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2780                    }
2781    
2782                    String sql = query.toString();
2783    
2784                    Query q = session.createQuery(sql);
2785    
2786                    q.setFirstResult(0);
2787                    q.setMaxResults(2);
2788    
2789                    QueryPos qPos = QueryPos.getInstance(q);
2790    
2791                    qPos.add(groupId);
2792    
2793                    if (orderByComparator != null) {
2794                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
2795    
2796                            for (Object value : values) {
2797                                    qPos.add(value);
2798                            }
2799                    }
2800    
2801                    List<JournalArticle> list = q.list();
2802    
2803                    if (list.size() == 2) {
2804                            return list.get(1);
2805                    }
2806                    else {
2807                            return null;
2808                    }
2809            }
2810    
2811            /**
2812             * Returns all the journal articles that the user has permission to view where groupId = &#63;.
2813             *
2814             * @param groupId the group ID
2815             * @return the matching journal articles that the user has permission to view
2816             * @throws SystemException if a system exception occurred
2817             */
2818            public List<JournalArticle> filterFindByGroupId(long groupId)
2819                    throws SystemException {
2820                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2821                            QueryUtil.ALL_POS, null);
2822            }
2823    
2824            /**
2825             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63;.
2826             *
2827             * <p>
2828             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2829             * </p>
2830             *
2831             * @param groupId the group ID
2832             * @param start the lower bound of the range of journal articles
2833             * @param end the upper bound of the range of journal articles (not inclusive)
2834             * @return the range of matching journal articles that the user has permission to view
2835             * @throws SystemException if a system exception occurred
2836             */
2837            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2838                    int end) throws SystemException {
2839                    return filterFindByGroupId(groupId, start, end, null);
2840            }
2841    
2842            /**
2843             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63;.
2844             *
2845             * <p>
2846             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2847             * </p>
2848             *
2849             * @param groupId the group ID
2850             * @param start the lower bound of the range of journal articles
2851             * @param end the upper bound of the range of journal articles (not inclusive)
2852             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2853             * @return the ordered range of matching journal articles that the user has permission to view
2854             * @throws SystemException if a system exception occurred
2855             */
2856            public List<JournalArticle> filterFindByGroupId(long groupId, int start,
2857                    int end, OrderByComparator orderByComparator) throws SystemException {
2858                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2859                            return findByGroupId(groupId, start, end, orderByComparator);
2860                    }
2861    
2862                    StringBundler query = null;
2863    
2864                    if (orderByComparator != null) {
2865                            query = new StringBundler(3 +
2866                                            (orderByComparator.getOrderByFields().length * 3));
2867                    }
2868                    else {
2869                            query = new StringBundler(3);
2870                    }
2871    
2872                    if (getDB().isSupportsInlineDistinct()) {
2873                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2874                    }
2875                    else {
2876                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
2877                    }
2878    
2879                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2880    
2881                    if (!getDB().isSupportsInlineDistinct()) {
2882                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
2883                    }
2884    
2885                    if (orderByComparator != null) {
2886                            if (getDB().isSupportsInlineDistinct()) {
2887                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2888                                            orderByComparator);
2889                            }
2890                            else {
2891                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2892                                            orderByComparator);
2893                            }
2894                    }
2895    
2896                    else {
2897                            if (getDB().isSupportsInlineDistinct()) {
2898                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
2899                            }
2900                            else {
2901                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
2902                            }
2903                    }
2904    
2905                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2906                                    JournalArticle.class.getName(),
2907                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2908    
2909                    Session session = null;
2910    
2911                    try {
2912                            session = openSession();
2913    
2914                            SQLQuery q = session.createSQLQuery(sql);
2915    
2916                            if (getDB().isSupportsInlineDistinct()) {
2917                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
2918                            }
2919                            else {
2920                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
2921                            }
2922    
2923                            QueryPos qPos = QueryPos.getInstance(q);
2924    
2925                            qPos.add(groupId);
2926    
2927                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
2928                                    end);
2929                    }
2930                    catch (Exception e) {
2931                            throw processException(e);
2932                    }
2933                    finally {
2934                            closeSession(session);
2935                    }
2936            }
2937    
2938            /**
2939             * 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;.
2940             *
2941             * @param id the primary key of the current journal article
2942             * @param groupId the group ID
2943             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2944             * @return the previous, current, and next journal article
2945             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
2946             * @throws SystemException if a system exception occurred
2947             */
2948            public JournalArticle[] filterFindByGroupId_PrevAndNext(long id,
2949                    long groupId, OrderByComparator orderByComparator)
2950                    throws NoSuchArticleException, SystemException {
2951                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2952                            return findByGroupId_PrevAndNext(id, groupId, orderByComparator);
2953                    }
2954    
2955                    JournalArticle journalArticle = findByPrimaryKey(id);
2956    
2957                    Session session = null;
2958    
2959                    try {
2960                            session = openSession();
2961    
2962                            JournalArticle[] array = new JournalArticleImpl[3];
2963    
2964                            array[0] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2965                                            groupId, orderByComparator, true);
2966    
2967                            array[1] = journalArticle;
2968    
2969                            array[2] = filterGetByGroupId_PrevAndNext(session, journalArticle,
2970                                            groupId, orderByComparator, false);
2971    
2972                            return array;
2973                    }
2974                    catch (Exception e) {
2975                            throw processException(e);
2976                    }
2977                    finally {
2978                            closeSession(session);
2979                    }
2980            }
2981    
2982            protected JournalArticle filterGetByGroupId_PrevAndNext(Session session,
2983                    JournalArticle journalArticle, long groupId,
2984                    OrderByComparator orderByComparator, boolean previous) {
2985                    StringBundler query = null;
2986    
2987                    if (orderByComparator != null) {
2988                            query = new StringBundler(6 +
2989                                            (orderByComparator.getOrderByFields().length * 6));
2990                    }
2991                    else {
2992                            query = new StringBundler(3);
2993                    }
2994    
2995                    if (getDB().isSupportsInlineDistinct()) {
2996                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
2997                    }
2998                    else {
2999                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
3000                    }
3001    
3002                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
3003    
3004                    if (!getDB().isSupportsInlineDistinct()) {
3005                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
3006                    }
3007    
3008                    if (orderByComparator != null) {
3009                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3010    
3011                            if (orderByConditionFields.length > 0) {
3012                                    query.append(WHERE_AND);
3013                            }
3014    
3015                            for (int i = 0; i < orderByConditionFields.length; i++) {
3016                                    if (getDB().isSupportsInlineDistinct()) {
3017                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3018                                    }
3019                                    else {
3020                                            query.append(_ORDER_BY_ENTITY_TABLE);
3021                                    }
3022    
3023                                    query.append(orderByConditionFields[i]);
3024    
3025                                    if ((i + 1) < orderByConditionFields.length) {
3026                                            if (orderByComparator.isAscending() ^ previous) {
3027                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3028                                            }
3029                                            else {
3030                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3031                                            }
3032                                    }
3033                                    else {
3034                                            if (orderByComparator.isAscending() ^ previous) {
3035                                                    query.append(WHERE_GREATER_THAN);
3036                                            }
3037                                            else {
3038                                                    query.append(WHERE_LESSER_THAN);
3039                                            }
3040                                    }
3041                            }
3042    
3043                            query.append(ORDER_BY_CLAUSE);
3044    
3045                            String[] orderByFields = orderByComparator.getOrderByFields();
3046    
3047                            for (int i = 0; i < orderByFields.length; i++) {
3048                                    if (getDB().isSupportsInlineDistinct()) {
3049                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3050                                    }
3051                                    else {
3052                                            query.append(_ORDER_BY_ENTITY_TABLE);
3053                                    }
3054    
3055                                    query.append(orderByFields[i]);
3056    
3057                                    if ((i + 1) < orderByFields.length) {
3058                                            if (orderByComparator.isAscending() ^ previous) {
3059                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3060                                            }
3061                                            else {
3062                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3063                                            }
3064                                    }
3065                                    else {
3066                                            if (orderByComparator.isAscending() ^ previous) {
3067                                                    query.append(ORDER_BY_ASC);
3068                                            }
3069                                            else {
3070                                                    query.append(ORDER_BY_DESC);
3071                                            }
3072                                    }
3073                            }
3074                    }
3075    
3076                    else {
3077                            if (getDB().isSupportsInlineDistinct()) {
3078                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3079                            }
3080                            else {
3081                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
3082                            }
3083                    }
3084    
3085                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3086                                    JournalArticle.class.getName(),
3087                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3088    
3089                    SQLQuery q = session.createSQLQuery(sql);
3090    
3091                    q.setFirstResult(0);
3092                    q.setMaxResults(2);
3093    
3094                    if (getDB().isSupportsInlineDistinct()) {
3095                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
3096                    }
3097                    else {
3098                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
3099                    }
3100    
3101                    QueryPos qPos = QueryPos.getInstance(q);
3102    
3103                    qPos.add(groupId);
3104    
3105                    if (orderByComparator != null) {
3106                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3107    
3108                            for (Object value : values) {
3109                                    qPos.add(value);
3110                            }
3111                    }
3112    
3113                    List<JournalArticle> list = q.list();
3114    
3115                    if (list.size() == 2) {
3116                            return list.get(1);
3117                    }
3118                    else {
3119                            return null;
3120                    }
3121            }
3122    
3123            /**
3124             * Returns all the journal articles where companyId = &#63;.
3125             *
3126             * @param companyId the company ID
3127             * @return the matching journal articles
3128             * @throws SystemException if a system exception occurred
3129             */
3130            public List<JournalArticle> findByCompanyId(long companyId)
3131                    throws SystemException {
3132                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3133                            null);
3134            }
3135    
3136            /**
3137             * Returns a range of all the journal articles where companyId = &#63;.
3138             *
3139             * <p>
3140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3141             * </p>
3142             *
3143             * @param companyId the company ID
3144             * @param start the lower bound of the range of journal articles
3145             * @param end the upper bound of the range of journal articles (not inclusive)
3146             * @return the range of matching journal articles
3147             * @throws SystemException if a system exception occurred
3148             */
3149            public List<JournalArticle> findByCompanyId(long companyId, int start,
3150                    int end) throws SystemException {
3151                    return findByCompanyId(companyId, start, end, null);
3152            }
3153    
3154            /**
3155             * Returns an ordered range of all the journal articles where companyId = &#63;.
3156             *
3157             * <p>
3158             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3159             * </p>
3160             *
3161             * @param companyId the company ID
3162             * @param start the lower bound of the range of journal articles
3163             * @param end the upper bound of the range of journal articles (not inclusive)
3164             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3165             * @return the ordered range of matching journal articles
3166             * @throws SystemException if a system exception occurred
3167             */
3168            public List<JournalArticle> findByCompanyId(long companyId, int start,
3169                    int end, OrderByComparator orderByComparator) throws SystemException {
3170                    FinderPath finderPath = null;
3171                    Object[] finderArgs = null;
3172    
3173                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3174                                    (orderByComparator == null)) {
3175                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
3176                            finderArgs = new Object[] { companyId };
3177                    }
3178                    else {
3179                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
3180                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
3181                    }
3182    
3183                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3184                                    finderArgs, this);
3185    
3186                    if (list == null) {
3187                            StringBundler query = null;
3188    
3189                            if (orderByComparator != null) {
3190                                    query = new StringBundler(3 +
3191                                                    (orderByComparator.getOrderByFields().length * 3));
3192                            }
3193                            else {
3194                                    query = new StringBundler(3);
3195                            }
3196    
3197                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3198    
3199                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3200    
3201                            if (orderByComparator != null) {
3202                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3203                                            orderByComparator);
3204                            }
3205    
3206                            else {
3207                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3208                            }
3209    
3210                            String sql = query.toString();
3211    
3212                            Session session = null;
3213    
3214                            try {
3215                                    session = openSession();
3216    
3217                                    Query q = session.createQuery(sql);
3218    
3219                                    QueryPos qPos = QueryPos.getInstance(q);
3220    
3221                                    qPos.add(companyId);
3222    
3223                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3224                                                    start, end);
3225                            }
3226                            catch (Exception e) {
3227                                    throw processException(e);
3228                            }
3229                            finally {
3230                                    if (list == null) {
3231                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3232                                    }
3233                                    else {
3234                                            cacheResult(list);
3235    
3236                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3237                                    }
3238    
3239                                    closeSession(session);
3240                            }
3241                    }
3242    
3243                    return list;
3244            }
3245    
3246            /**
3247             * Returns the first journal article in the ordered set where companyId = &#63;.
3248             *
3249             * <p>
3250             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3251             * </p>
3252             *
3253             * @param companyId the company ID
3254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3255             * @return the first matching journal article
3256             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3257             * @throws SystemException if a system exception occurred
3258             */
3259            public JournalArticle findByCompanyId_First(long companyId,
3260                    OrderByComparator orderByComparator)
3261                    throws NoSuchArticleException, SystemException {
3262                    List<JournalArticle> list = findByCompanyId(companyId, 0, 1,
3263                                    orderByComparator);
3264    
3265                    if (list.isEmpty()) {
3266                            StringBundler msg = new StringBundler(4);
3267    
3268                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3269    
3270                            msg.append("companyId=");
3271                            msg.append(companyId);
3272    
3273                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3274    
3275                            throw new NoSuchArticleException(msg.toString());
3276                    }
3277                    else {
3278                            return list.get(0);
3279                    }
3280            }
3281    
3282            /**
3283             * Returns the last journal article in the ordered set where companyId = &#63;.
3284             *
3285             * <p>
3286             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3287             * </p>
3288             *
3289             * @param companyId the company ID
3290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3291             * @return the last matching journal article
3292             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3293             * @throws SystemException if a system exception occurred
3294             */
3295            public JournalArticle findByCompanyId_Last(long companyId,
3296                    OrderByComparator orderByComparator)
3297                    throws NoSuchArticleException, SystemException {
3298                    int count = countByCompanyId(companyId);
3299    
3300                    List<JournalArticle> list = findByCompanyId(companyId, count - 1,
3301                                    count, orderByComparator);
3302    
3303                    if (list.isEmpty()) {
3304                            StringBundler msg = new StringBundler(4);
3305    
3306                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3307    
3308                            msg.append("companyId=");
3309                            msg.append(companyId);
3310    
3311                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3312    
3313                            throw new NoSuchArticleException(msg.toString());
3314                    }
3315                    else {
3316                            return list.get(0);
3317                    }
3318            }
3319    
3320            /**
3321             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63;.
3322             *
3323             * <p>
3324             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3325             * </p>
3326             *
3327             * @param id the primary key of the current journal article
3328             * @param companyId the company ID
3329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3330             * @return the previous, current, and next journal article
3331             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3332             * @throws SystemException if a system exception occurred
3333             */
3334            public JournalArticle[] findByCompanyId_PrevAndNext(long id,
3335                    long companyId, OrderByComparator orderByComparator)
3336                    throws NoSuchArticleException, SystemException {
3337                    JournalArticle journalArticle = findByPrimaryKey(id);
3338    
3339                    Session session = null;
3340    
3341                    try {
3342                            session = openSession();
3343    
3344                            JournalArticle[] array = new JournalArticleImpl[3];
3345    
3346                            array[0] = getByCompanyId_PrevAndNext(session, journalArticle,
3347                                            companyId, orderByComparator, true);
3348    
3349                            array[1] = journalArticle;
3350    
3351                            array[2] = getByCompanyId_PrevAndNext(session, journalArticle,
3352                                            companyId, orderByComparator, false);
3353    
3354                            return array;
3355                    }
3356                    catch (Exception e) {
3357                            throw processException(e);
3358                    }
3359                    finally {
3360                            closeSession(session);
3361                    }
3362            }
3363    
3364            protected JournalArticle getByCompanyId_PrevAndNext(Session session,
3365                    JournalArticle journalArticle, long companyId,
3366                    OrderByComparator orderByComparator, boolean previous) {
3367                    StringBundler query = null;
3368    
3369                    if (orderByComparator != null) {
3370                            query = new StringBundler(6 +
3371                                            (orderByComparator.getOrderByFields().length * 6));
3372                    }
3373                    else {
3374                            query = new StringBundler(3);
3375                    }
3376    
3377                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3378    
3379                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3380    
3381                    if (orderByComparator != null) {
3382                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3383    
3384                            if (orderByConditionFields.length > 0) {
3385                                    query.append(WHERE_AND);
3386                            }
3387    
3388                            for (int i = 0; i < orderByConditionFields.length; i++) {
3389                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3390                                    query.append(orderByConditionFields[i]);
3391    
3392                                    if ((i + 1) < orderByConditionFields.length) {
3393                                            if (orderByComparator.isAscending() ^ previous) {
3394                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3395                                            }
3396                                            else {
3397                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3398                                            }
3399                                    }
3400                                    else {
3401                                            if (orderByComparator.isAscending() ^ previous) {
3402                                                    query.append(WHERE_GREATER_THAN);
3403                                            }
3404                                            else {
3405                                                    query.append(WHERE_LESSER_THAN);
3406                                            }
3407                                    }
3408                            }
3409    
3410                            query.append(ORDER_BY_CLAUSE);
3411    
3412                            String[] orderByFields = orderByComparator.getOrderByFields();
3413    
3414                            for (int i = 0; i < orderByFields.length; i++) {
3415                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3416                                    query.append(orderByFields[i]);
3417    
3418                                    if ((i + 1) < orderByFields.length) {
3419                                            if (orderByComparator.isAscending() ^ previous) {
3420                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3421                                            }
3422                                            else {
3423                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3424                                            }
3425                                    }
3426                                    else {
3427                                            if (orderByComparator.isAscending() ^ previous) {
3428                                                    query.append(ORDER_BY_ASC);
3429                                            }
3430                                            else {
3431                                                    query.append(ORDER_BY_DESC);
3432                                            }
3433                                    }
3434                            }
3435                    }
3436    
3437                    else {
3438                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3439                    }
3440    
3441                    String sql = query.toString();
3442    
3443                    Query q = session.createQuery(sql);
3444    
3445                    q.setFirstResult(0);
3446                    q.setMaxResults(2);
3447    
3448                    QueryPos qPos = QueryPos.getInstance(q);
3449    
3450                    qPos.add(companyId);
3451    
3452                    if (orderByComparator != null) {
3453                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3454    
3455                            for (Object value : values) {
3456                                    qPos.add(value);
3457                            }
3458                    }
3459    
3460                    List<JournalArticle> list = q.list();
3461    
3462                    if (list.size() == 2) {
3463                            return list.get(1);
3464                    }
3465                    else {
3466                            return null;
3467                    }
3468            }
3469    
3470            /**
3471             * Returns all the journal articles where smallImageId = &#63;.
3472             *
3473             * @param smallImageId the small image ID
3474             * @return the matching journal articles
3475             * @throws SystemException if a system exception occurred
3476             */
3477            public List<JournalArticle> findBySmallImageId(long smallImageId)
3478                    throws SystemException {
3479                    return findBySmallImageId(smallImageId, QueryUtil.ALL_POS,
3480                            QueryUtil.ALL_POS, null);
3481            }
3482    
3483            /**
3484             * Returns a range of all the journal articles where smallImageId = &#63;.
3485             *
3486             * <p>
3487             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3488             * </p>
3489             *
3490             * @param smallImageId the small image ID
3491             * @param start the lower bound of the range of journal articles
3492             * @param end the upper bound of the range of journal articles (not inclusive)
3493             * @return the range of matching journal articles
3494             * @throws SystemException if a system exception occurred
3495             */
3496            public List<JournalArticle> findBySmallImageId(long smallImageId,
3497                    int start, int end) throws SystemException {
3498                    return findBySmallImageId(smallImageId, start, end, null);
3499            }
3500    
3501            /**
3502             * Returns an ordered range of all the journal articles where smallImageId = &#63;.
3503             *
3504             * <p>
3505             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3506             * </p>
3507             *
3508             * @param smallImageId the small image ID
3509             * @param start the lower bound of the range of journal articles
3510             * @param end the upper bound of the range of journal articles (not inclusive)
3511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3512             * @return the ordered range of matching journal articles
3513             * @throws SystemException if a system exception occurred
3514             */
3515            public List<JournalArticle> findBySmallImageId(long smallImageId,
3516                    int start, int end, OrderByComparator orderByComparator)
3517                    throws SystemException {
3518                    FinderPath finderPath = null;
3519                    Object[] finderArgs = null;
3520    
3521                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3522                                    (orderByComparator == null)) {
3523                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SMALLIMAGEID;
3524                            finderArgs = new Object[] { smallImageId };
3525                    }
3526                    else {
3527                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SMALLIMAGEID;
3528                            finderArgs = new Object[] {
3529                                            smallImageId,
3530                                            
3531                                            start, end, orderByComparator
3532                                    };
3533                    }
3534    
3535                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3536                                    finderArgs, this);
3537    
3538                    if (list == null) {
3539                            StringBundler query = null;
3540    
3541                            if (orderByComparator != null) {
3542                                    query = new StringBundler(3 +
3543                                                    (orderByComparator.getOrderByFields().length * 3));
3544                            }
3545                            else {
3546                                    query = new StringBundler(3);
3547                            }
3548    
3549                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3550    
3551                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
3552    
3553                            if (orderByComparator != null) {
3554                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3555                                            orderByComparator);
3556                            }
3557    
3558                            else {
3559                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3560                            }
3561    
3562                            String sql = query.toString();
3563    
3564                            Session session = null;
3565    
3566                            try {
3567                                    session = openSession();
3568    
3569                                    Query q = session.createQuery(sql);
3570    
3571                                    QueryPos qPos = QueryPos.getInstance(q);
3572    
3573                                    qPos.add(smallImageId);
3574    
3575                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3576                                                    start, end);
3577                            }
3578                            catch (Exception e) {
3579                                    throw processException(e);
3580                            }
3581                            finally {
3582                                    if (list == null) {
3583                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3584                                    }
3585                                    else {
3586                                            cacheResult(list);
3587    
3588                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3589                                    }
3590    
3591                                    closeSession(session);
3592                            }
3593                    }
3594    
3595                    return list;
3596            }
3597    
3598            /**
3599             * Returns the first journal article in the ordered set where smallImageId = &#63;.
3600             *
3601             * <p>
3602             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3603             * </p>
3604             *
3605             * @param smallImageId the small image ID
3606             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3607             * @return the first matching journal article
3608             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3609             * @throws SystemException if a system exception occurred
3610             */
3611            public JournalArticle findBySmallImageId_First(long smallImageId,
3612                    OrderByComparator orderByComparator)
3613                    throws NoSuchArticleException, SystemException {
3614                    List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1,
3615                                    orderByComparator);
3616    
3617                    if (list.isEmpty()) {
3618                            StringBundler msg = new StringBundler(4);
3619    
3620                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3621    
3622                            msg.append("smallImageId=");
3623                            msg.append(smallImageId);
3624    
3625                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3626    
3627                            throw new NoSuchArticleException(msg.toString());
3628                    }
3629                    else {
3630                            return list.get(0);
3631                    }
3632            }
3633    
3634            /**
3635             * Returns the last journal article in the ordered set where smallImageId = &#63;.
3636             *
3637             * <p>
3638             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3639             * </p>
3640             *
3641             * @param smallImageId the small image ID
3642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3643             * @return the last matching journal article
3644             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3645             * @throws SystemException if a system exception occurred
3646             */
3647            public JournalArticle findBySmallImageId_Last(long smallImageId,
3648                    OrderByComparator orderByComparator)
3649                    throws NoSuchArticleException, SystemException {
3650                    int count = countBySmallImageId(smallImageId);
3651    
3652                    List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
3653                                    count, orderByComparator);
3654    
3655                    if (list.isEmpty()) {
3656                            StringBundler msg = new StringBundler(4);
3657    
3658                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3659    
3660                            msg.append("smallImageId=");
3661                            msg.append(smallImageId);
3662    
3663                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3664    
3665                            throw new NoSuchArticleException(msg.toString());
3666                    }
3667                    else {
3668                            return list.get(0);
3669                    }
3670            }
3671    
3672            /**
3673             * Returns the journal articles before and after the current journal article in the ordered set where smallImageId = &#63;.
3674             *
3675             * <p>
3676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3677             * </p>
3678             *
3679             * @param id the primary key of the current journal article
3680             * @param smallImageId the small image ID
3681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3682             * @return the previous, current, and next journal article
3683             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
3684             * @throws SystemException if a system exception occurred
3685             */
3686            public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
3687                    long smallImageId, OrderByComparator orderByComparator)
3688                    throws NoSuchArticleException, SystemException {
3689                    JournalArticle journalArticle = findByPrimaryKey(id);
3690    
3691                    Session session = null;
3692    
3693                    try {
3694                            session = openSession();
3695    
3696                            JournalArticle[] array = new JournalArticleImpl[3];
3697    
3698                            array[0] = getBySmallImageId_PrevAndNext(session, journalArticle,
3699                                            smallImageId, orderByComparator, true);
3700    
3701                            array[1] = journalArticle;
3702    
3703                            array[2] = getBySmallImageId_PrevAndNext(session, journalArticle,
3704                                            smallImageId, orderByComparator, false);
3705    
3706                            return array;
3707                    }
3708                    catch (Exception e) {
3709                            throw processException(e);
3710                    }
3711                    finally {
3712                            closeSession(session);
3713                    }
3714            }
3715    
3716            protected JournalArticle getBySmallImageId_PrevAndNext(Session session,
3717                    JournalArticle journalArticle, long smallImageId,
3718                    OrderByComparator orderByComparator, boolean previous) {
3719                    StringBundler query = null;
3720    
3721                    if (orderByComparator != null) {
3722                            query = new StringBundler(6 +
3723                                            (orderByComparator.getOrderByFields().length * 6));
3724                    }
3725                    else {
3726                            query = new StringBundler(3);
3727                    }
3728    
3729                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3730    
3731                    query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
3732    
3733                    if (orderByComparator != null) {
3734                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3735    
3736                            if (orderByConditionFields.length > 0) {
3737                                    query.append(WHERE_AND);
3738                            }
3739    
3740                            for (int i = 0; i < orderByConditionFields.length; i++) {
3741                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3742                                    query.append(orderByConditionFields[i]);
3743    
3744                                    if ((i + 1) < orderByConditionFields.length) {
3745                                            if (orderByComparator.isAscending() ^ previous) {
3746                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3747                                            }
3748                                            else {
3749                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3750                                            }
3751                                    }
3752                                    else {
3753                                            if (orderByComparator.isAscending() ^ previous) {
3754                                                    query.append(WHERE_GREATER_THAN);
3755                                            }
3756                                            else {
3757                                                    query.append(WHERE_LESSER_THAN);
3758                                            }
3759                                    }
3760                            }
3761    
3762                            query.append(ORDER_BY_CLAUSE);
3763    
3764                            String[] orderByFields = orderByComparator.getOrderByFields();
3765    
3766                            for (int i = 0; i < orderByFields.length; i++) {
3767                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3768                                    query.append(orderByFields[i]);
3769    
3770                                    if ((i + 1) < orderByFields.length) {
3771                                            if (orderByComparator.isAscending() ^ previous) {
3772                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3773                                            }
3774                                            else {
3775                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3776                                            }
3777                                    }
3778                                    else {
3779                                            if (orderByComparator.isAscending() ^ previous) {
3780                                                    query.append(ORDER_BY_ASC);
3781                                            }
3782                                            else {
3783                                                    query.append(ORDER_BY_DESC);
3784                                            }
3785                                    }
3786                            }
3787                    }
3788    
3789                    else {
3790                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3791                    }
3792    
3793                    String sql = query.toString();
3794    
3795                    Query q = session.createQuery(sql);
3796    
3797                    q.setFirstResult(0);
3798                    q.setMaxResults(2);
3799    
3800                    QueryPos qPos = QueryPos.getInstance(q);
3801    
3802                    qPos.add(smallImageId);
3803    
3804                    if (orderByComparator != null) {
3805                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
3806    
3807                            for (Object value : values) {
3808                                    qPos.add(value);
3809                            }
3810                    }
3811    
3812                    List<JournalArticle> list = q.list();
3813    
3814                    if (list.size() == 2) {
3815                            return list.get(1);
3816                    }
3817                    else {
3818                            return null;
3819                    }
3820            }
3821    
3822            /**
3823             * Returns all the journal articles where resourcePrimKey = &#63; and status = &#63;.
3824             *
3825             * @param resourcePrimKey the resource prim key
3826             * @param status the status
3827             * @return the matching journal articles
3828             * @throws SystemException if a system exception occurred
3829             */
3830            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status)
3831                    throws SystemException {
3832                    return findByR_ST(resourcePrimKey, status, QueryUtil.ALL_POS,
3833                            QueryUtil.ALL_POS, null);
3834            }
3835    
3836            /**
3837             * Returns a range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
3838             *
3839             * <p>
3840             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3841             * </p>
3842             *
3843             * @param resourcePrimKey the resource prim key
3844             * @param status the status
3845             * @param start the lower bound of the range of journal articles
3846             * @param end the upper bound of the range of journal articles (not inclusive)
3847             * @return the range of matching journal articles
3848             * @throws SystemException if a system exception occurred
3849             */
3850            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
3851                    int start, int end) throws SystemException {
3852                    return findByR_ST(resourcePrimKey, status, start, end, null);
3853            }
3854    
3855            /**
3856             * Returns an ordered range of all the journal articles where resourcePrimKey = &#63; and status = &#63;.
3857             *
3858             * <p>
3859             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3860             * </p>
3861             *
3862             * @param resourcePrimKey the resource prim key
3863             * @param status the status
3864             * @param start the lower bound of the range of journal articles
3865             * @param end the upper bound of the range of journal articles (not inclusive)
3866             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3867             * @return the ordered range of matching journal articles
3868             * @throws SystemException if a system exception occurred
3869             */
3870            public List<JournalArticle> findByR_ST(long resourcePrimKey, int status,
3871                    int start, int end, OrderByComparator orderByComparator)
3872                    throws SystemException {
3873                    FinderPath finderPath = null;
3874                    Object[] finderArgs = null;
3875    
3876                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3877                                    (orderByComparator == null)) {
3878                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_ST;
3879                            finderArgs = new Object[] { resourcePrimKey, status };
3880                    }
3881                    else {
3882                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_ST;
3883                            finderArgs = new Object[] {
3884                                            resourcePrimKey, status,
3885                                            
3886                                            start, end, orderByComparator
3887                                    };
3888                    }
3889    
3890                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
3891                                    finderArgs, this);
3892    
3893                    if (list == null) {
3894                            StringBundler query = null;
3895    
3896                            if (orderByComparator != null) {
3897                                    query = new StringBundler(4 +
3898                                                    (orderByComparator.getOrderByFields().length * 3));
3899                            }
3900                            else {
3901                                    query = new StringBundler(4);
3902                            }
3903    
3904                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
3905    
3906                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
3907    
3908                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
3909    
3910                            if (orderByComparator != null) {
3911                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3912                                            orderByComparator);
3913                            }
3914    
3915                            else {
3916                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
3917                            }
3918    
3919                            String sql = query.toString();
3920    
3921                            Session session = null;
3922    
3923                            try {
3924                                    session = openSession();
3925    
3926                                    Query q = session.createQuery(sql);
3927    
3928                                    QueryPos qPos = QueryPos.getInstance(q);
3929    
3930                                    qPos.add(resourcePrimKey);
3931    
3932                                    qPos.add(status);
3933    
3934                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
3935                                                    start, end);
3936                            }
3937                            catch (Exception e) {
3938                                    throw processException(e);
3939                            }
3940                            finally {
3941                                    if (list == null) {
3942                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3943                                    }
3944                                    else {
3945                                            cacheResult(list);
3946    
3947                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3948                                    }
3949    
3950                                    closeSession(session);
3951                            }
3952                    }
3953    
3954                    return list;
3955            }
3956    
3957            /**
3958             * Returns the first journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3959             *
3960             * <p>
3961             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3962             * </p>
3963             *
3964             * @param resourcePrimKey the resource prim key
3965             * @param status the status
3966             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3967             * @return the first matching journal article
3968             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
3969             * @throws SystemException if a system exception occurred
3970             */
3971            public JournalArticle findByR_ST_First(long resourcePrimKey, int status,
3972                    OrderByComparator orderByComparator)
3973                    throws NoSuchArticleException, SystemException {
3974                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status, 0, 1,
3975                                    orderByComparator);
3976    
3977                    if (list.isEmpty()) {
3978                            StringBundler msg = new StringBundler(6);
3979    
3980                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3981    
3982                            msg.append("resourcePrimKey=");
3983                            msg.append(resourcePrimKey);
3984    
3985                            msg.append(", status=");
3986                            msg.append(status);
3987    
3988                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3989    
3990                            throw new NoSuchArticleException(msg.toString());
3991                    }
3992                    else {
3993                            return list.get(0);
3994                    }
3995            }
3996    
3997            /**
3998             * Returns the last journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
3999             *
4000             * <p>
4001             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4002             * </p>
4003             *
4004             * @param resourcePrimKey the resource prim key
4005             * @param status the status
4006             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4007             * @return the last matching journal article
4008             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4009             * @throws SystemException if a system exception occurred
4010             */
4011            public JournalArticle findByR_ST_Last(long resourcePrimKey, int status,
4012                    OrderByComparator orderByComparator)
4013                    throws NoSuchArticleException, SystemException {
4014                    int count = countByR_ST(resourcePrimKey, status);
4015    
4016                    List<JournalArticle> list = findByR_ST(resourcePrimKey, status,
4017                                    count - 1, count, orderByComparator);
4018    
4019                    if (list.isEmpty()) {
4020                            StringBundler msg = new StringBundler(6);
4021    
4022                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4023    
4024                            msg.append("resourcePrimKey=");
4025                            msg.append(resourcePrimKey);
4026    
4027                            msg.append(", status=");
4028                            msg.append(status);
4029    
4030                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4031    
4032                            throw new NoSuchArticleException(msg.toString());
4033                    }
4034                    else {
4035                            return list.get(0);
4036                    }
4037            }
4038    
4039            /**
4040             * Returns the journal articles before and after the current journal article in the ordered set where resourcePrimKey = &#63; and status = &#63;.
4041             *
4042             * <p>
4043             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4044             * </p>
4045             *
4046             * @param id the primary key of the current journal article
4047             * @param resourcePrimKey the resource prim key
4048             * @param status the status
4049             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4050             * @return the previous, current, and next journal article
4051             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4052             * @throws SystemException if a system exception occurred
4053             */
4054            public JournalArticle[] findByR_ST_PrevAndNext(long id,
4055                    long resourcePrimKey, int status, OrderByComparator orderByComparator)
4056                    throws NoSuchArticleException, SystemException {
4057                    JournalArticle journalArticle = findByPrimaryKey(id);
4058    
4059                    Session session = null;
4060    
4061                    try {
4062                            session = openSession();
4063    
4064                            JournalArticle[] array = new JournalArticleImpl[3];
4065    
4066                            array[0] = getByR_ST_PrevAndNext(session, journalArticle,
4067                                            resourcePrimKey, status, orderByComparator, true);
4068    
4069                            array[1] = journalArticle;
4070    
4071                            array[2] = getByR_ST_PrevAndNext(session, journalArticle,
4072                                            resourcePrimKey, status, orderByComparator, false);
4073    
4074                            return array;
4075                    }
4076                    catch (Exception e) {
4077                            throw processException(e);
4078                    }
4079                    finally {
4080                            closeSession(session);
4081                    }
4082            }
4083    
4084            protected JournalArticle getByR_ST_PrevAndNext(Session session,
4085                    JournalArticle journalArticle, long resourcePrimKey, int status,
4086                    OrderByComparator orderByComparator, boolean previous) {
4087                    StringBundler query = null;
4088    
4089                    if (orderByComparator != null) {
4090                            query = new StringBundler(6 +
4091                                            (orderByComparator.getOrderByFields().length * 6));
4092                    }
4093                    else {
4094                            query = new StringBundler(3);
4095                    }
4096    
4097                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4098    
4099                    query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
4100    
4101                    query.append(_FINDER_COLUMN_R_ST_STATUS_2);
4102    
4103                    if (orderByComparator != null) {
4104                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4105    
4106                            if (orderByConditionFields.length > 0) {
4107                                    query.append(WHERE_AND);
4108                            }
4109    
4110                            for (int i = 0; i < orderByConditionFields.length; i++) {
4111                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4112                                    query.append(orderByConditionFields[i]);
4113    
4114                                    if ((i + 1) < orderByConditionFields.length) {
4115                                            if (orderByComparator.isAscending() ^ previous) {
4116                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4117                                            }
4118                                            else {
4119                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4120                                            }
4121                                    }
4122                                    else {
4123                                            if (orderByComparator.isAscending() ^ previous) {
4124                                                    query.append(WHERE_GREATER_THAN);
4125                                            }
4126                                            else {
4127                                                    query.append(WHERE_LESSER_THAN);
4128                                            }
4129                                    }
4130                            }
4131    
4132                            query.append(ORDER_BY_CLAUSE);
4133    
4134                            String[] orderByFields = orderByComparator.getOrderByFields();
4135    
4136                            for (int i = 0; i < orderByFields.length; i++) {
4137                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4138                                    query.append(orderByFields[i]);
4139    
4140                                    if ((i + 1) < orderByFields.length) {
4141                                            if (orderByComparator.isAscending() ^ previous) {
4142                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4143                                            }
4144                                            else {
4145                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4146                                            }
4147                                    }
4148                                    else {
4149                                            if (orderByComparator.isAscending() ^ previous) {
4150                                                    query.append(ORDER_BY_ASC);
4151                                            }
4152                                            else {
4153                                                    query.append(ORDER_BY_DESC);
4154                                            }
4155                                    }
4156                            }
4157                    }
4158    
4159                    else {
4160                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4161                    }
4162    
4163                    String sql = query.toString();
4164    
4165                    Query q = session.createQuery(sql);
4166    
4167                    q.setFirstResult(0);
4168                    q.setMaxResults(2);
4169    
4170                    QueryPos qPos = QueryPos.getInstance(q);
4171    
4172                    qPos.add(resourcePrimKey);
4173    
4174                    qPos.add(status);
4175    
4176                    if (orderByComparator != null) {
4177                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4178    
4179                            for (Object value : values) {
4180                                    qPos.add(value);
4181                            }
4182                    }
4183    
4184                    List<JournalArticle> list = q.list();
4185    
4186                    if (list.size() == 2) {
4187                            return list.get(1);
4188                    }
4189                    else {
4190                            return null;
4191                    }
4192            }
4193    
4194            /**
4195             * Returns all the journal articles where groupId = &#63; and articleId = &#63;.
4196             *
4197             * @param groupId the group ID
4198             * @param articleId the article ID
4199             * @return the matching journal articles
4200             * @throws SystemException if a system exception occurred
4201             */
4202            public List<JournalArticle> findByG_A(long groupId, String articleId)
4203                    throws SystemException {
4204                    return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
4205                            QueryUtil.ALL_POS, null);
4206            }
4207    
4208            /**
4209             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63;.
4210             *
4211             * <p>
4212             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4213             * </p>
4214             *
4215             * @param groupId the group ID
4216             * @param articleId the article ID
4217             * @param start the lower bound of the range of journal articles
4218             * @param end the upper bound of the range of journal articles (not inclusive)
4219             * @return the range of matching journal articles
4220             * @throws SystemException if a system exception occurred
4221             */
4222            public List<JournalArticle> findByG_A(long groupId, String articleId,
4223                    int start, int end) throws SystemException {
4224                    return findByG_A(groupId, articleId, start, end, null);
4225            }
4226    
4227            /**
4228             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63;.
4229             *
4230             * <p>
4231             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4232             * </p>
4233             *
4234             * @param groupId the group ID
4235             * @param articleId the article ID
4236             * @param start the lower bound of the range of journal articles
4237             * @param end the upper bound of the range of journal articles (not inclusive)
4238             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4239             * @return the ordered range of matching journal articles
4240             * @throws SystemException if a system exception occurred
4241             */
4242            public List<JournalArticle> findByG_A(long groupId, String articleId,
4243                    int start, int end, OrderByComparator orderByComparator)
4244                    throws SystemException {
4245                    FinderPath finderPath = null;
4246                    Object[] finderArgs = null;
4247    
4248                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4249                                    (orderByComparator == null)) {
4250                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A;
4251                            finderArgs = new Object[] { groupId, articleId };
4252                    }
4253                    else {
4254                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A;
4255                            finderArgs = new Object[] {
4256                                            groupId, articleId,
4257                                            
4258                                            start, end, orderByComparator
4259                                    };
4260                    }
4261    
4262                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
4263                                    finderArgs, this);
4264    
4265                    if (list == null) {
4266                            StringBundler query = null;
4267    
4268                            if (orderByComparator != null) {
4269                                    query = new StringBundler(4 +
4270                                                    (orderByComparator.getOrderByFields().length * 3));
4271                            }
4272                            else {
4273                                    query = new StringBundler(4);
4274                            }
4275    
4276                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4277    
4278                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4279    
4280                            if (articleId == null) {
4281                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4282                            }
4283                            else {
4284                                    if (articleId.equals(StringPool.BLANK)) {
4285                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4286                                    }
4287                                    else {
4288                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4289                                    }
4290                            }
4291    
4292                            if (orderByComparator != null) {
4293                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4294                                            orderByComparator);
4295                            }
4296    
4297                            else {
4298                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4299                            }
4300    
4301                            String sql = query.toString();
4302    
4303                            Session session = null;
4304    
4305                            try {
4306                                    session = openSession();
4307    
4308                                    Query q = session.createQuery(sql);
4309    
4310                                    QueryPos qPos = QueryPos.getInstance(q);
4311    
4312                                    qPos.add(groupId);
4313    
4314                                    if (articleId != null) {
4315                                            qPos.add(articleId);
4316                                    }
4317    
4318                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
4319                                                    start, end);
4320                            }
4321                            catch (Exception e) {
4322                                    throw processException(e);
4323                            }
4324                            finally {
4325                                    if (list == null) {
4326                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4327                                    }
4328                                    else {
4329                                            cacheResult(list);
4330    
4331                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4332                                    }
4333    
4334                                    closeSession(session);
4335                            }
4336                    }
4337    
4338                    return list;
4339            }
4340    
4341            /**
4342             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63;.
4343             *
4344             * <p>
4345             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4346             * </p>
4347             *
4348             * @param groupId the group ID
4349             * @param articleId the article ID
4350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4351             * @return the first matching journal article
4352             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4353             * @throws SystemException if a system exception occurred
4354             */
4355            public JournalArticle findByG_A_First(long groupId, String articleId,
4356                    OrderByComparator orderByComparator)
4357                    throws NoSuchArticleException, SystemException {
4358                    List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1,
4359                                    orderByComparator);
4360    
4361                    if (list.isEmpty()) {
4362                            StringBundler msg = new StringBundler(6);
4363    
4364                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4365    
4366                            msg.append("groupId=");
4367                            msg.append(groupId);
4368    
4369                            msg.append(", articleId=");
4370                            msg.append(articleId);
4371    
4372                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4373    
4374                            throw new NoSuchArticleException(msg.toString());
4375                    }
4376                    else {
4377                            return list.get(0);
4378                    }
4379            }
4380    
4381            /**
4382             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63;.
4383             *
4384             * <p>
4385             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4386             * </p>
4387             *
4388             * @param groupId the group ID
4389             * @param articleId the article ID
4390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4391             * @return the last matching journal article
4392             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
4393             * @throws SystemException if a system exception occurred
4394             */
4395            public JournalArticle findByG_A_Last(long groupId, String articleId,
4396                    OrderByComparator orderByComparator)
4397                    throws NoSuchArticleException, SystemException {
4398                    int count = countByG_A(groupId, articleId);
4399    
4400                    List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
4401                                    count, orderByComparator);
4402    
4403                    if (list.isEmpty()) {
4404                            StringBundler msg = new StringBundler(6);
4405    
4406                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4407    
4408                            msg.append("groupId=");
4409                            msg.append(groupId);
4410    
4411                            msg.append(", articleId=");
4412                            msg.append(articleId);
4413    
4414                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4415    
4416                            throw new NoSuchArticleException(msg.toString());
4417                    }
4418                    else {
4419                            return list.get(0);
4420                    }
4421            }
4422    
4423            /**
4424             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63;.
4425             *
4426             * <p>
4427             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4428             * </p>
4429             *
4430             * @param id the primary key of the current journal article
4431             * @param groupId the group ID
4432             * @param articleId the article ID
4433             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4434             * @return the previous, current, and next journal article
4435             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4436             * @throws SystemException if a system exception occurred
4437             */
4438            public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
4439                    String articleId, OrderByComparator orderByComparator)
4440                    throws NoSuchArticleException, SystemException {
4441                    JournalArticle journalArticle = findByPrimaryKey(id);
4442    
4443                    Session session = null;
4444    
4445                    try {
4446                            session = openSession();
4447    
4448                            JournalArticle[] array = new JournalArticleImpl[3];
4449    
4450                            array[0] = getByG_A_PrevAndNext(session, journalArticle, groupId,
4451                                            articleId, orderByComparator, true);
4452    
4453                            array[1] = journalArticle;
4454    
4455                            array[2] = getByG_A_PrevAndNext(session, journalArticle, groupId,
4456                                            articleId, orderByComparator, false);
4457    
4458                            return array;
4459                    }
4460                    catch (Exception e) {
4461                            throw processException(e);
4462                    }
4463                    finally {
4464                            closeSession(session);
4465                    }
4466            }
4467    
4468            protected JournalArticle getByG_A_PrevAndNext(Session session,
4469                    JournalArticle journalArticle, long groupId, String articleId,
4470                    OrderByComparator orderByComparator, boolean previous) {
4471                    StringBundler query = null;
4472    
4473                    if (orderByComparator != null) {
4474                            query = new StringBundler(6 +
4475                                            (orderByComparator.getOrderByFields().length * 6));
4476                    }
4477                    else {
4478                            query = new StringBundler(3);
4479                    }
4480    
4481                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
4482    
4483                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4484    
4485                    if (articleId == null) {
4486                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4487                    }
4488                    else {
4489                            if (articleId.equals(StringPool.BLANK)) {
4490                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4491                            }
4492                            else {
4493                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4494                            }
4495                    }
4496    
4497                    if (orderByComparator != null) {
4498                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4499    
4500                            if (orderByConditionFields.length > 0) {
4501                                    query.append(WHERE_AND);
4502                            }
4503    
4504                            for (int i = 0; i < orderByConditionFields.length; i++) {
4505                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4506                                    query.append(orderByConditionFields[i]);
4507    
4508                                    if ((i + 1) < orderByConditionFields.length) {
4509                                            if (orderByComparator.isAscending() ^ previous) {
4510                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4511                                            }
4512                                            else {
4513                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4514                                            }
4515                                    }
4516                                    else {
4517                                            if (orderByComparator.isAscending() ^ previous) {
4518                                                    query.append(WHERE_GREATER_THAN);
4519                                            }
4520                                            else {
4521                                                    query.append(WHERE_LESSER_THAN);
4522                                            }
4523                                    }
4524                            }
4525    
4526                            query.append(ORDER_BY_CLAUSE);
4527    
4528                            String[] orderByFields = orderByComparator.getOrderByFields();
4529    
4530                            for (int i = 0; i < orderByFields.length; i++) {
4531                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4532                                    query.append(orderByFields[i]);
4533    
4534                                    if ((i + 1) < orderByFields.length) {
4535                                            if (orderByComparator.isAscending() ^ previous) {
4536                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4537                                            }
4538                                            else {
4539                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4540                                            }
4541                                    }
4542                                    else {
4543                                            if (orderByComparator.isAscending() ^ previous) {
4544                                                    query.append(ORDER_BY_ASC);
4545                                            }
4546                                            else {
4547                                                    query.append(ORDER_BY_DESC);
4548                                            }
4549                                    }
4550                            }
4551                    }
4552    
4553                    else {
4554                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4555                    }
4556    
4557                    String sql = query.toString();
4558    
4559                    Query q = session.createQuery(sql);
4560    
4561                    q.setFirstResult(0);
4562                    q.setMaxResults(2);
4563    
4564                    QueryPos qPos = QueryPos.getInstance(q);
4565    
4566                    qPos.add(groupId);
4567    
4568                    if (articleId != null) {
4569                            qPos.add(articleId);
4570                    }
4571    
4572                    if (orderByComparator != null) {
4573                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4574    
4575                            for (Object value : values) {
4576                                    qPos.add(value);
4577                            }
4578                    }
4579    
4580                    List<JournalArticle> list = q.list();
4581    
4582                    if (list.size() == 2) {
4583                            return list.get(1);
4584                    }
4585                    else {
4586                            return null;
4587                    }
4588            }
4589    
4590            /**
4591             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
4592             *
4593             * @param groupId the group ID
4594             * @param articleId the article ID
4595             * @return the matching journal articles that the user has permission to view
4596             * @throws SystemException if a system exception occurred
4597             */
4598            public List<JournalArticle> filterFindByG_A(long groupId, String articleId)
4599                    throws SystemException {
4600                    return filterFindByG_A(groupId, articleId, QueryUtil.ALL_POS,
4601                            QueryUtil.ALL_POS, null);
4602            }
4603    
4604            /**
4605             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
4606             *
4607             * <p>
4608             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4609             * </p>
4610             *
4611             * @param groupId the group ID
4612             * @param articleId the article ID
4613             * @param start the lower bound of the range of journal articles
4614             * @param end the upper bound of the range of journal articles (not inclusive)
4615             * @return the range of matching journal articles that the user has permission to view
4616             * @throws SystemException if a system exception occurred
4617             */
4618            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
4619                    int start, int end) throws SystemException {
4620                    return filterFindByG_A(groupId, articleId, start, end, null);
4621            }
4622    
4623            /**
4624             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and articleId = &#63;.
4625             *
4626             * <p>
4627             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4628             * </p>
4629             *
4630             * @param groupId the group ID
4631             * @param articleId the article ID
4632             * @param start the lower bound of the range of journal articles
4633             * @param end the upper bound of the range of journal articles (not inclusive)
4634             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4635             * @return the ordered range of matching journal articles that the user has permission to view
4636             * @throws SystemException if a system exception occurred
4637             */
4638            public List<JournalArticle> filterFindByG_A(long groupId, String articleId,
4639                    int start, int end, OrderByComparator orderByComparator)
4640                    throws SystemException {
4641                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4642                            return findByG_A(groupId, articleId, start, end, orderByComparator);
4643                    }
4644    
4645                    StringBundler query = null;
4646    
4647                    if (orderByComparator != null) {
4648                            query = new StringBundler(4 +
4649                                            (orderByComparator.getOrderByFields().length * 3));
4650                    }
4651                    else {
4652                            query = new StringBundler(4);
4653                    }
4654    
4655                    if (getDB().isSupportsInlineDistinct()) {
4656                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
4657                    }
4658                    else {
4659                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
4660                    }
4661    
4662                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4663    
4664                    if (articleId == null) {
4665                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4666                    }
4667                    else {
4668                            if (articleId.equals(StringPool.BLANK)) {
4669                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4670                            }
4671                            else {
4672                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4673                            }
4674                    }
4675    
4676                    if (!getDB().isSupportsInlineDistinct()) {
4677                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
4678                    }
4679    
4680                    if (orderByComparator != null) {
4681                            if (getDB().isSupportsInlineDistinct()) {
4682                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4683                                            orderByComparator);
4684                            }
4685                            else {
4686                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4687                                            orderByComparator);
4688                            }
4689                    }
4690    
4691                    else {
4692                            if (getDB().isSupportsInlineDistinct()) {
4693                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4694                            }
4695                            else {
4696                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
4697                            }
4698                    }
4699    
4700                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4701                                    JournalArticle.class.getName(),
4702                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4703    
4704                    Session session = null;
4705    
4706                    try {
4707                            session = openSession();
4708    
4709                            SQLQuery q = session.createSQLQuery(sql);
4710    
4711                            if (getDB().isSupportsInlineDistinct()) {
4712                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
4713                            }
4714                            else {
4715                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
4716                            }
4717    
4718                            QueryPos qPos = QueryPos.getInstance(q);
4719    
4720                            qPos.add(groupId);
4721    
4722                            if (articleId != null) {
4723                                    qPos.add(articleId);
4724                            }
4725    
4726                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
4727                                    end);
4728                    }
4729                    catch (Exception e) {
4730                            throw processException(e);
4731                    }
4732                    finally {
4733                            closeSession(session);
4734                    }
4735            }
4736    
4737            /**
4738             * 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;.
4739             *
4740             * @param id the primary key of the current journal article
4741             * @param groupId the group ID
4742             * @param articleId the article ID
4743             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4744             * @return the previous, current, and next journal article
4745             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
4746             * @throws SystemException if a system exception occurred
4747             */
4748            public JournalArticle[] filterFindByG_A_PrevAndNext(long id, long groupId,
4749                    String articleId, OrderByComparator orderByComparator)
4750                    throws NoSuchArticleException, SystemException {
4751                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4752                            return findByG_A_PrevAndNext(id, groupId, articleId,
4753                                    orderByComparator);
4754                    }
4755    
4756                    JournalArticle journalArticle = findByPrimaryKey(id);
4757    
4758                    Session session = null;
4759    
4760                    try {
4761                            session = openSession();
4762    
4763                            JournalArticle[] array = new JournalArticleImpl[3];
4764    
4765                            array[0] = filterGetByG_A_PrevAndNext(session, journalArticle,
4766                                            groupId, articleId, orderByComparator, true);
4767    
4768                            array[1] = journalArticle;
4769    
4770                            array[2] = filterGetByG_A_PrevAndNext(session, journalArticle,
4771                                            groupId, articleId, orderByComparator, false);
4772    
4773                            return array;
4774                    }
4775                    catch (Exception e) {
4776                            throw processException(e);
4777                    }
4778                    finally {
4779                            closeSession(session);
4780                    }
4781            }
4782    
4783            protected JournalArticle filterGetByG_A_PrevAndNext(Session session,
4784                    JournalArticle journalArticle, long groupId, String articleId,
4785                    OrderByComparator orderByComparator, boolean previous) {
4786                    StringBundler query = null;
4787    
4788                    if (orderByComparator != null) {
4789                            query = new StringBundler(6 +
4790                                            (orderByComparator.getOrderByFields().length * 6));
4791                    }
4792                    else {
4793                            query = new StringBundler(3);
4794                    }
4795    
4796                    if (getDB().isSupportsInlineDistinct()) {
4797                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
4798                    }
4799                    else {
4800                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
4801                    }
4802    
4803                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
4804    
4805                    if (articleId == null) {
4806                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
4807                    }
4808                    else {
4809                            if (articleId.equals(StringPool.BLANK)) {
4810                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
4811                            }
4812                            else {
4813                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
4814                            }
4815                    }
4816    
4817                    if (!getDB().isSupportsInlineDistinct()) {
4818                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
4819                    }
4820    
4821                    if (orderByComparator != null) {
4822                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4823    
4824                            if (orderByConditionFields.length > 0) {
4825                                    query.append(WHERE_AND);
4826                            }
4827    
4828                            for (int i = 0; i < orderByConditionFields.length; i++) {
4829                                    if (getDB().isSupportsInlineDistinct()) {
4830                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4831                                    }
4832                                    else {
4833                                            query.append(_ORDER_BY_ENTITY_TABLE);
4834                                    }
4835    
4836                                    query.append(orderByConditionFields[i]);
4837    
4838                                    if ((i + 1) < orderByConditionFields.length) {
4839                                            if (orderByComparator.isAscending() ^ previous) {
4840                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4841                                            }
4842                                            else {
4843                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4844                                            }
4845                                    }
4846                                    else {
4847                                            if (orderByComparator.isAscending() ^ previous) {
4848                                                    query.append(WHERE_GREATER_THAN);
4849                                            }
4850                                            else {
4851                                                    query.append(WHERE_LESSER_THAN);
4852                                            }
4853                                    }
4854                            }
4855    
4856                            query.append(ORDER_BY_CLAUSE);
4857    
4858                            String[] orderByFields = orderByComparator.getOrderByFields();
4859    
4860                            for (int i = 0; i < orderByFields.length; i++) {
4861                                    if (getDB().isSupportsInlineDistinct()) {
4862                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4863                                    }
4864                                    else {
4865                                            query.append(_ORDER_BY_ENTITY_TABLE);
4866                                    }
4867    
4868                                    query.append(orderByFields[i]);
4869    
4870                                    if ((i + 1) < orderByFields.length) {
4871                                            if (orderByComparator.isAscending() ^ previous) {
4872                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4873                                            }
4874                                            else {
4875                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4876                                            }
4877                                    }
4878                                    else {
4879                                            if (orderByComparator.isAscending() ^ previous) {
4880                                                    query.append(ORDER_BY_ASC);
4881                                            }
4882                                            else {
4883                                                    query.append(ORDER_BY_DESC);
4884                                            }
4885                                    }
4886                            }
4887                    }
4888    
4889                    else {
4890                            if (getDB().isSupportsInlineDistinct()) {
4891                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
4892                            }
4893                            else {
4894                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
4895                            }
4896                    }
4897    
4898                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4899                                    JournalArticle.class.getName(),
4900                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4901    
4902                    SQLQuery q = session.createSQLQuery(sql);
4903    
4904                    q.setFirstResult(0);
4905                    q.setMaxResults(2);
4906    
4907                    if (getDB().isSupportsInlineDistinct()) {
4908                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
4909                    }
4910                    else {
4911                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
4912                    }
4913    
4914                    QueryPos qPos = QueryPos.getInstance(q);
4915    
4916                    qPos.add(groupId);
4917    
4918                    if (articleId != null) {
4919                            qPos.add(articleId);
4920                    }
4921    
4922                    if (orderByComparator != null) {
4923                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
4924    
4925                            for (Object value : values) {
4926                                    qPos.add(value);
4927                            }
4928                    }
4929    
4930                    List<JournalArticle> list = q.list();
4931    
4932                    if (list.size() == 2) {
4933                            return list.get(1);
4934                    }
4935                    else {
4936                            return null;
4937                    }
4938            }
4939    
4940            /**
4941             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63;.
4942             *
4943             * @param groupId the group ID
4944             * @param urlTitle the url title
4945             * @return the matching journal articles
4946             * @throws SystemException if a system exception occurred
4947             */
4948            public List<JournalArticle> findByG_UT(long groupId, String urlTitle)
4949                    throws SystemException {
4950                    return findByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
4951                            QueryUtil.ALL_POS, null);
4952            }
4953    
4954            /**
4955             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
4956             *
4957             * <p>
4958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4959             * </p>
4960             *
4961             * @param groupId the group ID
4962             * @param urlTitle the url title
4963             * @param start the lower bound of the range of journal articles
4964             * @param end the upper bound of the range of journal articles (not inclusive)
4965             * @return the range of matching journal articles
4966             * @throws SystemException if a system exception occurred
4967             */
4968            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
4969                    int start, int end) throws SystemException {
4970                    return findByG_UT(groupId, urlTitle, start, end, null);
4971            }
4972    
4973            /**
4974             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63;.
4975             *
4976             * <p>
4977             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4978             * </p>
4979             *
4980             * @param groupId the group ID
4981             * @param urlTitle the url title
4982             * @param start the lower bound of the range of journal articles
4983             * @param end the upper bound of the range of journal articles (not inclusive)
4984             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4985             * @return the ordered range of matching journal articles
4986             * @throws SystemException if a system exception occurred
4987             */
4988            public List<JournalArticle> findByG_UT(long groupId, String urlTitle,
4989                    int start, int end, OrderByComparator orderByComparator)
4990                    throws SystemException {
4991                    FinderPath finderPath = null;
4992                    Object[] finderArgs = null;
4993    
4994                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4995                                    (orderByComparator == null)) {
4996                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT;
4997                            finderArgs = new Object[] { groupId, urlTitle };
4998                    }
4999                    else {
5000                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT;
5001                            finderArgs = new Object[] {
5002                                            groupId, urlTitle,
5003                                            
5004                                            start, end, orderByComparator
5005                                    };
5006                    }
5007    
5008                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5009                                    finderArgs, this);
5010    
5011                    if (list == null) {
5012                            StringBundler query = null;
5013    
5014                            if (orderByComparator != null) {
5015                                    query = new StringBundler(4 +
5016                                                    (orderByComparator.getOrderByFields().length * 3));
5017                            }
5018                            else {
5019                                    query = new StringBundler(4);
5020                            }
5021    
5022                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5023    
5024                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5025    
5026                            if (urlTitle == null) {
5027                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5028                            }
5029                            else {
5030                                    if (urlTitle.equals(StringPool.BLANK)) {
5031                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5032                                    }
5033                                    else {
5034                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5035                                    }
5036                            }
5037    
5038                            if (orderByComparator != null) {
5039                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5040                                            orderByComparator);
5041                            }
5042    
5043                            else {
5044                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5045                            }
5046    
5047                            String sql = query.toString();
5048    
5049                            Session session = null;
5050    
5051                            try {
5052                                    session = openSession();
5053    
5054                                    Query q = session.createQuery(sql);
5055    
5056                                    QueryPos qPos = QueryPos.getInstance(q);
5057    
5058                                    qPos.add(groupId);
5059    
5060                                    if (urlTitle != null) {
5061                                            qPos.add(urlTitle);
5062                                    }
5063    
5064                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5065                                                    start, end);
5066                            }
5067                            catch (Exception e) {
5068                                    throw processException(e);
5069                            }
5070                            finally {
5071                                    if (list == null) {
5072                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5073                                    }
5074                                    else {
5075                                            cacheResult(list);
5076    
5077                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5078                                    }
5079    
5080                                    closeSession(session);
5081                            }
5082                    }
5083    
5084                    return list;
5085            }
5086    
5087            /**
5088             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
5089             *
5090             * <p>
5091             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5092             * </p>
5093             *
5094             * @param groupId the group ID
5095             * @param urlTitle the url title
5096             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5097             * @return the first matching journal article
5098             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5099             * @throws SystemException if a system exception occurred
5100             */
5101            public JournalArticle findByG_UT_First(long groupId, String urlTitle,
5102                    OrderByComparator orderByComparator)
5103                    throws NoSuchArticleException, SystemException {
5104                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, 0, 1,
5105                                    orderByComparator);
5106    
5107                    if (list.isEmpty()) {
5108                            StringBundler msg = new StringBundler(6);
5109    
5110                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5111    
5112                            msg.append("groupId=");
5113                            msg.append(groupId);
5114    
5115                            msg.append(", urlTitle=");
5116                            msg.append(urlTitle);
5117    
5118                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5119    
5120                            throw new NoSuchArticleException(msg.toString());
5121                    }
5122                    else {
5123                            return list.get(0);
5124                    }
5125            }
5126    
5127            /**
5128             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
5129             *
5130             * <p>
5131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5132             * </p>
5133             *
5134             * @param groupId the group ID
5135             * @param urlTitle the url title
5136             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5137             * @return the last matching journal article
5138             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5139             * @throws SystemException if a system exception occurred
5140             */
5141            public JournalArticle findByG_UT_Last(long groupId, String urlTitle,
5142                    OrderByComparator orderByComparator)
5143                    throws NoSuchArticleException, SystemException {
5144                    int count = countByG_UT(groupId, urlTitle);
5145    
5146                    List<JournalArticle> list = findByG_UT(groupId, urlTitle, count - 1,
5147                                    count, orderByComparator);
5148    
5149                    if (list.isEmpty()) {
5150                            StringBundler msg = new StringBundler(6);
5151    
5152                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5153    
5154                            msg.append("groupId=");
5155                            msg.append(groupId);
5156    
5157                            msg.append(", urlTitle=");
5158                            msg.append(urlTitle);
5159    
5160                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5161    
5162                            throw new NoSuchArticleException(msg.toString());
5163                    }
5164                    else {
5165                            return list.get(0);
5166                    }
5167            }
5168    
5169            /**
5170             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63;.
5171             *
5172             * <p>
5173             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5174             * </p>
5175             *
5176             * @param id the primary key of the current journal article
5177             * @param groupId the group ID
5178             * @param urlTitle the url title
5179             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5180             * @return the previous, current, and next journal article
5181             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5182             * @throws SystemException if a system exception occurred
5183             */
5184            public JournalArticle[] findByG_UT_PrevAndNext(long id, long groupId,
5185                    String urlTitle, OrderByComparator orderByComparator)
5186                    throws NoSuchArticleException, SystemException {
5187                    JournalArticle journalArticle = findByPrimaryKey(id);
5188    
5189                    Session session = null;
5190    
5191                    try {
5192                            session = openSession();
5193    
5194                            JournalArticle[] array = new JournalArticleImpl[3];
5195    
5196                            array[0] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
5197                                            urlTitle, orderByComparator, true);
5198    
5199                            array[1] = journalArticle;
5200    
5201                            array[2] = getByG_UT_PrevAndNext(session, journalArticle, groupId,
5202                                            urlTitle, orderByComparator, false);
5203    
5204                            return array;
5205                    }
5206                    catch (Exception e) {
5207                            throw processException(e);
5208                    }
5209                    finally {
5210                            closeSession(session);
5211                    }
5212            }
5213    
5214            protected JournalArticle getByG_UT_PrevAndNext(Session session,
5215                    JournalArticle journalArticle, long groupId, String urlTitle,
5216                    OrderByComparator orderByComparator, boolean previous) {
5217                    StringBundler query = null;
5218    
5219                    if (orderByComparator != null) {
5220                            query = new StringBundler(6 +
5221                                            (orderByComparator.getOrderByFields().length * 6));
5222                    }
5223                    else {
5224                            query = new StringBundler(3);
5225                    }
5226    
5227                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5228    
5229                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5230    
5231                    if (urlTitle == null) {
5232                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5233                    }
5234                    else {
5235                            if (urlTitle.equals(StringPool.BLANK)) {
5236                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5237                            }
5238                            else {
5239                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5240                            }
5241                    }
5242    
5243                    if (orderByComparator != null) {
5244                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5245    
5246                            if (orderByConditionFields.length > 0) {
5247                                    query.append(WHERE_AND);
5248                            }
5249    
5250                            for (int i = 0; i < orderByConditionFields.length; i++) {
5251                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5252                                    query.append(orderByConditionFields[i]);
5253    
5254                                    if ((i + 1) < orderByConditionFields.length) {
5255                                            if (orderByComparator.isAscending() ^ previous) {
5256                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5257                                            }
5258                                            else {
5259                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5260                                            }
5261                                    }
5262                                    else {
5263                                            if (orderByComparator.isAscending() ^ previous) {
5264                                                    query.append(WHERE_GREATER_THAN);
5265                                            }
5266                                            else {
5267                                                    query.append(WHERE_LESSER_THAN);
5268                                            }
5269                                    }
5270                            }
5271    
5272                            query.append(ORDER_BY_CLAUSE);
5273    
5274                            String[] orderByFields = orderByComparator.getOrderByFields();
5275    
5276                            for (int i = 0; i < orderByFields.length; i++) {
5277                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5278                                    query.append(orderByFields[i]);
5279    
5280                                    if ((i + 1) < orderByFields.length) {
5281                                            if (orderByComparator.isAscending() ^ previous) {
5282                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5283                                            }
5284                                            else {
5285                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5286                                            }
5287                                    }
5288                                    else {
5289                                            if (orderByComparator.isAscending() ^ previous) {
5290                                                    query.append(ORDER_BY_ASC);
5291                                            }
5292                                            else {
5293                                                    query.append(ORDER_BY_DESC);
5294                                            }
5295                                    }
5296                            }
5297                    }
5298    
5299                    else {
5300                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5301                    }
5302    
5303                    String sql = query.toString();
5304    
5305                    Query q = session.createQuery(sql);
5306    
5307                    q.setFirstResult(0);
5308                    q.setMaxResults(2);
5309    
5310                    QueryPos qPos = QueryPos.getInstance(q);
5311    
5312                    qPos.add(groupId);
5313    
5314                    if (urlTitle != null) {
5315                            qPos.add(urlTitle);
5316                    }
5317    
5318                    if (orderByComparator != null) {
5319                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5320    
5321                            for (Object value : values) {
5322                                    qPos.add(value);
5323                            }
5324                    }
5325    
5326                    List<JournalArticle> list = q.list();
5327    
5328                    if (list.size() == 2) {
5329                            return list.get(1);
5330                    }
5331                    else {
5332                            return null;
5333                    }
5334            }
5335    
5336            /**
5337             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
5338             *
5339             * @param groupId the group ID
5340             * @param urlTitle the url title
5341             * @return the matching journal articles that the user has permission to view
5342             * @throws SystemException if a system exception occurred
5343             */
5344            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle)
5345                    throws SystemException {
5346                    return filterFindByG_UT(groupId, urlTitle, QueryUtil.ALL_POS,
5347                            QueryUtil.ALL_POS, null);
5348            }
5349    
5350            /**
5351             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
5352             *
5353             * <p>
5354             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5355             * </p>
5356             *
5357             * @param groupId the group ID
5358             * @param urlTitle the url title
5359             * @param start the lower bound of the range of journal articles
5360             * @param end the upper bound of the range of journal articles (not inclusive)
5361             * @return the range of matching journal articles that the user has permission to view
5362             * @throws SystemException if a system exception occurred
5363             */
5364            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
5365                    int start, int end) throws SystemException {
5366                    return filterFindByG_UT(groupId, urlTitle, start, end, null);
5367            }
5368    
5369            /**
5370             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and urlTitle = &#63;.
5371             *
5372             * <p>
5373             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5374             * </p>
5375             *
5376             * @param groupId the group ID
5377             * @param urlTitle the url title
5378             * @param start the lower bound of the range of journal articles
5379             * @param end the upper bound of the range of journal articles (not inclusive)
5380             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5381             * @return the ordered range of matching journal articles that the user has permission to view
5382             * @throws SystemException if a system exception occurred
5383             */
5384            public List<JournalArticle> filterFindByG_UT(long groupId, String urlTitle,
5385                    int start, int end, OrderByComparator orderByComparator)
5386                    throws SystemException {
5387                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5388                            return findByG_UT(groupId, urlTitle, start, end, orderByComparator);
5389                    }
5390    
5391                    StringBundler query = null;
5392    
5393                    if (orderByComparator != null) {
5394                            query = new StringBundler(4 +
5395                                            (orderByComparator.getOrderByFields().length * 3));
5396                    }
5397                    else {
5398                            query = new StringBundler(4);
5399                    }
5400    
5401                    if (getDB().isSupportsInlineDistinct()) {
5402                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5403                    }
5404                    else {
5405                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5406                    }
5407    
5408                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5409    
5410                    if (urlTitle == null) {
5411                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5412                    }
5413                    else {
5414                            if (urlTitle.equals(StringPool.BLANK)) {
5415                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5416                            }
5417                            else {
5418                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5419                            }
5420                    }
5421    
5422                    if (!getDB().isSupportsInlineDistinct()) {
5423                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5424                    }
5425    
5426                    if (orderByComparator != null) {
5427                            if (getDB().isSupportsInlineDistinct()) {
5428                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5429                                            orderByComparator);
5430                            }
5431                            else {
5432                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5433                                            orderByComparator);
5434                            }
5435                    }
5436    
5437                    else {
5438                            if (getDB().isSupportsInlineDistinct()) {
5439                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5440                            }
5441                            else {
5442                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
5443                            }
5444                    }
5445    
5446                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5447                                    JournalArticle.class.getName(),
5448                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5449    
5450                    Session session = null;
5451    
5452                    try {
5453                            session = openSession();
5454    
5455                            SQLQuery q = session.createSQLQuery(sql);
5456    
5457                            if (getDB().isSupportsInlineDistinct()) {
5458                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5459                            }
5460                            else {
5461                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
5462                            }
5463    
5464                            QueryPos qPos = QueryPos.getInstance(q);
5465    
5466                            qPos.add(groupId);
5467    
5468                            if (urlTitle != null) {
5469                                    qPos.add(urlTitle);
5470                            }
5471    
5472                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
5473                                    end);
5474                    }
5475                    catch (Exception e) {
5476                            throw processException(e);
5477                    }
5478                    finally {
5479                            closeSession(session);
5480                    }
5481            }
5482    
5483            /**
5484             * 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;.
5485             *
5486             * @param id the primary key of the current journal article
5487             * @param groupId the group ID
5488             * @param urlTitle the url title
5489             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5490             * @return the previous, current, and next journal article
5491             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5492             * @throws SystemException if a system exception occurred
5493             */
5494            public JournalArticle[] filterFindByG_UT_PrevAndNext(long id, long groupId,
5495                    String urlTitle, OrderByComparator orderByComparator)
5496                    throws NoSuchArticleException, SystemException {
5497                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5498                            return findByG_UT_PrevAndNext(id, groupId, urlTitle,
5499                                    orderByComparator);
5500                    }
5501    
5502                    JournalArticle journalArticle = findByPrimaryKey(id);
5503    
5504                    Session session = null;
5505    
5506                    try {
5507                            session = openSession();
5508    
5509                            JournalArticle[] array = new JournalArticleImpl[3];
5510    
5511                            array[0] = filterGetByG_UT_PrevAndNext(session, journalArticle,
5512                                            groupId, urlTitle, orderByComparator, true);
5513    
5514                            array[1] = journalArticle;
5515    
5516                            array[2] = filterGetByG_UT_PrevAndNext(session, journalArticle,
5517                                            groupId, urlTitle, orderByComparator, false);
5518    
5519                            return array;
5520                    }
5521                    catch (Exception e) {
5522                            throw processException(e);
5523                    }
5524                    finally {
5525                            closeSession(session);
5526                    }
5527            }
5528    
5529            protected JournalArticle filterGetByG_UT_PrevAndNext(Session session,
5530                    JournalArticle journalArticle, long groupId, String urlTitle,
5531                    OrderByComparator orderByComparator, boolean previous) {
5532                    StringBundler query = null;
5533    
5534                    if (orderByComparator != null) {
5535                            query = new StringBundler(6 +
5536                                            (orderByComparator.getOrderByFields().length * 6));
5537                    }
5538                    else {
5539                            query = new StringBundler(3);
5540                    }
5541    
5542                    if (getDB().isSupportsInlineDistinct()) {
5543                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
5544                    }
5545                    else {
5546                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
5547                    }
5548    
5549                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5550    
5551                    if (urlTitle == null) {
5552                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5553                    }
5554                    else {
5555                            if (urlTitle.equals(StringPool.BLANK)) {
5556                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5557                            }
5558                            else {
5559                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5560                            }
5561                    }
5562    
5563                    if (!getDB().isSupportsInlineDistinct()) {
5564                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
5565                    }
5566    
5567                    if (orderByComparator != null) {
5568                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5569    
5570                            if (orderByConditionFields.length > 0) {
5571                                    query.append(WHERE_AND);
5572                            }
5573    
5574                            for (int i = 0; i < orderByConditionFields.length; i++) {
5575                                    if (getDB().isSupportsInlineDistinct()) {
5576                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5577                                    }
5578                                    else {
5579                                            query.append(_ORDER_BY_ENTITY_TABLE);
5580                                    }
5581    
5582                                    query.append(orderByConditionFields[i]);
5583    
5584                                    if ((i + 1) < orderByConditionFields.length) {
5585                                            if (orderByComparator.isAscending() ^ previous) {
5586                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5587                                            }
5588                                            else {
5589                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5590                                            }
5591                                    }
5592                                    else {
5593                                            if (orderByComparator.isAscending() ^ previous) {
5594                                                    query.append(WHERE_GREATER_THAN);
5595                                            }
5596                                            else {
5597                                                    query.append(WHERE_LESSER_THAN);
5598                                            }
5599                                    }
5600                            }
5601    
5602                            query.append(ORDER_BY_CLAUSE);
5603    
5604                            String[] orderByFields = orderByComparator.getOrderByFields();
5605    
5606                            for (int i = 0; i < orderByFields.length; i++) {
5607                                    if (getDB().isSupportsInlineDistinct()) {
5608                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5609                                    }
5610                                    else {
5611                                            query.append(_ORDER_BY_ENTITY_TABLE);
5612                                    }
5613    
5614                                    query.append(orderByFields[i]);
5615    
5616                                    if ((i + 1) < orderByFields.length) {
5617                                            if (orderByComparator.isAscending() ^ previous) {
5618                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5619                                            }
5620                                            else {
5621                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5622                                            }
5623                                    }
5624                                    else {
5625                                            if (orderByComparator.isAscending() ^ previous) {
5626                                                    query.append(ORDER_BY_ASC);
5627                                            }
5628                                            else {
5629                                                    query.append(ORDER_BY_DESC);
5630                                            }
5631                                    }
5632                            }
5633                    }
5634    
5635                    else {
5636                            if (getDB().isSupportsInlineDistinct()) {
5637                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5638                            }
5639                            else {
5640                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
5641                            }
5642                    }
5643    
5644                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5645                                    JournalArticle.class.getName(),
5646                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5647    
5648                    SQLQuery q = session.createSQLQuery(sql);
5649    
5650                    q.setFirstResult(0);
5651                    q.setMaxResults(2);
5652    
5653                    if (getDB().isSupportsInlineDistinct()) {
5654                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
5655                    }
5656                    else {
5657                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
5658                    }
5659    
5660                    QueryPos qPos = QueryPos.getInstance(q);
5661    
5662                    qPos.add(groupId);
5663    
5664                    if (urlTitle != null) {
5665                            qPos.add(urlTitle);
5666                    }
5667    
5668                    if (orderByComparator != null) {
5669                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
5670    
5671                            for (Object value : values) {
5672                                    qPos.add(value);
5673                            }
5674                    }
5675    
5676                    List<JournalArticle> list = q.list();
5677    
5678                    if (list.size() == 2) {
5679                            return list.get(1);
5680                    }
5681                    else {
5682                            return null;
5683                    }
5684            }
5685    
5686            /**
5687             * Returns all the journal articles where groupId = &#63; and structureId = &#63;.
5688             *
5689             * @param groupId the group ID
5690             * @param structureId the structure ID
5691             * @return the matching journal articles
5692             * @throws SystemException if a system exception occurred
5693             */
5694            public List<JournalArticle> findByG_S(long groupId, String structureId)
5695                    throws SystemException {
5696                    return findByG_S(groupId, structureId, QueryUtil.ALL_POS,
5697                            QueryUtil.ALL_POS, null);
5698            }
5699    
5700            /**
5701             * Returns a range of all the journal articles where groupId = &#63; and structureId = &#63;.
5702             *
5703             * <p>
5704             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5705             * </p>
5706             *
5707             * @param groupId the group ID
5708             * @param structureId the structure ID
5709             * @param start the lower bound of the range of journal articles
5710             * @param end the upper bound of the range of journal articles (not inclusive)
5711             * @return the range of matching journal articles
5712             * @throws SystemException if a system exception occurred
5713             */
5714            public List<JournalArticle> findByG_S(long groupId, String structureId,
5715                    int start, int end) throws SystemException {
5716                    return findByG_S(groupId, structureId, start, end, null);
5717            }
5718    
5719            /**
5720             * Returns an ordered range of all the journal articles where groupId = &#63; and structureId = &#63;.
5721             *
5722             * <p>
5723             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5724             * </p>
5725             *
5726             * @param groupId the group ID
5727             * @param structureId the structure ID
5728             * @param start the lower bound of the range of journal articles
5729             * @param end the upper bound of the range of journal articles (not inclusive)
5730             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5731             * @return the ordered range of matching journal articles
5732             * @throws SystemException if a system exception occurred
5733             */
5734            public List<JournalArticle> findByG_S(long groupId, String structureId,
5735                    int start, int end, OrderByComparator orderByComparator)
5736                    throws SystemException {
5737                    FinderPath finderPath = null;
5738                    Object[] finderArgs = null;
5739    
5740                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5741                                    (orderByComparator == null)) {
5742                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
5743                            finderArgs = new Object[] { groupId, structureId };
5744                    }
5745                    else {
5746                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
5747                            finderArgs = new Object[] {
5748                                            groupId, structureId,
5749                                            
5750                                            start, end, orderByComparator
5751                                    };
5752                    }
5753    
5754                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
5755                                    finderArgs, this);
5756    
5757                    if (list == null) {
5758                            StringBundler query = null;
5759    
5760                            if (orderByComparator != null) {
5761                                    query = new StringBundler(4 +
5762                                                    (orderByComparator.getOrderByFields().length * 3));
5763                            }
5764                            else {
5765                                    query = new StringBundler(4);
5766                            }
5767    
5768                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5769    
5770                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5771    
5772                            if (structureId == null) {
5773                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
5774                            }
5775                            else {
5776                                    if (structureId.equals(StringPool.BLANK)) {
5777                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
5778                                    }
5779                                    else {
5780                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
5781                                    }
5782                            }
5783    
5784                            if (orderByComparator != null) {
5785                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5786                                            orderByComparator);
5787                            }
5788    
5789                            else {
5790                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
5791                            }
5792    
5793                            String sql = query.toString();
5794    
5795                            Session session = null;
5796    
5797                            try {
5798                                    session = openSession();
5799    
5800                                    Query q = session.createQuery(sql);
5801    
5802                                    QueryPos qPos = QueryPos.getInstance(q);
5803    
5804                                    qPos.add(groupId);
5805    
5806                                    if (structureId != null) {
5807                                            qPos.add(structureId);
5808                                    }
5809    
5810                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
5811                                                    start, end);
5812                            }
5813                            catch (Exception e) {
5814                                    throw processException(e);
5815                            }
5816                            finally {
5817                                    if (list == null) {
5818                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5819                                    }
5820                                    else {
5821                                            cacheResult(list);
5822    
5823                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5824                                    }
5825    
5826                                    closeSession(session);
5827                            }
5828                    }
5829    
5830                    return list;
5831            }
5832    
5833            /**
5834             * Returns the first journal article in the ordered set where groupId = &#63; and structureId = &#63;.
5835             *
5836             * <p>
5837             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5838             * </p>
5839             *
5840             * @param groupId the group ID
5841             * @param structureId the structure ID
5842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5843             * @return the first matching journal article
5844             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5845             * @throws SystemException if a system exception occurred
5846             */
5847            public JournalArticle findByG_S_First(long groupId, String structureId,
5848                    OrderByComparator orderByComparator)
5849                    throws NoSuchArticleException, SystemException {
5850                    List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1,
5851                                    orderByComparator);
5852    
5853                    if (list.isEmpty()) {
5854                            StringBundler msg = new StringBundler(6);
5855    
5856                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5857    
5858                            msg.append("groupId=");
5859                            msg.append(groupId);
5860    
5861                            msg.append(", structureId=");
5862                            msg.append(structureId);
5863    
5864                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5865    
5866                            throw new NoSuchArticleException(msg.toString());
5867                    }
5868                    else {
5869                            return list.get(0);
5870                    }
5871            }
5872    
5873            /**
5874             * Returns the last journal article in the ordered set where groupId = &#63; and structureId = &#63;.
5875             *
5876             * <p>
5877             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5878             * </p>
5879             *
5880             * @param groupId the group ID
5881             * @param structureId the structure ID
5882             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5883             * @return the last matching journal article
5884             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
5885             * @throws SystemException if a system exception occurred
5886             */
5887            public JournalArticle findByG_S_Last(long groupId, String structureId,
5888                    OrderByComparator orderByComparator)
5889                    throws NoSuchArticleException, SystemException {
5890                    int count = countByG_S(groupId, structureId);
5891    
5892                    List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
5893                                    count, orderByComparator);
5894    
5895                    if (list.isEmpty()) {
5896                            StringBundler msg = new StringBundler(6);
5897    
5898                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5899    
5900                            msg.append("groupId=");
5901                            msg.append(groupId);
5902    
5903                            msg.append(", structureId=");
5904                            msg.append(structureId);
5905    
5906                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5907    
5908                            throw new NoSuchArticleException(msg.toString());
5909                    }
5910                    else {
5911                            return list.get(0);
5912                    }
5913            }
5914    
5915            /**
5916             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and structureId = &#63;.
5917             *
5918             * <p>
5919             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5920             * </p>
5921             *
5922             * @param id the primary key of the current journal article
5923             * @param groupId the group ID
5924             * @param structureId the structure ID
5925             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5926             * @return the previous, current, and next journal article
5927             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
5928             * @throws SystemException if a system exception occurred
5929             */
5930            public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
5931                    String structureId, OrderByComparator orderByComparator)
5932                    throws NoSuchArticleException, SystemException {
5933                    JournalArticle journalArticle = findByPrimaryKey(id);
5934    
5935                    Session session = null;
5936    
5937                    try {
5938                            session = openSession();
5939    
5940                            JournalArticle[] array = new JournalArticleImpl[3];
5941    
5942                            array[0] = getByG_S_PrevAndNext(session, journalArticle, groupId,
5943                                            structureId, orderByComparator, true);
5944    
5945                            array[1] = journalArticle;
5946    
5947                            array[2] = getByG_S_PrevAndNext(session, journalArticle, groupId,
5948                                            structureId, orderByComparator, false);
5949    
5950                            return array;
5951                    }
5952                    catch (Exception e) {
5953                            throw processException(e);
5954                    }
5955                    finally {
5956                            closeSession(session);
5957                    }
5958            }
5959    
5960            protected JournalArticle getByG_S_PrevAndNext(Session session,
5961                    JournalArticle journalArticle, long groupId, String structureId,
5962                    OrderByComparator orderByComparator, boolean previous) {
5963                    StringBundler query = null;
5964    
5965                    if (orderByComparator != null) {
5966                            query = new StringBundler(6 +
5967                                            (orderByComparator.getOrderByFields().length * 6));
5968                    }
5969                    else {
5970                            query = new StringBundler(3);
5971                    }
5972    
5973                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
5974    
5975                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
5976    
5977                    if (structureId == null) {
5978                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
5979                    }
5980                    else {
5981                            if (structureId.equals(StringPool.BLANK)) {
5982                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
5983                            }
5984                            else {
5985                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
5986                            }
5987                    }
5988    
5989                    if (orderByComparator != null) {
5990                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5991    
5992                            if (orderByConditionFields.length > 0) {
5993                                    query.append(WHERE_AND);
5994                            }
5995    
5996                            for (int i = 0; i < orderByConditionFields.length; i++) {
5997                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5998                                    query.append(orderByConditionFields[i]);
5999    
6000                                    if ((i + 1) < orderByConditionFields.length) {
6001                                            if (orderByComparator.isAscending() ^ previous) {
6002                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6003                                            }
6004                                            else {
6005                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6006                                            }
6007                                    }
6008                                    else {
6009                                            if (orderByComparator.isAscending() ^ previous) {
6010                                                    query.append(WHERE_GREATER_THAN);
6011                                            }
6012                                            else {
6013                                                    query.append(WHERE_LESSER_THAN);
6014                                            }
6015                                    }
6016                            }
6017    
6018                            query.append(ORDER_BY_CLAUSE);
6019    
6020                            String[] orderByFields = orderByComparator.getOrderByFields();
6021    
6022                            for (int i = 0; i < orderByFields.length; i++) {
6023                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6024                                    query.append(orderByFields[i]);
6025    
6026                                    if ((i + 1) < orderByFields.length) {
6027                                            if (orderByComparator.isAscending() ^ previous) {
6028                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6029                                            }
6030                                            else {
6031                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6032                                            }
6033                                    }
6034                                    else {
6035                                            if (orderByComparator.isAscending() ^ previous) {
6036                                                    query.append(ORDER_BY_ASC);
6037                                            }
6038                                            else {
6039                                                    query.append(ORDER_BY_DESC);
6040                                            }
6041                                    }
6042                            }
6043                    }
6044    
6045                    else {
6046                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6047                    }
6048    
6049                    String sql = query.toString();
6050    
6051                    Query q = session.createQuery(sql);
6052    
6053                    q.setFirstResult(0);
6054                    q.setMaxResults(2);
6055    
6056                    QueryPos qPos = QueryPos.getInstance(q);
6057    
6058                    qPos.add(groupId);
6059    
6060                    if (structureId != null) {
6061                            qPos.add(structureId);
6062                    }
6063    
6064                    if (orderByComparator != null) {
6065                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6066    
6067                            for (Object value : values) {
6068                                    qPos.add(value);
6069                            }
6070                    }
6071    
6072                    List<JournalArticle> list = q.list();
6073    
6074                    if (list.size() == 2) {
6075                            return list.get(1);
6076                    }
6077                    else {
6078                            return null;
6079                    }
6080            }
6081    
6082            /**
6083             * Returns all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
6084             *
6085             * @param groupId the group ID
6086             * @param structureId the structure ID
6087             * @return the matching journal articles that the user has permission to view
6088             * @throws SystemException if a system exception occurred
6089             */
6090            public List<JournalArticle> filterFindByG_S(long groupId, String structureId)
6091                    throws SystemException {
6092                    return filterFindByG_S(groupId, structureId, QueryUtil.ALL_POS,
6093                            QueryUtil.ALL_POS, null);
6094            }
6095    
6096            /**
6097             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
6098             *
6099             * <p>
6100             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6101             * </p>
6102             *
6103             * @param groupId the group ID
6104             * @param structureId the structure ID
6105             * @param start the lower bound of the range of journal articles
6106             * @param end the upper bound of the range of journal articles (not inclusive)
6107             * @return the range of matching journal articles that the user has permission to view
6108             * @throws SystemException if a system exception occurred
6109             */
6110            public List<JournalArticle> filterFindByG_S(long groupId,
6111                    String structureId, int start, int end) throws SystemException {
6112                    return filterFindByG_S(groupId, structureId, start, end, null);
6113            }
6114    
6115            /**
6116             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and structureId = &#63;.
6117             *
6118             * <p>
6119             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6120             * </p>
6121             *
6122             * @param groupId the group ID
6123             * @param structureId the structure ID
6124             * @param start the lower bound of the range of journal articles
6125             * @param end the upper bound of the range of journal articles (not inclusive)
6126             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6127             * @return the ordered range of matching journal articles that the user has permission to view
6128             * @throws SystemException if a system exception occurred
6129             */
6130            public List<JournalArticle> filterFindByG_S(long groupId,
6131                    String structureId, int start, int end,
6132                    OrderByComparator orderByComparator) throws SystemException {
6133                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6134                            return findByG_S(groupId, structureId, start, end, orderByComparator);
6135                    }
6136    
6137                    StringBundler query = null;
6138    
6139                    if (orderByComparator != null) {
6140                            query = new StringBundler(4 +
6141                                            (orderByComparator.getOrderByFields().length * 3));
6142                    }
6143                    else {
6144                            query = new StringBundler(4);
6145                    }
6146    
6147                    if (getDB().isSupportsInlineDistinct()) {
6148                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6149                    }
6150                    else {
6151                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6152                    }
6153    
6154                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6155    
6156                    if (structureId == null) {
6157                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
6158                    }
6159                    else {
6160                            if (structureId.equals(StringPool.BLANK)) {
6161                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
6162                            }
6163                            else {
6164                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
6165                            }
6166                    }
6167    
6168                    if (!getDB().isSupportsInlineDistinct()) {
6169                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6170                    }
6171    
6172                    if (orderByComparator != null) {
6173                            if (getDB().isSupportsInlineDistinct()) {
6174                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6175                                            orderByComparator);
6176                            }
6177                            else {
6178                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6179                                            orderByComparator);
6180                            }
6181                    }
6182    
6183                    else {
6184                            if (getDB().isSupportsInlineDistinct()) {
6185                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6186                            }
6187                            else {
6188                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6189                            }
6190                    }
6191    
6192                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6193                                    JournalArticle.class.getName(),
6194                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6195    
6196                    Session session = null;
6197    
6198                    try {
6199                            session = openSession();
6200    
6201                            SQLQuery q = session.createSQLQuery(sql);
6202    
6203                            if (getDB().isSupportsInlineDistinct()) {
6204                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6205                            }
6206                            else {
6207                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6208                            }
6209    
6210                            QueryPos qPos = QueryPos.getInstance(q);
6211    
6212                            qPos.add(groupId);
6213    
6214                            if (structureId != null) {
6215                                    qPos.add(structureId);
6216                            }
6217    
6218                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6219                                    end);
6220                    }
6221                    catch (Exception e) {
6222                            throw processException(e);
6223                    }
6224                    finally {
6225                            closeSession(session);
6226                    }
6227            }
6228    
6229            /**
6230             * 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;.
6231             *
6232             * @param id the primary key of the current journal article
6233             * @param groupId the group ID
6234             * @param structureId the structure ID
6235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6236             * @return the previous, current, and next journal article
6237             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6238             * @throws SystemException if a system exception occurred
6239             */
6240            public JournalArticle[] filterFindByG_S_PrevAndNext(long id, long groupId,
6241                    String structureId, OrderByComparator orderByComparator)
6242                    throws NoSuchArticleException, SystemException {
6243                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6244                            return findByG_S_PrevAndNext(id, groupId, structureId,
6245                                    orderByComparator);
6246                    }
6247    
6248                    JournalArticle journalArticle = findByPrimaryKey(id);
6249    
6250                    Session session = null;
6251    
6252                    try {
6253                            session = openSession();
6254    
6255                            JournalArticle[] array = new JournalArticleImpl[3];
6256    
6257                            array[0] = filterGetByG_S_PrevAndNext(session, journalArticle,
6258                                            groupId, structureId, orderByComparator, true);
6259    
6260                            array[1] = journalArticle;
6261    
6262                            array[2] = filterGetByG_S_PrevAndNext(session, journalArticle,
6263                                            groupId, structureId, orderByComparator, false);
6264    
6265                            return array;
6266                    }
6267                    catch (Exception e) {
6268                            throw processException(e);
6269                    }
6270                    finally {
6271                            closeSession(session);
6272                    }
6273            }
6274    
6275            protected JournalArticle filterGetByG_S_PrevAndNext(Session session,
6276                    JournalArticle journalArticle, long groupId, String structureId,
6277                    OrderByComparator orderByComparator, boolean previous) {
6278                    StringBundler query = null;
6279    
6280                    if (orderByComparator != null) {
6281                            query = new StringBundler(6 +
6282                                            (orderByComparator.getOrderByFields().length * 6));
6283                    }
6284                    else {
6285                            query = new StringBundler(3);
6286                    }
6287    
6288                    if (getDB().isSupportsInlineDistinct()) {
6289                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6290                    }
6291                    else {
6292                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6293                    }
6294    
6295                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6296    
6297                    if (structureId == null) {
6298                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
6299                    }
6300                    else {
6301                            if (structureId.equals(StringPool.BLANK)) {
6302                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
6303                            }
6304                            else {
6305                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
6306                            }
6307                    }
6308    
6309                    if (!getDB().isSupportsInlineDistinct()) {
6310                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6311                    }
6312    
6313                    if (orderByComparator != null) {
6314                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6315    
6316                            if (orderByConditionFields.length > 0) {
6317                                    query.append(WHERE_AND);
6318                            }
6319    
6320                            for (int i = 0; i < orderByConditionFields.length; i++) {
6321                                    if (getDB().isSupportsInlineDistinct()) {
6322                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6323                                    }
6324                                    else {
6325                                            query.append(_ORDER_BY_ENTITY_TABLE);
6326                                    }
6327    
6328                                    query.append(orderByConditionFields[i]);
6329    
6330                                    if ((i + 1) < orderByConditionFields.length) {
6331                                            if (orderByComparator.isAscending() ^ previous) {
6332                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6333                                            }
6334                                            else {
6335                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6336                                            }
6337                                    }
6338                                    else {
6339                                            if (orderByComparator.isAscending() ^ previous) {
6340                                                    query.append(WHERE_GREATER_THAN);
6341                                            }
6342                                            else {
6343                                                    query.append(WHERE_LESSER_THAN);
6344                                            }
6345                                    }
6346                            }
6347    
6348                            query.append(ORDER_BY_CLAUSE);
6349    
6350                            String[] orderByFields = orderByComparator.getOrderByFields();
6351    
6352                            for (int i = 0; i < orderByFields.length; i++) {
6353                                    if (getDB().isSupportsInlineDistinct()) {
6354                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6355                                    }
6356                                    else {
6357                                            query.append(_ORDER_BY_ENTITY_TABLE);
6358                                    }
6359    
6360                                    query.append(orderByFields[i]);
6361    
6362                                    if ((i + 1) < orderByFields.length) {
6363                                            if (orderByComparator.isAscending() ^ previous) {
6364                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6365                                            }
6366                                            else {
6367                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6368                                            }
6369                                    }
6370                                    else {
6371                                            if (orderByComparator.isAscending() ^ previous) {
6372                                                    query.append(ORDER_BY_ASC);
6373                                            }
6374                                            else {
6375                                                    query.append(ORDER_BY_DESC);
6376                                            }
6377                                    }
6378                            }
6379                    }
6380    
6381                    else {
6382                            if (getDB().isSupportsInlineDistinct()) {
6383                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6384                            }
6385                            else {
6386                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6387                            }
6388                    }
6389    
6390                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6391                                    JournalArticle.class.getName(),
6392                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6393    
6394                    SQLQuery q = session.createSQLQuery(sql);
6395    
6396                    q.setFirstResult(0);
6397                    q.setMaxResults(2);
6398    
6399                    if (getDB().isSupportsInlineDistinct()) {
6400                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6401                    }
6402                    else {
6403                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6404                    }
6405    
6406                    QueryPos qPos = QueryPos.getInstance(q);
6407    
6408                    qPos.add(groupId);
6409    
6410                    if (structureId != null) {
6411                            qPos.add(structureId);
6412                    }
6413    
6414                    if (orderByComparator != null) {
6415                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6416    
6417                            for (Object value : values) {
6418                                    qPos.add(value);
6419                            }
6420                    }
6421    
6422                    List<JournalArticle> list = q.list();
6423    
6424                    if (list.size() == 2) {
6425                            return list.get(1);
6426                    }
6427                    else {
6428                            return null;
6429                    }
6430            }
6431    
6432            /**
6433             * Returns all the journal articles where groupId = &#63; and templateId = &#63;.
6434             *
6435             * @param groupId the group ID
6436             * @param templateId the template ID
6437             * @return the matching journal articles
6438             * @throws SystemException if a system exception occurred
6439             */
6440            public List<JournalArticle> findByG_T(long groupId, String templateId)
6441                    throws SystemException {
6442                    return findByG_T(groupId, templateId, QueryUtil.ALL_POS,
6443                            QueryUtil.ALL_POS, null);
6444            }
6445    
6446            /**
6447             * Returns a range of all the journal articles where groupId = &#63; and templateId = &#63;.
6448             *
6449             * <p>
6450             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6451             * </p>
6452             *
6453             * @param groupId the group ID
6454             * @param templateId the template ID
6455             * @param start the lower bound of the range of journal articles
6456             * @param end the upper bound of the range of journal articles (not inclusive)
6457             * @return the range of matching journal articles
6458             * @throws SystemException if a system exception occurred
6459             */
6460            public List<JournalArticle> findByG_T(long groupId, String templateId,
6461                    int start, int end) throws SystemException {
6462                    return findByG_T(groupId, templateId, start, end, null);
6463            }
6464    
6465            /**
6466             * Returns an ordered range of all the journal articles where groupId = &#63; and templateId = &#63;.
6467             *
6468             * <p>
6469             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6470             * </p>
6471             *
6472             * @param groupId the group ID
6473             * @param templateId the template ID
6474             * @param start the lower bound of the range of journal articles
6475             * @param end the upper bound of the range of journal articles (not inclusive)
6476             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6477             * @return the ordered range of matching journal articles
6478             * @throws SystemException if a system exception occurred
6479             */
6480            public List<JournalArticle> findByG_T(long groupId, String templateId,
6481                    int start, int end, OrderByComparator orderByComparator)
6482                    throws SystemException {
6483                    FinderPath finderPath = null;
6484                    Object[] finderArgs = null;
6485    
6486                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6487                                    (orderByComparator == null)) {
6488                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
6489                            finderArgs = new Object[] { groupId, templateId };
6490                    }
6491                    else {
6492                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
6493                            finderArgs = new Object[] {
6494                                            groupId, templateId,
6495                                            
6496                                            start, end, orderByComparator
6497                                    };
6498                    }
6499    
6500                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
6501                                    finderArgs, this);
6502    
6503                    if (list == null) {
6504                            StringBundler query = null;
6505    
6506                            if (orderByComparator != null) {
6507                                    query = new StringBundler(4 +
6508                                                    (orderByComparator.getOrderByFields().length * 3));
6509                            }
6510                            else {
6511                                    query = new StringBundler(4);
6512                            }
6513    
6514                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6515    
6516                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
6517    
6518                            if (templateId == null) {
6519                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
6520                            }
6521                            else {
6522                                    if (templateId.equals(StringPool.BLANK)) {
6523                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
6524                                    }
6525                                    else {
6526                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
6527                                    }
6528                            }
6529    
6530                            if (orderByComparator != null) {
6531                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6532                                            orderByComparator);
6533                            }
6534    
6535                            else {
6536                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6537                            }
6538    
6539                            String sql = query.toString();
6540    
6541                            Session session = null;
6542    
6543                            try {
6544                                    session = openSession();
6545    
6546                                    Query q = session.createQuery(sql);
6547    
6548                                    QueryPos qPos = QueryPos.getInstance(q);
6549    
6550                                    qPos.add(groupId);
6551    
6552                                    if (templateId != null) {
6553                                            qPos.add(templateId);
6554                                    }
6555    
6556                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
6557                                                    start, end);
6558                            }
6559                            catch (Exception e) {
6560                                    throw processException(e);
6561                            }
6562                            finally {
6563                                    if (list == null) {
6564                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6565                                    }
6566                                    else {
6567                                            cacheResult(list);
6568    
6569                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6570                                    }
6571    
6572                                    closeSession(session);
6573                            }
6574                    }
6575    
6576                    return list;
6577            }
6578    
6579            /**
6580             * Returns the first journal article in the ordered set where groupId = &#63; and templateId = &#63;.
6581             *
6582             * <p>
6583             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6584             * </p>
6585             *
6586             * @param groupId the group ID
6587             * @param templateId the template ID
6588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6589             * @return the first matching journal article
6590             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6591             * @throws SystemException if a system exception occurred
6592             */
6593            public JournalArticle findByG_T_First(long groupId, String templateId,
6594                    OrderByComparator orderByComparator)
6595                    throws NoSuchArticleException, SystemException {
6596                    List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1,
6597                                    orderByComparator);
6598    
6599                    if (list.isEmpty()) {
6600                            StringBundler msg = new StringBundler(6);
6601    
6602                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6603    
6604                            msg.append("groupId=");
6605                            msg.append(groupId);
6606    
6607                            msg.append(", templateId=");
6608                            msg.append(templateId);
6609    
6610                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6611    
6612                            throw new NoSuchArticleException(msg.toString());
6613                    }
6614                    else {
6615                            return list.get(0);
6616                    }
6617            }
6618    
6619            /**
6620             * Returns the last journal article in the ordered set where groupId = &#63; and templateId = &#63;.
6621             *
6622             * <p>
6623             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6624             * </p>
6625             *
6626             * @param groupId the group ID
6627             * @param templateId the template ID
6628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6629             * @return the last matching journal article
6630             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
6631             * @throws SystemException if a system exception occurred
6632             */
6633            public JournalArticle findByG_T_Last(long groupId, String templateId,
6634                    OrderByComparator orderByComparator)
6635                    throws NoSuchArticleException, SystemException {
6636                    int count = countByG_T(groupId, templateId);
6637    
6638                    List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
6639                                    count, orderByComparator);
6640    
6641                    if (list.isEmpty()) {
6642                            StringBundler msg = new StringBundler(6);
6643    
6644                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6645    
6646                            msg.append("groupId=");
6647                            msg.append(groupId);
6648    
6649                            msg.append(", templateId=");
6650                            msg.append(templateId);
6651    
6652                            msg.append(StringPool.CLOSE_CURLY_BRACE);
6653    
6654                            throw new NoSuchArticleException(msg.toString());
6655                    }
6656                    else {
6657                            return list.get(0);
6658                    }
6659            }
6660    
6661            /**
6662             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and templateId = &#63;.
6663             *
6664             * <p>
6665             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6666             * </p>
6667             *
6668             * @param id the primary key of the current journal article
6669             * @param groupId the group ID
6670             * @param templateId the template ID
6671             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6672             * @return the previous, current, and next journal article
6673             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6674             * @throws SystemException if a system exception occurred
6675             */
6676            public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
6677                    String templateId, OrderByComparator orderByComparator)
6678                    throws NoSuchArticleException, SystemException {
6679                    JournalArticle journalArticle = findByPrimaryKey(id);
6680    
6681                    Session session = null;
6682    
6683                    try {
6684                            session = openSession();
6685    
6686                            JournalArticle[] array = new JournalArticleImpl[3];
6687    
6688                            array[0] = getByG_T_PrevAndNext(session, journalArticle, groupId,
6689                                            templateId, orderByComparator, true);
6690    
6691                            array[1] = journalArticle;
6692    
6693                            array[2] = getByG_T_PrevAndNext(session, journalArticle, groupId,
6694                                            templateId, orderByComparator, false);
6695    
6696                            return array;
6697                    }
6698                    catch (Exception e) {
6699                            throw processException(e);
6700                    }
6701                    finally {
6702                            closeSession(session);
6703                    }
6704            }
6705    
6706            protected JournalArticle getByG_T_PrevAndNext(Session session,
6707                    JournalArticle journalArticle, long groupId, String templateId,
6708                    OrderByComparator orderByComparator, boolean previous) {
6709                    StringBundler query = null;
6710    
6711                    if (orderByComparator != null) {
6712                            query = new StringBundler(6 +
6713                                            (orderByComparator.getOrderByFields().length * 6));
6714                    }
6715                    else {
6716                            query = new StringBundler(3);
6717                    }
6718    
6719                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
6720    
6721                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
6722    
6723                    if (templateId == null) {
6724                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
6725                    }
6726                    else {
6727                            if (templateId.equals(StringPool.BLANK)) {
6728                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
6729                            }
6730                            else {
6731                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
6732                            }
6733                    }
6734    
6735                    if (orderByComparator != null) {
6736                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6737    
6738                            if (orderByConditionFields.length > 0) {
6739                                    query.append(WHERE_AND);
6740                            }
6741    
6742                            for (int i = 0; i < orderByConditionFields.length; i++) {
6743                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6744                                    query.append(orderByConditionFields[i]);
6745    
6746                                    if ((i + 1) < orderByConditionFields.length) {
6747                                            if (orderByComparator.isAscending() ^ previous) {
6748                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6749                                            }
6750                                            else {
6751                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6752                                            }
6753                                    }
6754                                    else {
6755                                            if (orderByComparator.isAscending() ^ previous) {
6756                                                    query.append(WHERE_GREATER_THAN);
6757                                            }
6758                                            else {
6759                                                    query.append(WHERE_LESSER_THAN);
6760                                            }
6761                                    }
6762                            }
6763    
6764                            query.append(ORDER_BY_CLAUSE);
6765    
6766                            String[] orderByFields = orderByComparator.getOrderByFields();
6767    
6768                            for (int i = 0; i < orderByFields.length; i++) {
6769                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6770                                    query.append(orderByFields[i]);
6771    
6772                                    if ((i + 1) < orderByFields.length) {
6773                                            if (orderByComparator.isAscending() ^ previous) {
6774                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6775                                            }
6776                                            else {
6777                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6778                                            }
6779                                    }
6780                                    else {
6781                                            if (orderByComparator.isAscending() ^ previous) {
6782                                                    query.append(ORDER_BY_ASC);
6783                                            }
6784                                            else {
6785                                                    query.append(ORDER_BY_DESC);
6786                                            }
6787                                    }
6788                            }
6789                    }
6790    
6791                    else {
6792                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6793                    }
6794    
6795                    String sql = query.toString();
6796    
6797                    Query q = session.createQuery(sql);
6798    
6799                    q.setFirstResult(0);
6800                    q.setMaxResults(2);
6801    
6802                    QueryPos qPos = QueryPos.getInstance(q);
6803    
6804                    qPos.add(groupId);
6805    
6806                    if (templateId != null) {
6807                            qPos.add(templateId);
6808                    }
6809    
6810                    if (orderByComparator != null) {
6811                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
6812    
6813                            for (Object value : values) {
6814                                    qPos.add(value);
6815                            }
6816                    }
6817    
6818                    List<JournalArticle> list = q.list();
6819    
6820                    if (list.size() == 2) {
6821                            return list.get(1);
6822                    }
6823                    else {
6824                            return null;
6825                    }
6826            }
6827    
6828            /**
6829             * Returns all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
6830             *
6831             * @param groupId the group ID
6832             * @param templateId the template ID
6833             * @return the matching journal articles that the user has permission to view
6834             * @throws SystemException if a system exception occurred
6835             */
6836            public List<JournalArticle> filterFindByG_T(long groupId, String templateId)
6837                    throws SystemException {
6838                    return filterFindByG_T(groupId, templateId, QueryUtil.ALL_POS,
6839                            QueryUtil.ALL_POS, null);
6840            }
6841    
6842            /**
6843             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
6844             *
6845             * <p>
6846             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6847             * </p>
6848             *
6849             * @param groupId the group ID
6850             * @param templateId the template ID
6851             * @param start the lower bound of the range of journal articles
6852             * @param end the upper bound of the range of journal articles (not inclusive)
6853             * @return the range of matching journal articles that the user has permission to view
6854             * @throws SystemException if a system exception occurred
6855             */
6856            public List<JournalArticle> filterFindByG_T(long groupId,
6857                    String templateId, int start, int end) throws SystemException {
6858                    return filterFindByG_T(groupId, templateId, start, end, null);
6859            }
6860    
6861            /**
6862             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and templateId = &#63;.
6863             *
6864             * <p>
6865             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6866             * </p>
6867             *
6868             * @param groupId the group ID
6869             * @param templateId the template ID
6870             * @param start the lower bound of the range of journal articles
6871             * @param end the upper bound of the range of journal articles (not inclusive)
6872             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6873             * @return the ordered range of matching journal articles that the user has permission to view
6874             * @throws SystemException if a system exception occurred
6875             */
6876            public List<JournalArticle> filterFindByG_T(long groupId,
6877                    String templateId, int start, int end,
6878                    OrderByComparator orderByComparator) throws SystemException {
6879                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6880                            return findByG_T(groupId, templateId, start, end, orderByComparator);
6881                    }
6882    
6883                    StringBundler query = null;
6884    
6885                    if (orderByComparator != null) {
6886                            query = new StringBundler(4 +
6887                                            (orderByComparator.getOrderByFields().length * 3));
6888                    }
6889                    else {
6890                            query = new StringBundler(4);
6891                    }
6892    
6893                    if (getDB().isSupportsInlineDistinct()) {
6894                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
6895                    }
6896                    else {
6897                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
6898                    }
6899    
6900                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
6901    
6902                    if (templateId == null) {
6903                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
6904                    }
6905                    else {
6906                            if (templateId.equals(StringPool.BLANK)) {
6907                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
6908                            }
6909                            else {
6910                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
6911                            }
6912                    }
6913    
6914                    if (!getDB().isSupportsInlineDistinct()) {
6915                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
6916                    }
6917    
6918                    if (orderByComparator != null) {
6919                            if (getDB().isSupportsInlineDistinct()) {
6920                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6921                                            orderByComparator);
6922                            }
6923                            else {
6924                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6925                                            orderByComparator);
6926                            }
6927                    }
6928    
6929                    else {
6930                            if (getDB().isSupportsInlineDistinct()) {
6931                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
6932                            }
6933                            else {
6934                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
6935                            }
6936                    }
6937    
6938                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6939                                    JournalArticle.class.getName(),
6940                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6941    
6942                    Session session = null;
6943    
6944                    try {
6945                            session = openSession();
6946    
6947                            SQLQuery q = session.createSQLQuery(sql);
6948    
6949                            if (getDB().isSupportsInlineDistinct()) {
6950                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
6951                            }
6952                            else {
6953                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
6954                            }
6955    
6956                            QueryPos qPos = QueryPos.getInstance(q);
6957    
6958                            qPos.add(groupId);
6959    
6960                            if (templateId != null) {
6961                                    qPos.add(templateId);
6962                            }
6963    
6964                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
6965                                    end);
6966                    }
6967                    catch (Exception e) {
6968                            throw processException(e);
6969                    }
6970                    finally {
6971                            closeSession(session);
6972                    }
6973            }
6974    
6975            /**
6976             * 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;.
6977             *
6978             * @param id the primary key of the current journal article
6979             * @param groupId the group ID
6980             * @param templateId the template ID
6981             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6982             * @return the previous, current, and next journal article
6983             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
6984             * @throws SystemException if a system exception occurred
6985             */
6986            public JournalArticle[] filterFindByG_T_PrevAndNext(long id, long groupId,
6987                    String templateId, OrderByComparator orderByComparator)
6988                    throws NoSuchArticleException, SystemException {
6989                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6990                            return findByG_T_PrevAndNext(id, groupId, templateId,
6991                                    orderByComparator);
6992                    }
6993    
6994                    JournalArticle journalArticle = findByPrimaryKey(id);
6995    
6996                    Session session = null;
6997    
6998                    try {
6999                            session = openSession();
7000    
7001                            JournalArticle[] array = new JournalArticleImpl[3];
7002    
7003                            array[0] = filterGetByG_T_PrevAndNext(session, journalArticle,
7004                                            groupId, templateId, orderByComparator, true);
7005    
7006                            array[1] = journalArticle;
7007    
7008                            array[2] = filterGetByG_T_PrevAndNext(session, journalArticle,
7009                                            groupId, templateId, orderByComparator, false);
7010    
7011                            return array;
7012                    }
7013                    catch (Exception e) {
7014                            throw processException(e);
7015                    }
7016                    finally {
7017                            closeSession(session);
7018                    }
7019            }
7020    
7021            protected JournalArticle filterGetByG_T_PrevAndNext(Session session,
7022                    JournalArticle journalArticle, long groupId, String templateId,
7023                    OrderByComparator orderByComparator, boolean previous) {
7024                    StringBundler query = null;
7025    
7026                    if (orderByComparator != null) {
7027                            query = new StringBundler(6 +
7028                                            (orderByComparator.getOrderByFields().length * 6));
7029                    }
7030                    else {
7031                            query = new StringBundler(3);
7032                    }
7033    
7034                    if (getDB().isSupportsInlineDistinct()) {
7035                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7036                    }
7037                    else {
7038                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7039                    }
7040    
7041                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
7042    
7043                    if (templateId == null) {
7044                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
7045                    }
7046                    else {
7047                            if (templateId.equals(StringPool.BLANK)) {
7048                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
7049                            }
7050                            else {
7051                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
7052                            }
7053                    }
7054    
7055                    if (!getDB().isSupportsInlineDistinct()) {
7056                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7057                    }
7058    
7059                    if (orderByComparator != null) {
7060                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7061    
7062                            if (orderByConditionFields.length > 0) {
7063                                    query.append(WHERE_AND);
7064                            }
7065    
7066                            for (int i = 0; i < orderByConditionFields.length; i++) {
7067                                    if (getDB().isSupportsInlineDistinct()) {
7068                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7069                                    }
7070                                    else {
7071                                            query.append(_ORDER_BY_ENTITY_TABLE);
7072                                    }
7073    
7074                                    query.append(orderByConditionFields[i]);
7075    
7076                                    if ((i + 1) < orderByConditionFields.length) {
7077                                            if (orderByComparator.isAscending() ^ previous) {
7078                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7079                                            }
7080                                            else {
7081                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7082                                            }
7083                                    }
7084                                    else {
7085                                            if (orderByComparator.isAscending() ^ previous) {
7086                                                    query.append(WHERE_GREATER_THAN);
7087                                            }
7088                                            else {
7089                                                    query.append(WHERE_LESSER_THAN);
7090                                            }
7091                                    }
7092                            }
7093    
7094                            query.append(ORDER_BY_CLAUSE);
7095    
7096                            String[] orderByFields = orderByComparator.getOrderByFields();
7097    
7098                            for (int i = 0; i < orderByFields.length; i++) {
7099                                    if (getDB().isSupportsInlineDistinct()) {
7100                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7101                                    }
7102                                    else {
7103                                            query.append(_ORDER_BY_ENTITY_TABLE);
7104                                    }
7105    
7106                                    query.append(orderByFields[i]);
7107    
7108                                    if ((i + 1) < orderByFields.length) {
7109                                            if (orderByComparator.isAscending() ^ previous) {
7110                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7111                                            }
7112                                            else {
7113                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7114                                            }
7115                                    }
7116                                    else {
7117                                            if (orderByComparator.isAscending() ^ previous) {
7118                                                    query.append(ORDER_BY_ASC);
7119                                            }
7120                                            else {
7121                                                    query.append(ORDER_BY_DESC);
7122                                            }
7123                                    }
7124                            }
7125                    }
7126    
7127                    else {
7128                            if (getDB().isSupportsInlineDistinct()) {
7129                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7130                            }
7131                            else {
7132                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7133                            }
7134                    }
7135    
7136                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7137                                    JournalArticle.class.getName(),
7138                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7139    
7140                    SQLQuery q = session.createSQLQuery(sql);
7141    
7142                    q.setFirstResult(0);
7143                    q.setMaxResults(2);
7144    
7145                    if (getDB().isSupportsInlineDistinct()) {
7146                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7147                    }
7148                    else {
7149                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7150                    }
7151    
7152                    QueryPos qPos = QueryPos.getInstance(q);
7153    
7154                    qPos.add(groupId);
7155    
7156                    if (templateId != null) {
7157                            qPos.add(templateId);
7158                    }
7159    
7160                    if (orderByComparator != null) {
7161                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7162    
7163                            for (Object value : values) {
7164                                    qPos.add(value);
7165                            }
7166                    }
7167    
7168                    List<JournalArticle> list = q.list();
7169    
7170                    if (list.size() == 2) {
7171                            return list.get(1);
7172                    }
7173                    else {
7174                            return null;
7175                    }
7176            }
7177    
7178            /**
7179             * Returns all the journal articles where groupId = &#63; and layoutUuid = &#63;.
7180             *
7181             * @param groupId the group ID
7182             * @param layoutUuid the layout uuid
7183             * @return the matching journal articles
7184             * @throws SystemException if a system exception occurred
7185             */
7186            public List<JournalArticle> findByG_L(long groupId, String layoutUuid)
7187                    throws SystemException {
7188                    return findByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
7189                            QueryUtil.ALL_POS, null);
7190            }
7191    
7192            /**
7193             * Returns a range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
7194             *
7195             * <p>
7196             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7197             * </p>
7198             *
7199             * @param groupId the group ID
7200             * @param layoutUuid the layout uuid
7201             * @param start the lower bound of the range of journal articles
7202             * @param end the upper bound of the range of journal articles (not inclusive)
7203             * @return the range of matching journal articles
7204             * @throws SystemException if a system exception occurred
7205             */
7206            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
7207                    int start, int end) throws SystemException {
7208                    return findByG_L(groupId, layoutUuid, start, end, null);
7209            }
7210    
7211            /**
7212             * Returns an ordered range of all the journal articles where groupId = &#63; and layoutUuid = &#63;.
7213             *
7214             * <p>
7215             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7216             * </p>
7217             *
7218             * @param groupId the group ID
7219             * @param layoutUuid the layout uuid
7220             * @param start the lower bound of the range of journal articles
7221             * @param end the upper bound of the range of journal articles (not inclusive)
7222             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7223             * @return the ordered range of matching journal articles
7224             * @throws SystemException if a system exception occurred
7225             */
7226            public List<JournalArticle> findByG_L(long groupId, String layoutUuid,
7227                    int start, int end, OrderByComparator orderByComparator)
7228                    throws SystemException {
7229                    FinderPath finderPath = null;
7230                    Object[] finderArgs = null;
7231    
7232                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7233                                    (orderByComparator == null)) {
7234                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_L;
7235                            finderArgs = new Object[] { groupId, layoutUuid };
7236                    }
7237                    else {
7238                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_L;
7239                            finderArgs = new Object[] {
7240                                            groupId, layoutUuid,
7241                                            
7242                                            start, end, orderByComparator
7243                                    };
7244                    }
7245    
7246                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7247                                    finderArgs, this);
7248    
7249                    if (list == null) {
7250                            StringBundler query = null;
7251    
7252                            if (orderByComparator != null) {
7253                                    query = new StringBundler(4 +
7254                                                    (orderByComparator.getOrderByFields().length * 3));
7255                            }
7256                            else {
7257                                    query = new StringBundler(4);
7258                            }
7259    
7260                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7261    
7262                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7263    
7264                            if (layoutUuid == null) {
7265                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7266                            }
7267                            else {
7268                                    if (layoutUuid.equals(StringPool.BLANK)) {
7269                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7270                                    }
7271                                    else {
7272                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7273                                    }
7274                            }
7275    
7276                            if (orderByComparator != null) {
7277                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7278                                            orderByComparator);
7279                            }
7280    
7281                            else {
7282                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7283                            }
7284    
7285                            String sql = query.toString();
7286    
7287                            Session session = null;
7288    
7289                            try {
7290                                    session = openSession();
7291    
7292                                    Query q = session.createQuery(sql);
7293    
7294                                    QueryPos qPos = QueryPos.getInstance(q);
7295    
7296                                    qPos.add(groupId);
7297    
7298                                    if (layoutUuid != null) {
7299                                            qPos.add(layoutUuid);
7300                                    }
7301    
7302                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
7303                                                    start, end);
7304                            }
7305                            catch (Exception e) {
7306                                    throw processException(e);
7307                            }
7308                            finally {
7309                                    if (list == null) {
7310                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7311                                    }
7312                                    else {
7313                                            cacheResult(list);
7314    
7315                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7316                                    }
7317    
7318                                    closeSession(session);
7319                            }
7320                    }
7321    
7322                    return list;
7323            }
7324    
7325            /**
7326             * Returns the first journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
7327             *
7328             * <p>
7329             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7330             * </p>
7331             *
7332             * @param groupId the group ID
7333             * @param layoutUuid the layout uuid
7334             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7335             * @return the first matching journal article
7336             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7337             * @throws SystemException if a system exception occurred
7338             */
7339            public JournalArticle findByG_L_First(long groupId, String layoutUuid,
7340                    OrderByComparator orderByComparator)
7341                    throws NoSuchArticleException, SystemException {
7342                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, 0, 1,
7343                                    orderByComparator);
7344    
7345                    if (list.isEmpty()) {
7346                            StringBundler msg = new StringBundler(6);
7347    
7348                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7349    
7350                            msg.append("groupId=");
7351                            msg.append(groupId);
7352    
7353                            msg.append(", layoutUuid=");
7354                            msg.append(layoutUuid);
7355    
7356                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7357    
7358                            throw new NoSuchArticleException(msg.toString());
7359                    }
7360                    else {
7361                            return list.get(0);
7362                    }
7363            }
7364    
7365            /**
7366             * Returns the last journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
7367             *
7368             * <p>
7369             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7370             * </p>
7371             *
7372             * @param groupId the group ID
7373             * @param layoutUuid the layout uuid
7374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7375             * @return the last matching journal article
7376             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
7377             * @throws SystemException if a system exception occurred
7378             */
7379            public JournalArticle findByG_L_Last(long groupId, String layoutUuid,
7380                    OrderByComparator orderByComparator)
7381                    throws NoSuchArticleException, SystemException {
7382                    int count = countByG_L(groupId, layoutUuid);
7383    
7384                    List<JournalArticle> list = findByG_L(groupId, layoutUuid, count - 1,
7385                                    count, orderByComparator);
7386    
7387                    if (list.isEmpty()) {
7388                            StringBundler msg = new StringBundler(6);
7389    
7390                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7391    
7392                            msg.append("groupId=");
7393                            msg.append(groupId);
7394    
7395                            msg.append(", layoutUuid=");
7396                            msg.append(layoutUuid);
7397    
7398                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7399    
7400                            throw new NoSuchArticleException(msg.toString());
7401                    }
7402                    else {
7403                            return list.get(0);
7404                    }
7405            }
7406    
7407            /**
7408             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and layoutUuid = &#63;.
7409             *
7410             * <p>
7411             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7412             * </p>
7413             *
7414             * @param id the primary key of the current journal article
7415             * @param groupId the group ID
7416             * @param layoutUuid the layout uuid
7417             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7418             * @return the previous, current, and next journal article
7419             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7420             * @throws SystemException if a system exception occurred
7421             */
7422            public JournalArticle[] findByG_L_PrevAndNext(long id, long groupId,
7423                    String layoutUuid, OrderByComparator orderByComparator)
7424                    throws NoSuchArticleException, SystemException {
7425                    JournalArticle journalArticle = findByPrimaryKey(id);
7426    
7427                    Session session = null;
7428    
7429                    try {
7430                            session = openSession();
7431    
7432                            JournalArticle[] array = new JournalArticleImpl[3];
7433    
7434                            array[0] = getByG_L_PrevAndNext(session, journalArticle, groupId,
7435                                            layoutUuid, orderByComparator, true);
7436    
7437                            array[1] = journalArticle;
7438    
7439                            array[2] = getByG_L_PrevAndNext(session, journalArticle, groupId,
7440                                            layoutUuid, orderByComparator, false);
7441    
7442                            return array;
7443                    }
7444                    catch (Exception e) {
7445                            throw processException(e);
7446                    }
7447                    finally {
7448                            closeSession(session);
7449                    }
7450            }
7451    
7452            protected JournalArticle getByG_L_PrevAndNext(Session session,
7453                    JournalArticle journalArticle, long groupId, String layoutUuid,
7454                    OrderByComparator orderByComparator, boolean previous) {
7455                    StringBundler query = null;
7456    
7457                    if (orderByComparator != null) {
7458                            query = new StringBundler(6 +
7459                                            (orderByComparator.getOrderByFields().length * 6));
7460                    }
7461                    else {
7462                            query = new StringBundler(3);
7463                    }
7464    
7465                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
7466    
7467                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7468    
7469                    if (layoutUuid == null) {
7470                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7471                    }
7472                    else {
7473                            if (layoutUuid.equals(StringPool.BLANK)) {
7474                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7475                            }
7476                            else {
7477                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7478                            }
7479                    }
7480    
7481                    if (orderByComparator != null) {
7482                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7483    
7484                            if (orderByConditionFields.length > 0) {
7485                                    query.append(WHERE_AND);
7486                            }
7487    
7488                            for (int i = 0; i < orderByConditionFields.length; i++) {
7489                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7490                                    query.append(orderByConditionFields[i]);
7491    
7492                                    if ((i + 1) < orderByConditionFields.length) {
7493                                            if (orderByComparator.isAscending() ^ previous) {
7494                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7495                                            }
7496                                            else {
7497                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7498                                            }
7499                                    }
7500                                    else {
7501                                            if (orderByComparator.isAscending() ^ previous) {
7502                                                    query.append(WHERE_GREATER_THAN);
7503                                            }
7504                                            else {
7505                                                    query.append(WHERE_LESSER_THAN);
7506                                            }
7507                                    }
7508                            }
7509    
7510                            query.append(ORDER_BY_CLAUSE);
7511    
7512                            String[] orderByFields = orderByComparator.getOrderByFields();
7513    
7514                            for (int i = 0; i < orderByFields.length; i++) {
7515                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7516                                    query.append(orderByFields[i]);
7517    
7518                                    if ((i + 1) < orderByFields.length) {
7519                                            if (orderByComparator.isAscending() ^ previous) {
7520                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7521                                            }
7522                                            else {
7523                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7524                                            }
7525                                    }
7526                                    else {
7527                                            if (orderByComparator.isAscending() ^ previous) {
7528                                                    query.append(ORDER_BY_ASC);
7529                                            }
7530                                            else {
7531                                                    query.append(ORDER_BY_DESC);
7532                                            }
7533                                    }
7534                            }
7535                    }
7536    
7537                    else {
7538                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7539                    }
7540    
7541                    String sql = query.toString();
7542    
7543                    Query q = session.createQuery(sql);
7544    
7545                    q.setFirstResult(0);
7546                    q.setMaxResults(2);
7547    
7548                    QueryPos qPos = QueryPos.getInstance(q);
7549    
7550                    qPos.add(groupId);
7551    
7552                    if (layoutUuid != null) {
7553                            qPos.add(layoutUuid);
7554                    }
7555    
7556                    if (orderByComparator != null) {
7557                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7558    
7559                            for (Object value : values) {
7560                                    qPos.add(value);
7561                            }
7562                    }
7563    
7564                    List<JournalArticle> list = q.list();
7565    
7566                    if (list.size() == 2) {
7567                            return list.get(1);
7568                    }
7569                    else {
7570                            return null;
7571                    }
7572            }
7573    
7574            /**
7575             * Returns all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
7576             *
7577             * @param groupId the group ID
7578             * @param layoutUuid the layout uuid
7579             * @return the matching journal articles that the user has permission to view
7580             * @throws SystemException if a system exception occurred
7581             */
7582            public List<JournalArticle> filterFindByG_L(long groupId, String layoutUuid)
7583                    throws SystemException {
7584                    return filterFindByG_L(groupId, layoutUuid, QueryUtil.ALL_POS,
7585                            QueryUtil.ALL_POS, null);
7586            }
7587    
7588            /**
7589             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
7590             *
7591             * <p>
7592             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7593             * </p>
7594             *
7595             * @param groupId the group ID
7596             * @param layoutUuid the layout uuid
7597             * @param start the lower bound of the range of journal articles
7598             * @param end the upper bound of the range of journal articles (not inclusive)
7599             * @return the range of matching journal articles that the user has permission to view
7600             * @throws SystemException if a system exception occurred
7601             */
7602            public List<JournalArticle> filterFindByG_L(long groupId,
7603                    String layoutUuid, int start, int end) throws SystemException {
7604                    return filterFindByG_L(groupId, layoutUuid, start, end, null);
7605            }
7606    
7607            /**
7608             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and layoutUuid = &#63;.
7609             *
7610             * <p>
7611             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7612             * </p>
7613             *
7614             * @param groupId the group ID
7615             * @param layoutUuid the layout uuid
7616             * @param start the lower bound of the range of journal articles
7617             * @param end the upper bound of the range of journal articles (not inclusive)
7618             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7619             * @return the ordered range of matching journal articles that the user has permission to view
7620             * @throws SystemException if a system exception occurred
7621             */
7622            public List<JournalArticle> filterFindByG_L(long groupId,
7623                    String layoutUuid, int start, int end,
7624                    OrderByComparator orderByComparator) throws SystemException {
7625                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7626                            return findByG_L(groupId, layoutUuid, start, end, orderByComparator);
7627                    }
7628    
7629                    StringBundler query = null;
7630    
7631                    if (orderByComparator != null) {
7632                            query = new StringBundler(4 +
7633                                            (orderByComparator.getOrderByFields().length * 3));
7634                    }
7635                    else {
7636                            query = new StringBundler(4);
7637                    }
7638    
7639                    if (getDB().isSupportsInlineDistinct()) {
7640                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7641                    }
7642                    else {
7643                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7644                    }
7645    
7646                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7647    
7648                    if (layoutUuid == null) {
7649                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7650                    }
7651                    else {
7652                            if (layoutUuid.equals(StringPool.BLANK)) {
7653                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7654                            }
7655                            else {
7656                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7657                            }
7658                    }
7659    
7660                    if (!getDB().isSupportsInlineDistinct()) {
7661                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7662                    }
7663    
7664                    if (orderByComparator != null) {
7665                            if (getDB().isSupportsInlineDistinct()) {
7666                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7667                                            orderByComparator);
7668                            }
7669                            else {
7670                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7671                                            orderByComparator);
7672                            }
7673                    }
7674    
7675                    else {
7676                            if (getDB().isSupportsInlineDistinct()) {
7677                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7678                            }
7679                            else {
7680                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7681                            }
7682                    }
7683    
7684                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7685                                    JournalArticle.class.getName(),
7686                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7687    
7688                    Session session = null;
7689    
7690                    try {
7691                            session = openSession();
7692    
7693                            SQLQuery q = session.createSQLQuery(sql);
7694    
7695                            if (getDB().isSupportsInlineDistinct()) {
7696                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7697                            }
7698                            else {
7699                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7700                            }
7701    
7702                            QueryPos qPos = QueryPos.getInstance(q);
7703    
7704                            qPos.add(groupId);
7705    
7706                            if (layoutUuid != null) {
7707                                    qPos.add(layoutUuid);
7708                            }
7709    
7710                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
7711                                    end);
7712                    }
7713                    catch (Exception e) {
7714                            throw processException(e);
7715                    }
7716                    finally {
7717                            closeSession(session);
7718                    }
7719            }
7720    
7721            /**
7722             * 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;.
7723             *
7724             * @param id the primary key of the current journal article
7725             * @param groupId the group ID
7726             * @param layoutUuid the layout uuid
7727             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7728             * @return the previous, current, and next journal article
7729             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
7730             * @throws SystemException if a system exception occurred
7731             */
7732            public JournalArticle[] filterFindByG_L_PrevAndNext(long id, long groupId,
7733                    String layoutUuid, OrderByComparator orderByComparator)
7734                    throws NoSuchArticleException, SystemException {
7735                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7736                            return findByG_L_PrevAndNext(id, groupId, layoutUuid,
7737                                    orderByComparator);
7738                    }
7739    
7740                    JournalArticle journalArticle = findByPrimaryKey(id);
7741    
7742                    Session session = null;
7743    
7744                    try {
7745                            session = openSession();
7746    
7747                            JournalArticle[] array = new JournalArticleImpl[3];
7748    
7749                            array[0] = filterGetByG_L_PrevAndNext(session, journalArticle,
7750                                            groupId, layoutUuid, orderByComparator, true);
7751    
7752                            array[1] = journalArticle;
7753    
7754                            array[2] = filterGetByG_L_PrevAndNext(session, journalArticle,
7755                                            groupId, layoutUuid, orderByComparator, false);
7756    
7757                            return array;
7758                    }
7759                    catch (Exception e) {
7760                            throw processException(e);
7761                    }
7762                    finally {
7763                            closeSession(session);
7764                    }
7765            }
7766    
7767            protected JournalArticle filterGetByG_L_PrevAndNext(Session session,
7768                    JournalArticle journalArticle, long groupId, String layoutUuid,
7769                    OrderByComparator orderByComparator, boolean previous) {
7770                    StringBundler query = null;
7771    
7772                    if (orderByComparator != null) {
7773                            query = new StringBundler(6 +
7774                                            (orderByComparator.getOrderByFields().length * 6));
7775                    }
7776                    else {
7777                            query = new StringBundler(3);
7778                    }
7779    
7780                    if (getDB().isSupportsInlineDistinct()) {
7781                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
7782                    }
7783                    else {
7784                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
7785                    }
7786    
7787                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
7788    
7789                    if (layoutUuid == null) {
7790                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
7791                    }
7792                    else {
7793                            if (layoutUuid.equals(StringPool.BLANK)) {
7794                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
7795                            }
7796                            else {
7797                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
7798                            }
7799                    }
7800    
7801                    if (!getDB().isSupportsInlineDistinct()) {
7802                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
7803                    }
7804    
7805                    if (orderByComparator != null) {
7806                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7807    
7808                            if (orderByConditionFields.length > 0) {
7809                                    query.append(WHERE_AND);
7810                            }
7811    
7812                            for (int i = 0; i < orderByConditionFields.length; i++) {
7813                                    if (getDB().isSupportsInlineDistinct()) {
7814                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7815                                    }
7816                                    else {
7817                                            query.append(_ORDER_BY_ENTITY_TABLE);
7818                                    }
7819    
7820                                    query.append(orderByConditionFields[i]);
7821    
7822                                    if ((i + 1) < orderByConditionFields.length) {
7823                                            if (orderByComparator.isAscending() ^ previous) {
7824                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7825                                            }
7826                                            else {
7827                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7828                                            }
7829                                    }
7830                                    else {
7831                                            if (orderByComparator.isAscending() ^ previous) {
7832                                                    query.append(WHERE_GREATER_THAN);
7833                                            }
7834                                            else {
7835                                                    query.append(WHERE_LESSER_THAN);
7836                                            }
7837                                    }
7838                            }
7839    
7840                            query.append(ORDER_BY_CLAUSE);
7841    
7842                            String[] orderByFields = orderByComparator.getOrderByFields();
7843    
7844                            for (int i = 0; i < orderByFields.length; i++) {
7845                                    if (getDB().isSupportsInlineDistinct()) {
7846                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7847                                    }
7848                                    else {
7849                                            query.append(_ORDER_BY_ENTITY_TABLE);
7850                                    }
7851    
7852                                    query.append(orderByFields[i]);
7853    
7854                                    if ((i + 1) < orderByFields.length) {
7855                                            if (orderByComparator.isAscending() ^ previous) {
7856                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7857                                            }
7858                                            else {
7859                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7860                                            }
7861                                    }
7862                                    else {
7863                                            if (orderByComparator.isAscending() ^ previous) {
7864                                                    query.append(ORDER_BY_ASC);
7865                                            }
7866                                            else {
7867                                                    query.append(ORDER_BY_DESC);
7868                                            }
7869                                    }
7870                            }
7871                    }
7872    
7873                    else {
7874                            if (getDB().isSupportsInlineDistinct()) {
7875                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
7876                            }
7877                            else {
7878                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
7879                            }
7880                    }
7881    
7882                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7883                                    JournalArticle.class.getName(),
7884                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7885    
7886                    SQLQuery q = session.createSQLQuery(sql);
7887    
7888                    q.setFirstResult(0);
7889                    q.setMaxResults(2);
7890    
7891                    if (getDB().isSupportsInlineDistinct()) {
7892                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
7893                    }
7894                    else {
7895                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
7896                    }
7897    
7898                    QueryPos qPos = QueryPos.getInstance(q);
7899    
7900                    qPos.add(groupId);
7901    
7902                    if (layoutUuid != null) {
7903                            qPos.add(layoutUuid);
7904                    }
7905    
7906                    if (orderByComparator != null) {
7907                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
7908    
7909                            for (Object value : values) {
7910                                    qPos.add(value);
7911                            }
7912                    }
7913    
7914                    List<JournalArticle> list = q.list();
7915    
7916                    if (list.size() == 2) {
7917                            return list.get(1);
7918                    }
7919                    else {
7920                            return null;
7921                    }
7922            }
7923    
7924            /**
7925             * Returns all the journal articles where groupId = &#63; and status = &#63;.
7926             *
7927             * @param groupId the group ID
7928             * @param status the status
7929             * @return the matching journal articles
7930             * @throws SystemException if a system exception occurred
7931             */
7932            public List<JournalArticle> findByG_ST(long groupId, int status)
7933                    throws SystemException {
7934                    return findByG_ST(groupId, status, QueryUtil.ALL_POS,
7935                            QueryUtil.ALL_POS, null);
7936            }
7937    
7938            /**
7939             * Returns a range of all the journal articles where groupId = &#63; and status = &#63;.
7940             *
7941             * <p>
7942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7943             * </p>
7944             *
7945             * @param groupId the group ID
7946             * @param status the status
7947             * @param start the lower bound of the range of journal articles
7948             * @param end the upper bound of the range of journal articles (not inclusive)
7949             * @return the range of matching journal articles
7950             * @throws SystemException if a system exception occurred
7951             */
7952            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
7953                    int end) throws SystemException {
7954                    return findByG_ST(groupId, status, start, end, null);
7955            }
7956    
7957            /**
7958             * Returns an ordered range of all the journal articles where groupId = &#63; and status = &#63;.
7959             *
7960             * <p>
7961             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7962             * </p>
7963             *
7964             * @param groupId the group ID
7965             * @param status the status
7966             * @param start the lower bound of the range of journal articles
7967             * @param end the upper bound of the range of journal articles (not inclusive)
7968             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7969             * @return the ordered range of matching journal articles
7970             * @throws SystemException if a system exception occurred
7971             */
7972            public List<JournalArticle> findByG_ST(long groupId, int status, int start,
7973                    int end, OrderByComparator orderByComparator) throws SystemException {
7974                    FinderPath finderPath = null;
7975                    Object[] finderArgs = null;
7976    
7977                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7978                                    (orderByComparator == null)) {
7979                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_ST;
7980                            finderArgs = new Object[] { groupId, status };
7981                    }
7982                    else {
7983                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_ST;
7984                            finderArgs = new Object[] {
7985                                            groupId, status,
7986                                            
7987                                            start, end, orderByComparator
7988                                    };
7989                    }
7990    
7991                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
7992                                    finderArgs, this);
7993    
7994                    if (list == null) {
7995                            StringBundler query = null;
7996    
7997                            if (orderByComparator != null) {
7998                                    query = new StringBundler(4 +
7999                                                    (orderByComparator.getOrderByFields().length * 3));
8000                            }
8001                            else {
8002                                    query = new StringBundler(4);
8003                            }
8004    
8005                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8006    
8007                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8008    
8009                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8010    
8011                            if (orderByComparator != null) {
8012                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8013                                            orderByComparator);
8014                            }
8015    
8016                            else {
8017                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8018                            }
8019    
8020                            String sql = query.toString();
8021    
8022                            Session session = null;
8023    
8024                            try {
8025                                    session = openSession();
8026    
8027                                    Query q = session.createQuery(sql);
8028    
8029                                    QueryPos qPos = QueryPos.getInstance(q);
8030    
8031                                    qPos.add(groupId);
8032    
8033                                    qPos.add(status);
8034    
8035                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
8036                                                    start, end);
8037                            }
8038                            catch (Exception e) {
8039                                    throw processException(e);
8040                            }
8041                            finally {
8042                                    if (list == null) {
8043                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8044                                    }
8045                                    else {
8046                                            cacheResult(list);
8047    
8048                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8049                                    }
8050    
8051                                    closeSession(session);
8052                            }
8053                    }
8054    
8055                    return list;
8056            }
8057    
8058            /**
8059             * Returns the first journal article in the ordered set where groupId = &#63; and status = &#63;.
8060             *
8061             * <p>
8062             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8063             * </p>
8064             *
8065             * @param groupId the group ID
8066             * @param status the status
8067             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8068             * @return the first matching journal article
8069             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8070             * @throws SystemException if a system exception occurred
8071             */
8072            public JournalArticle findByG_ST_First(long groupId, int status,
8073                    OrderByComparator orderByComparator)
8074                    throws NoSuchArticleException, SystemException {
8075                    List<JournalArticle> list = findByG_ST(groupId, status, 0, 1,
8076                                    orderByComparator);
8077    
8078                    if (list.isEmpty()) {
8079                            StringBundler msg = new StringBundler(6);
8080    
8081                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8082    
8083                            msg.append("groupId=");
8084                            msg.append(groupId);
8085    
8086                            msg.append(", status=");
8087                            msg.append(status);
8088    
8089                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8090    
8091                            throw new NoSuchArticleException(msg.toString());
8092                    }
8093                    else {
8094                            return list.get(0);
8095                    }
8096            }
8097    
8098            /**
8099             * Returns the last journal article in the ordered set where groupId = &#63; and status = &#63;.
8100             *
8101             * <p>
8102             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8103             * </p>
8104             *
8105             * @param groupId the group ID
8106             * @param status the status
8107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8108             * @return the last matching journal article
8109             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8110             * @throws SystemException if a system exception occurred
8111             */
8112            public JournalArticle findByG_ST_Last(long groupId, int status,
8113                    OrderByComparator orderByComparator)
8114                    throws NoSuchArticleException, SystemException {
8115                    int count = countByG_ST(groupId, status);
8116    
8117                    List<JournalArticle> list = findByG_ST(groupId, status, count - 1,
8118                                    count, orderByComparator);
8119    
8120                    if (list.isEmpty()) {
8121                            StringBundler msg = new StringBundler(6);
8122    
8123                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8124    
8125                            msg.append("groupId=");
8126                            msg.append(groupId);
8127    
8128                            msg.append(", status=");
8129                            msg.append(status);
8130    
8131                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8132    
8133                            throw new NoSuchArticleException(msg.toString());
8134                    }
8135                    else {
8136                            return list.get(0);
8137                    }
8138            }
8139    
8140            /**
8141             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and status = &#63;.
8142             *
8143             * <p>
8144             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8145             * </p>
8146             *
8147             * @param id the primary key of the current journal article
8148             * @param groupId the group ID
8149             * @param status the status
8150             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8151             * @return the previous, current, and next journal article
8152             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8153             * @throws SystemException if a system exception occurred
8154             */
8155            public JournalArticle[] findByG_ST_PrevAndNext(long id, long groupId,
8156                    int status, OrderByComparator orderByComparator)
8157                    throws NoSuchArticleException, SystemException {
8158                    JournalArticle journalArticle = findByPrimaryKey(id);
8159    
8160                    Session session = null;
8161    
8162                    try {
8163                            session = openSession();
8164    
8165                            JournalArticle[] array = new JournalArticleImpl[3];
8166    
8167                            array[0] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
8168                                            status, orderByComparator, true);
8169    
8170                            array[1] = journalArticle;
8171    
8172                            array[2] = getByG_ST_PrevAndNext(session, journalArticle, groupId,
8173                                            status, orderByComparator, false);
8174    
8175                            return array;
8176                    }
8177                    catch (Exception e) {
8178                            throw processException(e);
8179                    }
8180                    finally {
8181                            closeSession(session);
8182                    }
8183            }
8184    
8185            protected JournalArticle getByG_ST_PrevAndNext(Session session,
8186                    JournalArticle journalArticle, long groupId, int status,
8187                    OrderByComparator orderByComparator, boolean previous) {
8188                    StringBundler query = null;
8189    
8190                    if (orderByComparator != null) {
8191                            query = new StringBundler(6 +
8192                                            (orderByComparator.getOrderByFields().length * 6));
8193                    }
8194                    else {
8195                            query = new StringBundler(3);
8196                    }
8197    
8198                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8199    
8200                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8201    
8202                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8203    
8204                    if (orderByComparator != null) {
8205                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8206    
8207                            if (orderByConditionFields.length > 0) {
8208                                    query.append(WHERE_AND);
8209                            }
8210    
8211                            for (int i = 0; i < orderByConditionFields.length; i++) {
8212                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8213                                    query.append(orderByConditionFields[i]);
8214    
8215                                    if ((i + 1) < orderByConditionFields.length) {
8216                                            if (orderByComparator.isAscending() ^ previous) {
8217                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8218                                            }
8219                                            else {
8220                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8221                                            }
8222                                    }
8223                                    else {
8224                                            if (orderByComparator.isAscending() ^ previous) {
8225                                                    query.append(WHERE_GREATER_THAN);
8226                                            }
8227                                            else {
8228                                                    query.append(WHERE_LESSER_THAN);
8229                                            }
8230                                    }
8231                            }
8232    
8233                            query.append(ORDER_BY_CLAUSE);
8234    
8235                            String[] orderByFields = orderByComparator.getOrderByFields();
8236    
8237                            for (int i = 0; i < orderByFields.length; i++) {
8238                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8239                                    query.append(orderByFields[i]);
8240    
8241                                    if ((i + 1) < orderByFields.length) {
8242                                            if (orderByComparator.isAscending() ^ previous) {
8243                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8244                                            }
8245                                            else {
8246                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8247                                            }
8248                                    }
8249                                    else {
8250                                            if (orderByComparator.isAscending() ^ previous) {
8251                                                    query.append(ORDER_BY_ASC);
8252                                            }
8253                                            else {
8254                                                    query.append(ORDER_BY_DESC);
8255                                            }
8256                                    }
8257                            }
8258                    }
8259    
8260                    else {
8261                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8262                    }
8263    
8264                    String sql = query.toString();
8265    
8266                    Query q = session.createQuery(sql);
8267    
8268                    q.setFirstResult(0);
8269                    q.setMaxResults(2);
8270    
8271                    QueryPos qPos = QueryPos.getInstance(q);
8272    
8273                    qPos.add(groupId);
8274    
8275                    qPos.add(status);
8276    
8277                    if (orderByComparator != null) {
8278                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8279    
8280                            for (Object value : values) {
8281                                    qPos.add(value);
8282                            }
8283                    }
8284    
8285                    List<JournalArticle> list = q.list();
8286    
8287                    if (list.size() == 2) {
8288                            return list.get(1);
8289                    }
8290                    else {
8291                            return null;
8292                    }
8293            }
8294    
8295            /**
8296             * Returns all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
8297             *
8298             * @param groupId the group ID
8299             * @param status the status
8300             * @return the matching journal articles that the user has permission to view
8301             * @throws SystemException if a system exception occurred
8302             */
8303            public List<JournalArticle> filterFindByG_ST(long groupId, int status)
8304                    throws SystemException {
8305                    return filterFindByG_ST(groupId, status, QueryUtil.ALL_POS,
8306                            QueryUtil.ALL_POS, null);
8307            }
8308    
8309            /**
8310             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
8311             *
8312             * <p>
8313             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8314             * </p>
8315             *
8316             * @param groupId the group ID
8317             * @param status the status
8318             * @param start the lower bound of the range of journal articles
8319             * @param end the upper bound of the range of journal articles (not inclusive)
8320             * @return the range of matching journal articles that the user has permission to view
8321             * @throws SystemException if a system exception occurred
8322             */
8323            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
8324                    int start, int end) throws SystemException {
8325                    return filterFindByG_ST(groupId, status, start, end, null);
8326            }
8327    
8328            /**
8329             * Returns an ordered range of all the journal articles that the user has permissions to view where groupId = &#63; and status = &#63;.
8330             *
8331             * <p>
8332             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8333             * </p>
8334             *
8335             * @param groupId the group ID
8336             * @param status the status
8337             * @param start the lower bound of the range of journal articles
8338             * @param end the upper bound of the range of journal articles (not inclusive)
8339             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8340             * @return the ordered range of matching journal articles that the user has permission to view
8341             * @throws SystemException if a system exception occurred
8342             */
8343            public List<JournalArticle> filterFindByG_ST(long groupId, int status,
8344                    int start, int end, OrderByComparator orderByComparator)
8345                    throws SystemException {
8346                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8347                            return findByG_ST(groupId, status, start, end, orderByComparator);
8348                    }
8349    
8350                    StringBundler query = null;
8351    
8352                    if (orderByComparator != null) {
8353                            query = new StringBundler(4 +
8354                                            (orderByComparator.getOrderByFields().length * 3));
8355                    }
8356                    else {
8357                            query = new StringBundler(4);
8358                    }
8359    
8360                    if (getDB().isSupportsInlineDistinct()) {
8361                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8362                    }
8363                    else {
8364                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8365                    }
8366    
8367                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8368    
8369                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8370    
8371                    if (!getDB().isSupportsInlineDistinct()) {
8372                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8373                    }
8374    
8375                    if (orderByComparator != null) {
8376                            if (getDB().isSupportsInlineDistinct()) {
8377                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8378                                            orderByComparator);
8379                            }
8380                            else {
8381                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8382                                            orderByComparator);
8383                            }
8384                    }
8385    
8386                    else {
8387                            if (getDB().isSupportsInlineDistinct()) {
8388                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8389                            }
8390                            else {
8391                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8392                            }
8393                    }
8394    
8395                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8396                                    JournalArticle.class.getName(),
8397                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8398    
8399                    Session session = null;
8400    
8401                    try {
8402                            session = openSession();
8403    
8404                            SQLQuery q = session.createSQLQuery(sql);
8405    
8406                            if (getDB().isSupportsInlineDistinct()) {
8407                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8408                            }
8409                            else {
8410                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8411                            }
8412    
8413                            QueryPos qPos = QueryPos.getInstance(q);
8414    
8415                            qPos.add(groupId);
8416    
8417                            qPos.add(status);
8418    
8419                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
8420                                    end);
8421                    }
8422                    catch (Exception e) {
8423                            throw processException(e);
8424                    }
8425                    finally {
8426                            closeSession(session);
8427                    }
8428            }
8429    
8430            /**
8431             * 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;.
8432             *
8433             * @param id the primary key of the current journal article
8434             * @param groupId the group ID
8435             * @param status the status
8436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8437             * @return the previous, current, and next journal article
8438             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8439             * @throws SystemException if a system exception occurred
8440             */
8441            public JournalArticle[] filterFindByG_ST_PrevAndNext(long id, long groupId,
8442                    int status, OrderByComparator orderByComparator)
8443                    throws NoSuchArticleException, SystemException {
8444                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8445                            return findByG_ST_PrevAndNext(id, groupId, status, orderByComparator);
8446                    }
8447    
8448                    JournalArticle journalArticle = findByPrimaryKey(id);
8449    
8450                    Session session = null;
8451    
8452                    try {
8453                            session = openSession();
8454    
8455                            JournalArticle[] array = new JournalArticleImpl[3];
8456    
8457                            array[0] = filterGetByG_ST_PrevAndNext(session, journalArticle,
8458                                            groupId, status, orderByComparator, true);
8459    
8460                            array[1] = journalArticle;
8461    
8462                            array[2] = filterGetByG_ST_PrevAndNext(session, journalArticle,
8463                                            groupId, status, orderByComparator, false);
8464    
8465                            return array;
8466                    }
8467                    catch (Exception e) {
8468                            throw processException(e);
8469                    }
8470                    finally {
8471                            closeSession(session);
8472                    }
8473            }
8474    
8475            protected JournalArticle filterGetByG_ST_PrevAndNext(Session session,
8476                    JournalArticle journalArticle, long groupId, int status,
8477                    OrderByComparator orderByComparator, boolean previous) {
8478                    StringBundler query = null;
8479    
8480                    if (orderByComparator != null) {
8481                            query = new StringBundler(6 +
8482                                            (orderByComparator.getOrderByFields().length * 6));
8483                    }
8484                    else {
8485                            query = new StringBundler(3);
8486                    }
8487    
8488                    if (getDB().isSupportsInlineDistinct()) {
8489                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
8490                    }
8491                    else {
8492                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
8493                    }
8494    
8495                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
8496    
8497                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
8498    
8499                    if (!getDB().isSupportsInlineDistinct()) {
8500                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
8501                    }
8502    
8503                    if (orderByComparator != null) {
8504                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8505    
8506                            if (orderByConditionFields.length > 0) {
8507                                    query.append(WHERE_AND);
8508                            }
8509    
8510                            for (int i = 0; i < orderByConditionFields.length; i++) {
8511                                    if (getDB().isSupportsInlineDistinct()) {
8512                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8513                                    }
8514                                    else {
8515                                            query.append(_ORDER_BY_ENTITY_TABLE);
8516                                    }
8517    
8518                                    query.append(orderByConditionFields[i]);
8519    
8520                                    if ((i + 1) < orderByConditionFields.length) {
8521                                            if (orderByComparator.isAscending() ^ previous) {
8522                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8523                                            }
8524                                            else {
8525                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8526                                            }
8527                                    }
8528                                    else {
8529                                            if (orderByComparator.isAscending() ^ previous) {
8530                                                    query.append(WHERE_GREATER_THAN);
8531                                            }
8532                                            else {
8533                                                    query.append(WHERE_LESSER_THAN);
8534                                            }
8535                                    }
8536                            }
8537    
8538                            query.append(ORDER_BY_CLAUSE);
8539    
8540                            String[] orderByFields = orderByComparator.getOrderByFields();
8541    
8542                            for (int i = 0; i < orderByFields.length; i++) {
8543                                    if (getDB().isSupportsInlineDistinct()) {
8544                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8545                                    }
8546                                    else {
8547                                            query.append(_ORDER_BY_ENTITY_TABLE);
8548                                    }
8549    
8550                                    query.append(orderByFields[i]);
8551    
8552                                    if ((i + 1) < orderByFields.length) {
8553                                            if (orderByComparator.isAscending() ^ previous) {
8554                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8555                                            }
8556                                            else {
8557                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8558                                            }
8559                                    }
8560                                    else {
8561                                            if (orderByComparator.isAscending() ^ previous) {
8562                                                    query.append(ORDER_BY_ASC);
8563                                            }
8564                                            else {
8565                                                    query.append(ORDER_BY_DESC);
8566                                            }
8567                                    }
8568                            }
8569                    }
8570    
8571                    else {
8572                            if (getDB().isSupportsInlineDistinct()) {
8573                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8574                            }
8575                            else {
8576                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
8577                            }
8578                    }
8579    
8580                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8581                                    JournalArticle.class.getName(),
8582                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8583    
8584                    SQLQuery q = session.createSQLQuery(sql);
8585    
8586                    q.setFirstResult(0);
8587                    q.setMaxResults(2);
8588    
8589                    if (getDB().isSupportsInlineDistinct()) {
8590                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
8591                    }
8592                    else {
8593                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
8594                    }
8595    
8596                    QueryPos qPos = QueryPos.getInstance(q);
8597    
8598                    qPos.add(groupId);
8599    
8600                    qPos.add(status);
8601    
8602                    if (orderByComparator != null) {
8603                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8604    
8605                            for (Object value : values) {
8606                                    qPos.add(value);
8607                            }
8608                    }
8609    
8610                    List<JournalArticle> list = q.list();
8611    
8612                    if (list.size() == 2) {
8613                            return list.get(1);
8614                    }
8615                    else {
8616                            return null;
8617                    }
8618            }
8619    
8620            /**
8621             * Returns all the journal articles where companyId = &#63; and version = &#63;.
8622             *
8623             * @param companyId the company ID
8624             * @param version the version
8625             * @return the matching journal articles
8626             * @throws SystemException if a system exception occurred
8627             */
8628            public List<JournalArticle> findByC_V(long companyId, double version)
8629                    throws SystemException {
8630                    return findByC_V(companyId, version, QueryUtil.ALL_POS,
8631                            QueryUtil.ALL_POS, null);
8632            }
8633    
8634            /**
8635             * Returns a range of all the journal articles where companyId = &#63; and version = &#63;.
8636             *
8637             * <p>
8638             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8639             * </p>
8640             *
8641             * @param companyId the company ID
8642             * @param version the version
8643             * @param start the lower bound of the range of journal articles
8644             * @param end the upper bound of the range of journal articles (not inclusive)
8645             * @return the range of matching journal articles
8646             * @throws SystemException if a system exception occurred
8647             */
8648            public List<JournalArticle> findByC_V(long companyId, double version,
8649                    int start, int end) throws SystemException {
8650                    return findByC_V(companyId, version, start, end, null);
8651            }
8652    
8653            /**
8654             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63;.
8655             *
8656             * <p>
8657             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8658             * </p>
8659             *
8660             * @param companyId the company ID
8661             * @param version the version
8662             * @param start the lower bound of the range of journal articles
8663             * @param end the upper bound of the range of journal articles (not inclusive)
8664             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8665             * @return the ordered range of matching journal articles
8666             * @throws SystemException if a system exception occurred
8667             */
8668            public List<JournalArticle> findByC_V(long companyId, double version,
8669                    int start, int end, OrderByComparator orderByComparator)
8670                    throws SystemException {
8671                    FinderPath finderPath = null;
8672                    Object[] finderArgs = null;
8673    
8674                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8675                                    (orderByComparator == null)) {
8676                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V;
8677                            finderArgs = new Object[] { companyId, version };
8678                    }
8679                    else {
8680                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V;
8681                            finderArgs = new Object[] {
8682                                            companyId, version,
8683                                            
8684                                            start, end, orderByComparator
8685                                    };
8686                    }
8687    
8688                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
8689                                    finderArgs, this);
8690    
8691                    if (list == null) {
8692                            StringBundler query = null;
8693    
8694                            if (orderByComparator != null) {
8695                                    query = new StringBundler(4 +
8696                                                    (orderByComparator.getOrderByFields().length * 3));
8697                            }
8698                            else {
8699                                    query = new StringBundler(4);
8700                            }
8701    
8702                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8703    
8704                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
8705    
8706                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
8707    
8708                            if (orderByComparator != null) {
8709                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8710                                            orderByComparator);
8711                            }
8712    
8713                            else {
8714                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8715                            }
8716    
8717                            String sql = query.toString();
8718    
8719                            Session session = null;
8720    
8721                            try {
8722                                    session = openSession();
8723    
8724                                    Query q = session.createQuery(sql);
8725    
8726                                    QueryPos qPos = QueryPos.getInstance(q);
8727    
8728                                    qPos.add(companyId);
8729    
8730                                    qPos.add(version);
8731    
8732                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
8733                                                    start, end);
8734                            }
8735                            catch (Exception e) {
8736                                    throw processException(e);
8737                            }
8738                            finally {
8739                                    if (list == null) {
8740                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8741                                    }
8742                                    else {
8743                                            cacheResult(list);
8744    
8745                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8746                                    }
8747    
8748                                    closeSession(session);
8749                            }
8750                    }
8751    
8752                    return list;
8753            }
8754    
8755            /**
8756             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63;.
8757             *
8758             * <p>
8759             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8760             * </p>
8761             *
8762             * @param companyId the company ID
8763             * @param version the version
8764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8765             * @return the first matching journal article
8766             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8767             * @throws SystemException if a system exception occurred
8768             */
8769            public JournalArticle findByC_V_First(long companyId, double version,
8770                    OrderByComparator orderByComparator)
8771                    throws NoSuchArticleException, SystemException {
8772                    List<JournalArticle> list = findByC_V(companyId, version, 0, 1,
8773                                    orderByComparator);
8774    
8775                    if (list.isEmpty()) {
8776                            StringBundler msg = new StringBundler(6);
8777    
8778                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8779    
8780                            msg.append("companyId=");
8781                            msg.append(companyId);
8782    
8783                            msg.append(", version=");
8784                            msg.append(version);
8785    
8786                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8787    
8788                            throw new NoSuchArticleException(msg.toString());
8789                    }
8790                    else {
8791                            return list.get(0);
8792                    }
8793            }
8794    
8795            /**
8796             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63;.
8797             *
8798             * <p>
8799             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8800             * </p>
8801             *
8802             * @param companyId the company ID
8803             * @param version the version
8804             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8805             * @return the last matching journal article
8806             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
8807             * @throws SystemException if a system exception occurred
8808             */
8809            public JournalArticle findByC_V_Last(long companyId, double version,
8810                    OrderByComparator orderByComparator)
8811                    throws NoSuchArticleException, SystemException {
8812                    int count = countByC_V(companyId, version);
8813    
8814                    List<JournalArticle> list = findByC_V(companyId, version, count - 1,
8815                                    count, orderByComparator);
8816    
8817                    if (list.isEmpty()) {
8818                            StringBundler msg = new StringBundler(6);
8819    
8820                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8821    
8822                            msg.append("companyId=");
8823                            msg.append(companyId);
8824    
8825                            msg.append(", version=");
8826                            msg.append(version);
8827    
8828                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8829    
8830                            throw new NoSuchArticleException(msg.toString());
8831                    }
8832                    else {
8833                            return list.get(0);
8834                    }
8835            }
8836    
8837            /**
8838             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63;.
8839             *
8840             * <p>
8841             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8842             * </p>
8843             *
8844             * @param id the primary key of the current journal article
8845             * @param companyId the company ID
8846             * @param version the version
8847             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8848             * @return the previous, current, and next journal article
8849             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
8850             * @throws SystemException if a system exception occurred
8851             */
8852            public JournalArticle[] findByC_V_PrevAndNext(long id, long companyId,
8853                    double version, OrderByComparator orderByComparator)
8854                    throws NoSuchArticleException, SystemException {
8855                    JournalArticle journalArticle = findByPrimaryKey(id);
8856    
8857                    Session session = null;
8858    
8859                    try {
8860                            session = openSession();
8861    
8862                            JournalArticle[] array = new JournalArticleImpl[3];
8863    
8864                            array[0] = getByC_V_PrevAndNext(session, journalArticle, companyId,
8865                                            version, orderByComparator, true);
8866    
8867                            array[1] = journalArticle;
8868    
8869                            array[2] = getByC_V_PrevAndNext(session, journalArticle, companyId,
8870                                            version, orderByComparator, false);
8871    
8872                            return array;
8873                    }
8874                    catch (Exception e) {
8875                            throw processException(e);
8876                    }
8877                    finally {
8878                            closeSession(session);
8879                    }
8880            }
8881    
8882            protected JournalArticle getByC_V_PrevAndNext(Session session,
8883                    JournalArticle journalArticle, long companyId, double version,
8884                    OrderByComparator orderByComparator, boolean previous) {
8885                    StringBundler query = null;
8886    
8887                    if (orderByComparator != null) {
8888                            query = new StringBundler(6 +
8889                                            (orderByComparator.getOrderByFields().length * 6));
8890                    }
8891                    else {
8892                            query = new StringBundler(3);
8893                    }
8894    
8895                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
8896    
8897                    query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
8898    
8899                    query.append(_FINDER_COLUMN_C_V_VERSION_2);
8900    
8901                    if (orderByComparator != null) {
8902                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8903    
8904                            if (orderByConditionFields.length > 0) {
8905                                    query.append(WHERE_AND);
8906                            }
8907    
8908                            for (int i = 0; i < orderByConditionFields.length; i++) {
8909                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8910                                    query.append(orderByConditionFields[i]);
8911    
8912                                    if ((i + 1) < orderByConditionFields.length) {
8913                                            if (orderByComparator.isAscending() ^ previous) {
8914                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8915                                            }
8916                                            else {
8917                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8918                                            }
8919                                    }
8920                                    else {
8921                                            if (orderByComparator.isAscending() ^ previous) {
8922                                                    query.append(WHERE_GREATER_THAN);
8923                                            }
8924                                            else {
8925                                                    query.append(WHERE_LESSER_THAN);
8926                                            }
8927                                    }
8928                            }
8929    
8930                            query.append(ORDER_BY_CLAUSE);
8931    
8932                            String[] orderByFields = orderByComparator.getOrderByFields();
8933    
8934                            for (int i = 0; i < orderByFields.length; i++) {
8935                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8936                                    query.append(orderByFields[i]);
8937    
8938                                    if ((i + 1) < orderByFields.length) {
8939                                            if (orderByComparator.isAscending() ^ previous) {
8940                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8941                                            }
8942                                            else {
8943                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8944                                            }
8945                                    }
8946                                    else {
8947                                            if (orderByComparator.isAscending() ^ previous) {
8948                                                    query.append(ORDER_BY_ASC);
8949                                            }
8950                                            else {
8951                                                    query.append(ORDER_BY_DESC);
8952                                            }
8953                                    }
8954                            }
8955                    }
8956    
8957                    else {
8958                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
8959                    }
8960    
8961                    String sql = query.toString();
8962    
8963                    Query q = session.createQuery(sql);
8964    
8965                    q.setFirstResult(0);
8966                    q.setMaxResults(2);
8967    
8968                    QueryPos qPos = QueryPos.getInstance(q);
8969    
8970                    qPos.add(companyId);
8971    
8972                    qPos.add(version);
8973    
8974                    if (orderByComparator != null) {
8975                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
8976    
8977                            for (Object value : values) {
8978                                    qPos.add(value);
8979                            }
8980                    }
8981    
8982                    List<JournalArticle> list = q.list();
8983    
8984                    if (list.size() == 2) {
8985                            return list.get(1);
8986                    }
8987                    else {
8988                            return null;
8989                    }
8990            }
8991    
8992            /**
8993             * Returns all the journal articles where companyId = &#63; and status = &#63;.
8994             *
8995             * @param companyId the company ID
8996             * @param status the status
8997             * @return the matching journal articles
8998             * @throws SystemException if a system exception occurred
8999             */
9000            public List<JournalArticle> findByC_ST(long companyId, int status)
9001                    throws SystemException {
9002                    return findByC_ST(companyId, status, QueryUtil.ALL_POS,
9003                            QueryUtil.ALL_POS, null);
9004            }
9005    
9006            /**
9007             * Returns a range of all the journal articles where companyId = &#63; and status = &#63;.
9008             *
9009             * <p>
9010             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9011             * </p>
9012             *
9013             * @param companyId the company ID
9014             * @param status the status
9015             * @param start the lower bound of the range of journal articles
9016             * @param end the upper bound of the range of journal articles (not inclusive)
9017             * @return the range of matching journal articles
9018             * @throws SystemException if a system exception occurred
9019             */
9020            public List<JournalArticle> findByC_ST(long companyId, int status,
9021                    int start, int end) throws SystemException {
9022                    return findByC_ST(companyId, status, start, end, null);
9023            }
9024    
9025            /**
9026             * Returns an ordered range of all the journal articles where companyId = &#63; and status = &#63;.
9027             *
9028             * <p>
9029             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9030             * </p>
9031             *
9032             * @param companyId the company ID
9033             * @param status the status
9034             * @param start the lower bound of the range of journal articles
9035             * @param end the upper bound of the range of journal articles (not inclusive)
9036             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9037             * @return the ordered range of matching journal articles
9038             * @throws SystemException if a system exception occurred
9039             */
9040            public List<JournalArticle> findByC_ST(long companyId, int status,
9041                    int start, int end, OrderByComparator orderByComparator)
9042                    throws SystemException {
9043                    FinderPath finderPath = null;
9044                    Object[] finderArgs = null;
9045    
9046                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9047                                    (orderByComparator == null)) {
9048                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_ST;
9049                            finderArgs = new Object[] { companyId, status };
9050                    }
9051                    else {
9052                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_ST;
9053                            finderArgs = new Object[] {
9054                                            companyId, status,
9055                                            
9056                                            start, end, orderByComparator
9057                                    };
9058                    }
9059    
9060                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9061                                    finderArgs, this);
9062    
9063                    if (list == null) {
9064                            StringBundler query = null;
9065    
9066                            if (orderByComparator != null) {
9067                                    query = new StringBundler(4 +
9068                                                    (orderByComparator.getOrderByFields().length * 3));
9069                            }
9070                            else {
9071                                    query = new StringBundler(4);
9072                            }
9073    
9074                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9075    
9076                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
9077    
9078                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
9079    
9080                            if (orderByComparator != null) {
9081                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9082                                            orderByComparator);
9083                            }
9084    
9085                            else {
9086                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9087                            }
9088    
9089                            String sql = query.toString();
9090    
9091                            Session session = null;
9092    
9093                            try {
9094                                    session = openSession();
9095    
9096                                    Query q = session.createQuery(sql);
9097    
9098                                    QueryPos qPos = QueryPos.getInstance(q);
9099    
9100                                    qPos.add(companyId);
9101    
9102                                    qPos.add(status);
9103    
9104                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9105                                                    start, end);
9106                            }
9107                            catch (Exception e) {
9108                                    throw processException(e);
9109                            }
9110                            finally {
9111                                    if (list == null) {
9112                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9113                                    }
9114                                    else {
9115                                            cacheResult(list);
9116    
9117                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9118                                    }
9119    
9120                                    closeSession(session);
9121                            }
9122                    }
9123    
9124                    return list;
9125            }
9126    
9127            /**
9128             * Returns the first journal article in the ordered set where companyId = &#63; and status = &#63;.
9129             *
9130             * <p>
9131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9132             * </p>
9133             *
9134             * @param companyId the company ID
9135             * @param status the status
9136             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9137             * @return the first matching journal article
9138             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9139             * @throws SystemException if a system exception occurred
9140             */
9141            public JournalArticle findByC_ST_First(long companyId, int status,
9142                    OrderByComparator orderByComparator)
9143                    throws NoSuchArticleException, SystemException {
9144                    List<JournalArticle> list = findByC_ST(companyId, status, 0, 1,
9145                                    orderByComparator);
9146    
9147                    if (list.isEmpty()) {
9148                            StringBundler msg = new StringBundler(6);
9149    
9150                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9151    
9152                            msg.append("companyId=");
9153                            msg.append(companyId);
9154    
9155                            msg.append(", status=");
9156                            msg.append(status);
9157    
9158                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9159    
9160                            throw new NoSuchArticleException(msg.toString());
9161                    }
9162                    else {
9163                            return list.get(0);
9164                    }
9165            }
9166    
9167            /**
9168             * Returns the last journal article in the ordered set where companyId = &#63; and status = &#63;.
9169             *
9170             * <p>
9171             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9172             * </p>
9173             *
9174             * @param companyId the company ID
9175             * @param status the status
9176             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9177             * @return the last matching journal article
9178             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9179             * @throws SystemException if a system exception occurred
9180             */
9181            public JournalArticle findByC_ST_Last(long companyId, int status,
9182                    OrderByComparator orderByComparator)
9183                    throws NoSuchArticleException, SystemException {
9184                    int count = countByC_ST(companyId, status);
9185    
9186                    List<JournalArticle> list = findByC_ST(companyId, status, count - 1,
9187                                    count, orderByComparator);
9188    
9189                    if (list.isEmpty()) {
9190                            StringBundler msg = new StringBundler(6);
9191    
9192                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9193    
9194                            msg.append("companyId=");
9195                            msg.append(companyId);
9196    
9197                            msg.append(", status=");
9198                            msg.append(status);
9199    
9200                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9201    
9202                            throw new NoSuchArticleException(msg.toString());
9203                    }
9204                    else {
9205                            return list.get(0);
9206                    }
9207            }
9208    
9209            /**
9210             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and status = &#63;.
9211             *
9212             * <p>
9213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9214             * </p>
9215             *
9216             * @param id the primary key of the current journal article
9217             * @param companyId the company ID
9218             * @param status the status
9219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9220             * @return the previous, current, and next journal article
9221             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9222             * @throws SystemException if a system exception occurred
9223             */
9224            public JournalArticle[] findByC_ST_PrevAndNext(long id, long companyId,
9225                    int status, OrderByComparator orderByComparator)
9226                    throws NoSuchArticleException, SystemException {
9227                    JournalArticle journalArticle = findByPrimaryKey(id);
9228    
9229                    Session session = null;
9230    
9231                    try {
9232                            session = openSession();
9233    
9234                            JournalArticle[] array = new JournalArticleImpl[3];
9235    
9236                            array[0] = getByC_ST_PrevAndNext(session, journalArticle,
9237                                            companyId, status, orderByComparator, true);
9238    
9239                            array[1] = journalArticle;
9240    
9241                            array[2] = getByC_ST_PrevAndNext(session, journalArticle,
9242                                            companyId, status, orderByComparator, false);
9243    
9244                            return array;
9245                    }
9246                    catch (Exception e) {
9247                            throw processException(e);
9248                    }
9249                    finally {
9250                            closeSession(session);
9251                    }
9252            }
9253    
9254            protected JournalArticle getByC_ST_PrevAndNext(Session session,
9255                    JournalArticle journalArticle, long companyId, int status,
9256                    OrderByComparator orderByComparator, boolean previous) {
9257                    StringBundler query = null;
9258    
9259                    if (orderByComparator != null) {
9260                            query = new StringBundler(6 +
9261                                            (orderByComparator.getOrderByFields().length * 6));
9262                    }
9263                    else {
9264                            query = new StringBundler(3);
9265                    }
9266    
9267                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9268    
9269                    query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
9270    
9271                    query.append(_FINDER_COLUMN_C_ST_STATUS_2);
9272    
9273                    if (orderByComparator != null) {
9274                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9275    
9276                            if (orderByConditionFields.length > 0) {
9277                                    query.append(WHERE_AND);
9278                            }
9279    
9280                            for (int i = 0; i < orderByConditionFields.length; i++) {
9281                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9282                                    query.append(orderByConditionFields[i]);
9283    
9284                                    if ((i + 1) < orderByConditionFields.length) {
9285                                            if (orderByComparator.isAscending() ^ previous) {
9286                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9287                                            }
9288                                            else {
9289                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9290                                            }
9291                                    }
9292                                    else {
9293                                            if (orderByComparator.isAscending() ^ previous) {
9294                                                    query.append(WHERE_GREATER_THAN);
9295                                            }
9296                                            else {
9297                                                    query.append(WHERE_LESSER_THAN);
9298                                            }
9299                                    }
9300                            }
9301    
9302                            query.append(ORDER_BY_CLAUSE);
9303    
9304                            String[] orderByFields = orderByComparator.getOrderByFields();
9305    
9306                            for (int i = 0; i < orderByFields.length; i++) {
9307                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9308                                    query.append(orderByFields[i]);
9309    
9310                                    if ((i + 1) < orderByFields.length) {
9311                                            if (orderByComparator.isAscending() ^ previous) {
9312                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9313                                            }
9314                                            else {
9315                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9316                                            }
9317                                    }
9318                                    else {
9319                                            if (orderByComparator.isAscending() ^ previous) {
9320                                                    query.append(ORDER_BY_ASC);
9321                                            }
9322                                            else {
9323                                                    query.append(ORDER_BY_DESC);
9324                                            }
9325                                    }
9326                            }
9327                    }
9328    
9329                    else {
9330                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9331                    }
9332    
9333                    String sql = query.toString();
9334    
9335                    Query q = session.createQuery(sql);
9336    
9337                    q.setFirstResult(0);
9338                    q.setMaxResults(2);
9339    
9340                    QueryPos qPos = QueryPos.getInstance(q);
9341    
9342                    qPos.add(companyId);
9343    
9344                    qPos.add(status);
9345    
9346                    if (orderByComparator != null) {
9347                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9348    
9349                            for (Object value : values) {
9350                                    qPos.add(value);
9351                            }
9352                    }
9353    
9354                    List<JournalArticle> list = q.list();
9355    
9356                    if (list.size() == 2) {
9357                            return list.get(1);
9358                    }
9359                    else {
9360                            return null;
9361                    }
9362            }
9363    
9364            /**
9365             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9366             *
9367             * @param groupId the group ID
9368             * @param classNameId the class name ID
9369             * @param classPK the class p k
9370             * @return the matching journal articles
9371             * @throws SystemException if a system exception occurred
9372             */
9373            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
9374                    long classPK) throws SystemException {
9375                    return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
9376                            QueryUtil.ALL_POS, null);
9377            }
9378    
9379            /**
9380             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9381             *
9382             * <p>
9383             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9384             * </p>
9385             *
9386             * @param groupId the group ID
9387             * @param classNameId the class name ID
9388             * @param classPK the class p k
9389             * @param start the lower bound of the range of journal articles
9390             * @param end the upper bound of the range of journal articles (not inclusive)
9391             * @return the range of matching journal articles
9392             * @throws SystemException if a system exception occurred
9393             */
9394            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
9395                    long classPK, int start, int end) throws SystemException {
9396                    return findByG_C_C(groupId, classNameId, classPK, start, end, null);
9397            }
9398    
9399            /**
9400             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9401             *
9402             * <p>
9403             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9404             * </p>
9405             *
9406             * @param groupId the group ID
9407             * @param classNameId the class name ID
9408             * @param classPK the class p k
9409             * @param start the lower bound of the range of journal articles
9410             * @param end the upper bound of the range of journal articles (not inclusive)
9411             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9412             * @return the ordered range of matching journal articles
9413             * @throws SystemException if a system exception occurred
9414             */
9415            public List<JournalArticle> findByG_C_C(long groupId, long classNameId,
9416                    long classPK, int start, int end, OrderByComparator orderByComparator)
9417                    throws SystemException {
9418                    FinderPath finderPath = null;
9419                    Object[] finderArgs = null;
9420    
9421                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9422                                    (orderByComparator == null)) {
9423                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
9424                            finderArgs = new Object[] { groupId, classNameId, classPK };
9425                    }
9426                    else {
9427                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
9428                            finderArgs = new Object[] {
9429                                            groupId, classNameId, classPK,
9430                                            
9431                                            start, end, orderByComparator
9432                                    };
9433                    }
9434    
9435                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
9436                                    finderArgs, this);
9437    
9438                    if (list == null) {
9439                            StringBundler query = null;
9440    
9441                            if (orderByComparator != null) {
9442                                    query = new StringBundler(5 +
9443                                                    (orderByComparator.getOrderByFields().length * 3));
9444                            }
9445                            else {
9446                                    query = new StringBundler(5);
9447                            }
9448    
9449                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9450    
9451                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9452    
9453                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9454    
9455                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9456    
9457                            if (orderByComparator != null) {
9458                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9459                                            orderByComparator);
9460                            }
9461    
9462                            else {
9463                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9464                            }
9465    
9466                            String sql = query.toString();
9467    
9468                            Session session = null;
9469    
9470                            try {
9471                                    session = openSession();
9472    
9473                                    Query q = session.createQuery(sql);
9474    
9475                                    QueryPos qPos = QueryPos.getInstance(q);
9476    
9477                                    qPos.add(groupId);
9478    
9479                                    qPos.add(classNameId);
9480    
9481                                    qPos.add(classPK);
9482    
9483                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
9484                                                    start, end);
9485                            }
9486                            catch (Exception e) {
9487                                    throw processException(e);
9488                            }
9489                            finally {
9490                                    if (list == null) {
9491                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9492                                    }
9493                                    else {
9494                                            cacheResult(list);
9495    
9496                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9497                                    }
9498    
9499                                    closeSession(session);
9500                            }
9501                    }
9502    
9503                    return list;
9504            }
9505    
9506            /**
9507             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9508             *
9509             * <p>
9510             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9511             * </p>
9512             *
9513             * @param groupId the group ID
9514             * @param classNameId the class name ID
9515             * @param classPK the class p k
9516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9517             * @return the first matching journal article
9518             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9519             * @throws SystemException if a system exception occurred
9520             */
9521            public JournalArticle findByG_C_C_First(long groupId, long classNameId,
9522                    long classPK, OrderByComparator orderByComparator)
9523                    throws NoSuchArticleException, SystemException {
9524                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
9525                                    0, 1, orderByComparator);
9526    
9527                    if (list.isEmpty()) {
9528                            StringBundler msg = new StringBundler(8);
9529    
9530                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9531    
9532                            msg.append("groupId=");
9533                            msg.append(groupId);
9534    
9535                            msg.append(", classNameId=");
9536                            msg.append(classNameId);
9537    
9538                            msg.append(", classPK=");
9539                            msg.append(classPK);
9540    
9541                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9542    
9543                            throw new NoSuchArticleException(msg.toString());
9544                    }
9545                    else {
9546                            return list.get(0);
9547                    }
9548            }
9549    
9550            /**
9551             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9552             *
9553             * <p>
9554             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9555             * </p>
9556             *
9557             * @param groupId the group ID
9558             * @param classNameId the class name ID
9559             * @param classPK the class p k
9560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9561             * @return the last matching journal article
9562             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
9563             * @throws SystemException if a system exception occurred
9564             */
9565            public JournalArticle findByG_C_C_Last(long groupId, long classNameId,
9566                    long classPK, OrderByComparator orderByComparator)
9567                    throws NoSuchArticleException, SystemException {
9568                    int count = countByG_C_C(groupId, classNameId, classPK);
9569    
9570                    List<JournalArticle> list = findByG_C_C(groupId, classNameId, classPK,
9571                                    count - 1, count, orderByComparator);
9572    
9573                    if (list.isEmpty()) {
9574                            StringBundler msg = new StringBundler(8);
9575    
9576                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9577    
9578                            msg.append("groupId=");
9579                            msg.append(groupId);
9580    
9581                            msg.append(", classNameId=");
9582                            msg.append(classNameId);
9583    
9584                            msg.append(", classPK=");
9585                            msg.append(classPK);
9586    
9587                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9588    
9589                            throw new NoSuchArticleException(msg.toString());
9590                    }
9591                    else {
9592                            return list.get(0);
9593                    }
9594            }
9595    
9596            /**
9597             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9598             *
9599             * <p>
9600             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9601             * </p>
9602             *
9603             * @param id the primary key of the current journal article
9604             * @param groupId the group ID
9605             * @param classNameId the class name ID
9606             * @param classPK the class p k
9607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9608             * @return the previous, current, and next journal article
9609             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9610             * @throws SystemException if a system exception occurred
9611             */
9612            public JournalArticle[] findByG_C_C_PrevAndNext(long id, long groupId,
9613                    long classNameId, long classPK, OrderByComparator orderByComparator)
9614                    throws NoSuchArticleException, SystemException {
9615                    JournalArticle journalArticle = findByPrimaryKey(id);
9616    
9617                    Session session = null;
9618    
9619                    try {
9620                            session = openSession();
9621    
9622                            JournalArticle[] array = new JournalArticleImpl[3];
9623    
9624                            array[0] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
9625                                            classNameId, classPK, orderByComparator, true);
9626    
9627                            array[1] = journalArticle;
9628    
9629                            array[2] = getByG_C_C_PrevAndNext(session, journalArticle, groupId,
9630                                            classNameId, classPK, orderByComparator, false);
9631    
9632                            return array;
9633                    }
9634                    catch (Exception e) {
9635                            throw processException(e);
9636                    }
9637                    finally {
9638                            closeSession(session);
9639                    }
9640            }
9641    
9642            protected JournalArticle getByG_C_C_PrevAndNext(Session session,
9643                    JournalArticle journalArticle, long groupId, long classNameId,
9644                    long classPK, OrderByComparator orderByComparator, boolean previous) {
9645                    StringBundler query = null;
9646    
9647                    if (orderByComparator != null) {
9648                            query = new StringBundler(6 +
9649                                            (orderByComparator.getOrderByFields().length * 6));
9650                    }
9651                    else {
9652                            query = new StringBundler(3);
9653                    }
9654    
9655                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
9656    
9657                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9658    
9659                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9660    
9661                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9662    
9663                    if (orderByComparator != null) {
9664                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9665    
9666                            if (orderByConditionFields.length > 0) {
9667                                    query.append(WHERE_AND);
9668                            }
9669    
9670                            for (int i = 0; i < orderByConditionFields.length; i++) {
9671                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9672                                    query.append(orderByConditionFields[i]);
9673    
9674                                    if ((i + 1) < orderByConditionFields.length) {
9675                                            if (orderByComparator.isAscending() ^ previous) {
9676                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9677                                            }
9678                                            else {
9679                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9680                                            }
9681                                    }
9682                                    else {
9683                                            if (orderByComparator.isAscending() ^ previous) {
9684                                                    query.append(WHERE_GREATER_THAN);
9685                                            }
9686                                            else {
9687                                                    query.append(WHERE_LESSER_THAN);
9688                                            }
9689                                    }
9690                            }
9691    
9692                            query.append(ORDER_BY_CLAUSE);
9693    
9694                            String[] orderByFields = orderByComparator.getOrderByFields();
9695    
9696                            for (int i = 0; i < orderByFields.length; i++) {
9697                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9698                                    query.append(orderByFields[i]);
9699    
9700                                    if ((i + 1) < orderByFields.length) {
9701                                            if (orderByComparator.isAscending() ^ previous) {
9702                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9703                                            }
9704                                            else {
9705                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9706                                            }
9707                                    }
9708                                    else {
9709                                            if (orderByComparator.isAscending() ^ previous) {
9710                                                    query.append(ORDER_BY_ASC);
9711                                            }
9712                                            else {
9713                                                    query.append(ORDER_BY_DESC);
9714                                            }
9715                                    }
9716                            }
9717                    }
9718    
9719                    else {
9720                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9721                    }
9722    
9723                    String sql = query.toString();
9724    
9725                    Query q = session.createQuery(sql);
9726    
9727                    q.setFirstResult(0);
9728                    q.setMaxResults(2);
9729    
9730                    QueryPos qPos = QueryPos.getInstance(q);
9731    
9732                    qPos.add(groupId);
9733    
9734                    qPos.add(classNameId);
9735    
9736                    qPos.add(classPK);
9737    
9738                    if (orderByComparator != null) {
9739                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
9740    
9741                            for (Object value : values) {
9742                                    qPos.add(value);
9743                            }
9744                    }
9745    
9746                    List<JournalArticle> list = q.list();
9747    
9748                    if (list.size() == 2) {
9749                            return list.get(1);
9750                    }
9751                    else {
9752                            return null;
9753                    }
9754            }
9755    
9756            /**
9757             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9758             *
9759             * @param groupId the group ID
9760             * @param classNameId the class name ID
9761             * @param classPK the class p k
9762             * @return the matching journal articles that the user has permission to view
9763             * @throws SystemException if a system exception occurred
9764             */
9765            public List<JournalArticle> filterFindByG_C_C(long groupId,
9766                    long classNameId, long classPK) throws SystemException {
9767                    return filterFindByG_C_C(groupId, classNameId, classPK,
9768                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9769            }
9770    
9771            /**
9772             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
9773             *
9774             * <p>
9775             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9776             * </p>
9777             *
9778             * @param groupId the group ID
9779             * @param classNameId the class name ID
9780             * @param classPK the class p k
9781             * @param start the lower bound of the range of journal articles
9782             * @param end the upper bound of the range of journal articles (not inclusive)
9783             * @return the range of matching journal articles that the user has permission to view
9784             * @throws SystemException if a system exception occurred
9785             */
9786            public List<JournalArticle> filterFindByG_C_C(long groupId,
9787                    long classNameId, long classPK, int start, int end)
9788                    throws SystemException {
9789                    return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
9790            }
9791    
9792            /**
9793             * 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;.
9794             *
9795             * <p>
9796             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9797             * </p>
9798             *
9799             * @param groupId the group ID
9800             * @param classNameId the class name ID
9801             * @param classPK the class p k
9802             * @param start the lower bound of the range of journal articles
9803             * @param end the upper bound of the range of journal articles (not inclusive)
9804             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9805             * @return the ordered range of matching journal articles that the user has permission to view
9806             * @throws SystemException if a system exception occurred
9807             */
9808            public List<JournalArticle> filterFindByG_C_C(long groupId,
9809                    long classNameId, long classPK, int start, int end,
9810                    OrderByComparator orderByComparator) throws SystemException {
9811                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9812                            return findByG_C_C(groupId, classNameId, classPK, start, end,
9813                                    orderByComparator);
9814                    }
9815    
9816                    StringBundler query = null;
9817    
9818                    if (orderByComparator != null) {
9819                            query = new StringBundler(5 +
9820                                            (orderByComparator.getOrderByFields().length * 3));
9821                    }
9822                    else {
9823                            query = new StringBundler(5);
9824                    }
9825    
9826                    if (getDB().isSupportsInlineDistinct()) {
9827                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9828                    }
9829                    else {
9830                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9831                    }
9832    
9833                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9834    
9835                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9836    
9837                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9838    
9839                    if (!getDB().isSupportsInlineDistinct()) {
9840                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9841                    }
9842    
9843                    if (orderByComparator != null) {
9844                            if (getDB().isSupportsInlineDistinct()) {
9845                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9846                                            orderByComparator);
9847                            }
9848                            else {
9849                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9850                                            orderByComparator);
9851                            }
9852                    }
9853    
9854                    else {
9855                            if (getDB().isSupportsInlineDistinct()) {
9856                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
9857                            }
9858                            else {
9859                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
9860                            }
9861                    }
9862    
9863                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9864                                    JournalArticle.class.getName(),
9865                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9866    
9867                    Session session = null;
9868    
9869                    try {
9870                            session = openSession();
9871    
9872                            SQLQuery q = session.createSQLQuery(sql);
9873    
9874                            if (getDB().isSupportsInlineDistinct()) {
9875                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
9876                            }
9877                            else {
9878                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
9879                            }
9880    
9881                            QueryPos qPos = QueryPos.getInstance(q);
9882    
9883                            qPos.add(groupId);
9884    
9885                            qPos.add(classNameId);
9886    
9887                            qPos.add(classPK);
9888    
9889                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
9890                                    end);
9891                    }
9892                    catch (Exception e) {
9893                            throw processException(e);
9894                    }
9895                    finally {
9896                            closeSession(session);
9897                    }
9898            }
9899    
9900            /**
9901             * 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;.
9902             *
9903             * @param id the primary key of the current journal article
9904             * @param groupId the group ID
9905             * @param classNameId the class name ID
9906             * @param classPK the class p k
9907             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9908             * @return the previous, current, and next journal article
9909             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
9910             * @throws SystemException if a system exception occurred
9911             */
9912            public JournalArticle[] filterFindByG_C_C_PrevAndNext(long id,
9913                    long groupId, long classNameId, long classPK,
9914                    OrderByComparator orderByComparator)
9915                    throws NoSuchArticleException, SystemException {
9916                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9917                            return findByG_C_C_PrevAndNext(id, groupId, classNameId, classPK,
9918                                    orderByComparator);
9919                    }
9920    
9921                    JournalArticle journalArticle = findByPrimaryKey(id);
9922    
9923                    Session session = null;
9924    
9925                    try {
9926                            session = openSession();
9927    
9928                            JournalArticle[] array = new JournalArticleImpl[3];
9929    
9930                            array[0] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
9931                                            groupId, classNameId, classPK, orderByComparator, true);
9932    
9933                            array[1] = journalArticle;
9934    
9935                            array[2] = filterGetByG_C_C_PrevAndNext(session, journalArticle,
9936                                            groupId, classNameId, classPK, orderByComparator, false);
9937    
9938                            return array;
9939                    }
9940                    catch (Exception e) {
9941                            throw processException(e);
9942                    }
9943                    finally {
9944                            closeSession(session);
9945                    }
9946            }
9947    
9948            protected JournalArticle filterGetByG_C_C_PrevAndNext(Session session,
9949                    JournalArticle journalArticle, long groupId, long classNameId,
9950                    long classPK, OrderByComparator orderByComparator, boolean previous) {
9951                    StringBundler query = null;
9952    
9953                    if (orderByComparator != null) {
9954                            query = new StringBundler(6 +
9955                                            (orderByComparator.getOrderByFields().length * 6));
9956                    }
9957                    else {
9958                            query = new StringBundler(3);
9959                    }
9960    
9961                    if (getDB().isSupportsInlineDistinct()) {
9962                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
9963                    }
9964                    else {
9965                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
9966                    }
9967    
9968                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
9969    
9970                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
9971    
9972                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
9973    
9974                    if (!getDB().isSupportsInlineDistinct()) {
9975                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
9976                    }
9977    
9978                    if (orderByComparator != null) {
9979                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9980    
9981                            if (orderByConditionFields.length > 0) {
9982                                    query.append(WHERE_AND);
9983                            }
9984    
9985                            for (int i = 0; i < orderByConditionFields.length; i++) {
9986                                    if (getDB().isSupportsInlineDistinct()) {
9987                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9988                                    }
9989                                    else {
9990                                            query.append(_ORDER_BY_ENTITY_TABLE);
9991                                    }
9992    
9993                                    query.append(orderByConditionFields[i]);
9994    
9995                                    if ((i + 1) < orderByConditionFields.length) {
9996                                            if (orderByComparator.isAscending() ^ previous) {
9997                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9998                                            }
9999                                            else {
10000                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10001                                            }
10002                                    }
10003                                    else {
10004                                            if (orderByComparator.isAscending() ^ previous) {
10005                                                    query.append(WHERE_GREATER_THAN);
10006                                            }
10007                                            else {
10008                                                    query.append(WHERE_LESSER_THAN);
10009                                            }
10010                                    }
10011                            }
10012    
10013                            query.append(ORDER_BY_CLAUSE);
10014    
10015                            String[] orderByFields = orderByComparator.getOrderByFields();
10016    
10017                            for (int i = 0; i < orderByFields.length; i++) {
10018                                    if (getDB().isSupportsInlineDistinct()) {
10019                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10020                                    }
10021                                    else {
10022                                            query.append(_ORDER_BY_ENTITY_TABLE);
10023                                    }
10024    
10025                                    query.append(orderByFields[i]);
10026    
10027                                    if ((i + 1) < orderByFields.length) {
10028                                            if (orderByComparator.isAscending() ^ previous) {
10029                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10030                                            }
10031                                            else {
10032                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10033                                            }
10034                                    }
10035                                    else {
10036                                            if (orderByComparator.isAscending() ^ previous) {
10037                                                    query.append(ORDER_BY_ASC);
10038                                            }
10039                                            else {
10040                                                    query.append(ORDER_BY_DESC);
10041                                            }
10042                                    }
10043                            }
10044                    }
10045    
10046                    else {
10047                            if (getDB().isSupportsInlineDistinct()) {
10048                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10049                            }
10050                            else {
10051                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10052                            }
10053                    }
10054    
10055                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10056                                    JournalArticle.class.getName(),
10057                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10058    
10059                    SQLQuery q = session.createSQLQuery(sql);
10060    
10061                    q.setFirstResult(0);
10062                    q.setMaxResults(2);
10063    
10064                    if (getDB().isSupportsInlineDistinct()) {
10065                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10066                    }
10067                    else {
10068                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10069                    }
10070    
10071                    QueryPos qPos = QueryPos.getInstance(q);
10072    
10073                    qPos.add(groupId);
10074    
10075                    qPos.add(classNameId);
10076    
10077                    qPos.add(classPK);
10078    
10079                    if (orderByComparator != null) {
10080                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10081    
10082                            for (Object value : values) {
10083                                    qPos.add(value);
10084                            }
10085                    }
10086    
10087                    List<JournalArticle> list = q.list();
10088    
10089                    if (list.size() == 2) {
10090                            return list.get(1);
10091                    }
10092                    else {
10093                            return null;
10094                    }
10095            }
10096    
10097            /**
10098             * 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.
10099             *
10100             * @param groupId the group ID
10101             * @param classNameId the class name ID
10102             * @param structureId the structure ID
10103             * @return the matching journal article
10104             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10105             * @throws SystemException if a system exception occurred
10106             */
10107            public JournalArticle findByG_C_S(long groupId, long classNameId,
10108                    String structureId) throws NoSuchArticleException, SystemException {
10109                    JournalArticle journalArticle = fetchByG_C_S(groupId, classNameId,
10110                                    structureId);
10111    
10112                    if (journalArticle == null) {
10113                            StringBundler msg = new StringBundler(8);
10114    
10115                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10116    
10117                            msg.append("groupId=");
10118                            msg.append(groupId);
10119    
10120                            msg.append(", classNameId=");
10121                            msg.append(classNameId);
10122    
10123                            msg.append(", structureId=");
10124                            msg.append(structureId);
10125    
10126                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10127    
10128                            if (_log.isWarnEnabled()) {
10129                                    _log.warn(msg.toString());
10130                            }
10131    
10132                            throw new NoSuchArticleException(msg.toString());
10133                    }
10134    
10135                    return journalArticle;
10136            }
10137    
10138            /**
10139             * 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.
10140             *
10141             * @param groupId the group ID
10142             * @param classNameId the class name ID
10143             * @param structureId the structure ID
10144             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
10145             * @throws SystemException if a system exception occurred
10146             */
10147            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
10148                    String structureId) throws SystemException {
10149                    return fetchByG_C_S(groupId, classNameId, structureId, true);
10150            }
10151    
10152            /**
10153             * 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.
10154             *
10155             * @param groupId the group ID
10156             * @param classNameId the class name ID
10157             * @param structureId the structure ID
10158             * @param retrieveFromCache whether to use the finder cache
10159             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
10160             * @throws SystemException if a system exception occurred
10161             */
10162            public JournalArticle fetchByG_C_S(long groupId, long classNameId,
10163                    String structureId, boolean retrieveFromCache)
10164                    throws SystemException {
10165                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
10166    
10167                    Object result = null;
10168    
10169                    if (retrieveFromCache) {
10170                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_S,
10171                                            finderArgs, this);
10172                    }
10173    
10174                    if (result == null) {
10175                            StringBundler query = new StringBundler(5);
10176    
10177                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10178    
10179                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
10180    
10181                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
10182    
10183                            if (structureId == null) {
10184                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
10185                            }
10186                            else {
10187                                    if (structureId.equals(StringPool.BLANK)) {
10188                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
10189                                    }
10190                                    else {
10191                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
10192                                    }
10193                            }
10194    
10195                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10196    
10197                            String sql = query.toString();
10198    
10199                            Session session = null;
10200    
10201                            try {
10202                                    session = openSession();
10203    
10204                                    Query q = session.createQuery(sql);
10205    
10206                                    QueryPos qPos = QueryPos.getInstance(q);
10207    
10208                                    qPos.add(groupId);
10209    
10210                                    qPos.add(classNameId);
10211    
10212                                    if (structureId != null) {
10213                                            qPos.add(structureId);
10214                                    }
10215    
10216                                    List<JournalArticle> list = q.list();
10217    
10218                                    result = list;
10219    
10220                                    JournalArticle journalArticle = null;
10221    
10222                                    if (list.isEmpty()) {
10223                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
10224                                                    finderArgs, list);
10225                                    }
10226                                    else {
10227                                            journalArticle = list.get(0);
10228    
10229                                            cacheResult(journalArticle);
10230    
10231                                            if ((journalArticle.getGroupId() != groupId) ||
10232                                                            (journalArticle.getClassNameId() != classNameId) ||
10233                                                            (journalArticle.getStructureId() == null) ||
10234                                                            !journalArticle.getStructureId().equals(structureId)) {
10235                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_S,
10236                                                            finderArgs, journalArticle);
10237                                            }
10238                                    }
10239    
10240                                    return journalArticle;
10241                            }
10242                            catch (Exception e) {
10243                                    throw processException(e);
10244                            }
10245                            finally {
10246                                    if (result == null) {
10247                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_S,
10248                                                    finderArgs);
10249                                    }
10250    
10251                                    closeSession(session);
10252                            }
10253                    }
10254                    else {
10255                            if (result instanceof List<?>) {
10256                                    return null;
10257                            }
10258                            else {
10259                                    return (JournalArticle)result;
10260                            }
10261                    }
10262            }
10263    
10264            /**
10265             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10266             *
10267             * @param groupId the group ID
10268             * @param classNameId the class name ID
10269             * @param templateId the template ID
10270             * @return the matching journal articles
10271             * @throws SystemException if a system exception occurred
10272             */
10273            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
10274                    String templateId) throws SystemException {
10275                    return findByG_C_T(groupId, classNameId, templateId, QueryUtil.ALL_POS,
10276                            QueryUtil.ALL_POS, null);
10277            }
10278    
10279            /**
10280             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10281             *
10282             * <p>
10283             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10284             * </p>
10285             *
10286             * @param groupId the group ID
10287             * @param classNameId the class name ID
10288             * @param templateId the template ID
10289             * @param start the lower bound of the range of journal articles
10290             * @param end the upper bound of the range of journal articles (not inclusive)
10291             * @return the range of matching journal articles
10292             * @throws SystemException if a system exception occurred
10293             */
10294            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
10295                    String templateId, int start, int end) throws SystemException {
10296                    return findByG_C_T(groupId, classNameId, templateId, start, end, null);
10297            }
10298    
10299            /**
10300             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10301             *
10302             * <p>
10303             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10304             * </p>
10305             *
10306             * @param groupId the group ID
10307             * @param classNameId the class name ID
10308             * @param templateId the template ID
10309             * @param start the lower bound of the range of journal articles
10310             * @param end the upper bound of the range of journal articles (not inclusive)
10311             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10312             * @return the ordered range of matching journal articles
10313             * @throws SystemException if a system exception occurred
10314             */
10315            public List<JournalArticle> findByG_C_T(long groupId, long classNameId,
10316                    String templateId, int start, int end,
10317                    OrderByComparator orderByComparator) throws SystemException {
10318                    FinderPath finderPath = null;
10319                    Object[] finderArgs = null;
10320    
10321                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10322                                    (orderByComparator == null)) {
10323                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_T;
10324                            finderArgs = new Object[] { groupId, classNameId, templateId };
10325                    }
10326                    else {
10327                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_T;
10328                            finderArgs = new Object[] {
10329                                            groupId, classNameId, templateId,
10330                                            
10331                                            start, end, orderByComparator
10332                                    };
10333                    }
10334    
10335                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
10336                                    finderArgs, this);
10337    
10338                    if (list == null) {
10339                            StringBundler query = null;
10340    
10341                            if (orderByComparator != null) {
10342                                    query = new StringBundler(5 +
10343                                                    (orderByComparator.getOrderByFields().length * 3));
10344                            }
10345                            else {
10346                                    query = new StringBundler(5);
10347                            }
10348    
10349                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10350    
10351                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10352    
10353                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10354    
10355                            if (templateId == null) {
10356                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10357                            }
10358                            else {
10359                                    if (templateId.equals(StringPool.BLANK)) {
10360                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10361                                    }
10362                                    else {
10363                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10364                                    }
10365                            }
10366    
10367                            if (orderByComparator != null) {
10368                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10369                                            orderByComparator);
10370                            }
10371    
10372                            else {
10373                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10374                            }
10375    
10376                            String sql = query.toString();
10377    
10378                            Session session = null;
10379    
10380                            try {
10381                                    session = openSession();
10382    
10383                                    Query q = session.createQuery(sql);
10384    
10385                                    QueryPos qPos = QueryPos.getInstance(q);
10386    
10387                                    qPos.add(groupId);
10388    
10389                                    qPos.add(classNameId);
10390    
10391                                    if (templateId != null) {
10392                                            qPos.add(templateId);
10393                                    }
10394    
10395                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
10396                                                    start, end);
10397                            }
10398                            catch (Exception e) {
10399                                    throw processException(e);
10400                            }
10401                            finally {
10402                                    if (list == null) {
10403                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10404                                    }
10405                                    else {
10406                                            cacheResult(list);
10407    
10408                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10409                                    }
10410    
10411                                    closeSession(session);
10412                            }
10413                    }
10414    
10415                    return list;
10416            }
10417    
10418            /**
10419             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10420             *
10421             * <p>
10422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10423             * </p>
10424             *
10425             * @param groupId the group ID
10426             * @param classNameId the class name ID
10427             * @param templateId the template ID
10428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10429             * @return the first matching journal article
10430             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10431             * @throws SystemException if a system exception occurred
10432             */
10433            public JournalArticle findByG_C_T_First(long groupId, long classNameId,
10434                    String templateId, OrderByComparator orderByComparator)
10435                    throws NoSuchArticleException, SystemException {
10436                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
10437                                    templateId, 0, 1, orderByComparator);
10438    
10439                    if (list.isEmpty()) {
10440                            StringBundler msg = new StringBundler(8);
10441    
10442                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10443    
10444                            msg.append("groupId=");
10445                            msg.append(groupId);
10446    
10447                            msg.append(", classNameId=");
10448                            msg.append(classNameId);
10449    
10450                            msg.append(", templateId=");
10451                            msg.append(templateId);
10452    
10453                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10454    
10455                            throw new NoSuchArticleException(msg.toString());
10456                    }
10457                    else {
10458                            return list.get(0);
10459                    }
10460            }
10461    
10462            /**
10463             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10464             *
10465             * <p>
10466             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10467             * </p>
10468             *
10469             * @param groupId the group ID
10470             * @param classNameId the class name ID
10471             * @param templateId the template ID
10472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10473             * @return the last matching journal article
10474             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
10475             * @throws SystemException if a system exception occurred
10476             */
10477            public JournalArticle findByG_C_T_Last(long groupId, long classNameId,
10478                    String templateId, OrderByComparator orderByComparator)
10479                    throws NoSuchArticleException, SystemException {
10480                    int count = countByG_C_T(groupId, classNameId, templateId);
10481    
10482                    List<JournalArticle> list = findByG_C_T(groupId, classNameId,
10483                                    templateId, count - 1, count, orderByComparator);
10484    
10485                    if (list.isEmpty()) {
10486                            StringBundler msg = new StringBundler(8);
10487    
10488                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10489    
10490                            msg.append("groupId=");
10491                            msg.append(groupId);
10492    
10493                            msg.append(", classNameId=");
10494                            msg.append(classNameId);
10495    
10496                            msg.append(", templateId=");
10497                            msg.append(templateId);
10498    
10499                            msg.append(StringPool.CLOSE_CURLY_BRACE);
10500    
10501                            throw new NoSuchArticleException(msg.toString());
10502                    }
10503                    else {
10504                            return list.get(0);
10505                    }
10506            }
10507    
10508            /**
10509             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10510             *
10511             * <p>
10512             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10513             * </p>
10514             *
10515             * @param id the primary key of the current journal article
10516             * @param groupId the group ID
10517             * @param classNameId the class name ID
10518             * @param templateId the template ID
10519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10520             * @return the previous, current, and next journal article
10521             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10522             * @throws SystemException if a system exception occurred
10523             */
10524            public JournalArticle[] findByG_C_T_PrevAndNext(long id, long groupId,
10525                    long classNameId, String templateId, OrderByComparator orderByComparator)
10526                    throws NoSuchArticleException, SystemException {
10527                    JournalArticle journalArticle = findByPrimaryKey(id);
10528    
10529                    Session session = null;
10530    
10531                    try {
10532                            session = openSession();
10533    
10534                            JournalArticle[] array = new JournalArticleImpl[3];
10535    
10536                            array[0] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
10537                                            classNameId, templateId, orderByComparator, true);
10538    
10539                            array[1] = journalArticle;
10540    
10541                            array[2] = getByG_C_T_PrevAndNext(session, journalArticle, groupId,
10542                                            classNameId, templateId, orderByComparator, false);
10543    
10544                            return array;
10545                    }
10546                    catch (Exception e) {
10547                            throw processException(e);
10548                    }
10549                    finally {
10550                            closeSession(session);
10551                    }
10552            }
10553    
10554            protected JournalArticle getByG_C_T_PrevAndNext(Session session,
10555                    JournalArticle journalArticle, long groupId, long classNameId,
10556                    String templateId, OrderByComparator orderByComparator, boolean previous) {
10557                    StringBundler query = null;
10558    
10559                    if (orderByComparator != null) {
10560                            query = new StringBundler(6 +
10561                                            (orderByComparator.getOrderByFields().length * 6));
10562                    }
10563                    else {
10564                            query = new StringBundler(3);
10565                    }
10566    
10567                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
10568    
10569                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10570    
10571                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10572    
10573                    if (templateId == null) {
10574                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10575                    }
10576                    else {
10577                            if (templateId.equals(StringPool.BLANK)) {
10578                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10579                            }
10580                            else {
10581                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10582                            }
10583                    }
10584    
10585                    if (orderByComparator != null) {
10586                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10587    
10588                            if (orderByConditionFields.length > 0) {
10589                                    query.append(WHERE_AND);
10590                            }
10591    
10592                            for (int i = 0; i < orderByConditionFields.length; i++) {
10593                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10594                                    query.append(orderByConditionFields[i]);
10595    
10596                                    if ((i + 1) < orderByConditionFields.length) {
10597                                            if (orderByComparator.isAscending() ^ previous) {
10598                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10599                                            }
10600                                            else {
10601                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10602                                            }
10603                                    }
10604                                    else {
10605                                            if (orderByComparator.isAscending() ^ previous) {
10606                                                    query.append(WHERE_GREATER_THAN);
10607                                            }
10608                                            else {
10609                                                    query.append(WHERE_LESSER_THAN);
10610                                            }
10611                                    }
10612                            }
10613    
10614                            query.append(ORDER_BY_CLAUSE);
10615    
10616                            String[] orderByFields = orderByComparator.getOrderByFields();
10617    
10618                            for (int i = 0; i < orderByFields.length; i++) {
10619                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10620                                    query.append(orderByFields[i]);
10621    
10622                                    if ((i + 1) < orderByFields.length) {
10623                                            if (orderByComparator.isAscending() ^ previous) {
10624                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10625                                            }
10626                                            else {
10627                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10628                                            }
10629                                    }
10630                                    else {
10631                                            if (orderByComparator.isAscending() ^ previous) {
10632                                                    query.append(ORDER_BY_ASC);
10633                                            }
10634                                            else {
10635                                                    query.append(ORDER_BY_DESC);
10636                                            }
10637                                    }
10638                            }
10639                    }
10640    
10641                    else {
10642                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10643                    }
10644    
10645                    String sql = query.toString();
10646    
10647                    Query q = session.createQuery(sql);
10648    
10649                    q.setFirstResult(0);
10650                    q.setMaxResults(2);
10651    
10652                    QueryPos qPos = QueryPos.getInstance(q);
10653    
10654                    qPos.add(groupId);
10655    
10656                    qPos.add(classNameId);
10657    
10658                    if (templateId != null) {
10659                            qPos.add(templateId);
10660                    }
10661    
10662                    if (orderByComparator != null) {
10663                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
10664    
10665                            for (Object value : values) {
10666                                    qPos.add(value);
10667                            }
10668                    }
10669    
10670                    List<JournalArticle> list = q.list();
10671    
10672                    if (list.size() == 2) {
10673                            return list.get(1);
10674                    }
10675                    else {
10676                            return null;
10677                    }
10678            }
10679    
10680            /**
10681             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10682             *
10683             * @param groupId the group ID
10684             * @param classNameId the class name ID
10685             * @param templateId the template ID
10686             * @return the matching journal articles that the user has permission to view
10687             * @throws SystemException if a system exception occurred
10688             */
10689            public List<JournalArticle> filterFindByG_C_T(long groupId,
10690                    long classNameId, String templateId) throws SystemException {
10691                    return filterFindByG_C_T(groupId, classNameId, templateId,
10692                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10693            }
10694    
10695            /**
10696             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
10697             *
10698             * <p>
10699             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10700             * </p>
10701             *
10702             * @param groupId the group ID
10703             * @param classNameId the class name ID
10704             * @param templateId the template ID
10705             * @param start the lower bound of the range of journal articles
10706             * @param end the upper bound of the range of journal articles (not inclusive)
10707             * @return the range of matching journal articles that the user has permission to view
10708             * @throws SystemException if a system exception occurred
10709             */
10710            public List<JournalArticle> filterFindByG_C_T(long groupId,
10711                    long classNameId, String templateId, int start, int end)
10712                    throws SystemException {
10713                    return filterFindByG_C_T(groupId, classNameId, templateId, start, end,
10714                            null);
10715            }
10716    
10717            /**
10718             * 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;.
10719             *
10720             * <p>
10721             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10722             * </p>
10723             *
10724             * @param groupId the group ID
10725             * @param classNameId the class name ID
10726             * @param templateId the template ID
10727             * @param start the lower bound of the range of journal articles
10728             * @param end the upper bound of the range of journal articles (not inclusive)
10729             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10730             * @return the ordered range of matching journal articles that the user has permission to view
10731             * @throws SystemException if a system exception occurred
10732             */
10733            public List<JournalArticle> filterFindByG_C_T(long groupId,
10734                    long classNameId, String templateId, int start, int end,
10735                    OrderByComparator orderByComparator) throws SystemException {
10736                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10737                            return findByG_C_T(groupId, classNameId, templateId, start, end,
10738                                    orderByComparator);
10739                    }
10740    
10741                    StringBundler query = null;
10742    
10743                    if (orderByComparator != null) {
10744                            query = new StringBundler(5 +
10745                                            (orderByComparator.getOrderByFields().length * 3));
10746                    }
10747                    else {
10748                            query = new StringBundler(5);
10749                    }
10750    
10751                    if (getDB().isSupportsInlineDistinct()) {
10752                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10753                    }
10754                    else {
10755                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10756                    }
10757    
10758                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10759    
10760                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10761    
10762                    if (templateId == null) {
10763                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10764                    }
10765                    else {
10766                            if (templateId.equals(StringPool.BLANK)) {
10767                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10768                            }
10769                            else {
10770                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10771                            }
10772                    }
10773    
10774                    if (!getDB().isSupportsInlineDistinct()) {
10775                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10776                    }
10777    
10778                    if (orderByComparator != null) {
10779                            if (getDB().isSupportsInlineDistinct()) {
10780                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10781                                            orderByComparator);
10782                            }
10783                            else {
10784                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10785                                            orderByComparator);
10786                            }
10787                    }
10788    
10789                    else {
10790                            if (getDB().isSupportsInlineDistinct()) {
10791                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10792                            }
10793                            else {
10794                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10795                            }
10796                    }
10797    
10798                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10799                                    JournalArticle.class.getName(),
10800                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10801    
10802                    Session session = null;
10803    
10804                    try {
10805                            session = openSession();
10806    
10807                            SQLQuery q = session.createSQLQuery(sql);
10808    
10809                            if (getDB().isSupportsInlineDistinct()) {
10810                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
10811                            }
10812                            else {
10813                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
10814                            }
10815    
10816                            QueryPos qPos = QueryPos.getInstance(q);
10817    
10818                            qPos.add(groupId);
10819    
10820                            qPos.add(classNameId);
10821    
10822                            if (templateId != null) {
10823                                    qPos.add(templateId);
10824                            }
10825    
10826                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
10827                                    end);
10828                    }
10829                    catch (Exception e) {
10830                            throw processException(e);
10831                    }
10832                    finally {
10833                            closeSession(session);
10834                    }
10835            }
10836    
10837            /**
10838             * 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;.
10839             *
10840             * @param id the primary key of the current journal article
10841             * @param groupId the group ID
10842             * @param classNameId the class name ID
10843             * @param templateId the template ID
10844             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10845             * @return the previous, current, and next journal article
10846             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
10847             * @throws SystemException if a system exception occurred
10848             */
10849            public JournalArticle[] filterFindByG_C_T_PrevAndNext(long id,
10850                    long groupId, long classNameId, String templateId,
10851                    OrderByComparator orderByComparator)
10852                    throws NoSuchArticleException, SystemException {
10853                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10854                            return findByG_C_T_PrevAndNext(id, groupId, classNameId,
10855                                    templateId, orderByComparator);
10856                    }
10857    
10858                    JournalArticle journalArticle = findByPrimaryKey(id);
10859    
10860                    Session session = null;
10861    
10862                    try {
10863                            session = openSession();
10864    
10865                            JournalArticle[] array = new JournalArticleImpl[3];
10866    
10867                            array[0] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
10868                                            groupId, classNameId, templateId, orderByComparator, true);
10869    
10870                            array[1] = journalArticle;
10871    
10872                            array[2] = filterGetByG_C_T_PrevAndNext(session, journalArticle,
10873                                            groupId, classNameId, templateId, orderByComparator, false);
10874    
10875                            return array;
10876                    }
10877                    catch (Exception e) {
10878                            throw processException(e);
10879                    }
10880                    finally {
10881                            closeSession(session);
10882                    }
10883            }
10884    
10885            protected JournalArticle filterGetByG_C_T_PrevAndNext(Session session,
10886                    JournalArticle journalArticle, long groupId, long classNameId,
10887                    String templateId, OrderByComparator orderByComparator, boolean previous) {
10888                    StringBundler query = null;
10889    
10890                    if (orderByComparator != null) {
10891                            query = new StringBundler(6 +
10892                                            (orderByComparator.getOrderByFields().length * 6));
10893                    }
10894                    else {
10895                            query = new StringBundler(3);
10896                    }
10897    
10898                    if (getDB().isSupportsInlineDistinct()) {
10899                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
10900                    }
10901                    else {
10902                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
10903                    }
10904    
10905                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
10906    
10907                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
10908    
10909                    if (templateId == null) {
10910                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
10911                    }
10912                    else {
10913                            if (templateId.equals(StringPool.BLANK)) {
10914                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
10915                            }
10916                            else {
10917                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
10918                            }
10919                    }
10920    
10921                    if (!getDB().isSupportsInlineDistinct()) {
10922                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
10923                    }
10924    
10925                    if (orderByComparator != null) {
10926                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10927    
10928                            if (orderByConditionFields.length > 0) {
10929                                    query.append(WHERE_AND);
10930                            }
10931    
10932                            for (int i = 0; i < orderByConditionFields.length; i++) {
10933                                    if (getDB().isSupportsInlineDistinct()) {
10934                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10935                                    }
10936                                    else {
10937                                            query.append(_ORDER_BY_ENTITY_TABLE);
10938                                    }
10939    
10940                                    query.append(orderByConditionFields[i]);
10941    
10942                                    if ((i + 1) < orderByConditionFields.length) {
10943                                            if (orderByComparator.isAscending() ^ previous) {
10944                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10945                                            }
10946                                            else {
10947                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10948                                            }
10949                                    }
10950                                    else {
10951                                            if (orderByComparator.isAscending() ^ previous) {
10952                                                    query.append(WHERE_GREATER_THAN);
10953                                            }
10954                                            else {
10955                                                    query.append(WHERE_LESSER_THAN);
10956                                            }
10957                                    }
10958                            }
10959    
10960                            query.append(ORDER_BY_CLAUSE);
10961    
10962                            String[] orderByFields = orderByComparator.getOrderByFields();
10963    
10964                            for (int i = 0; i < orderByFields.length; i++) {
10965                                    if (getDB().isSupportsInlineDistinct()) {
10966                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10967                                    }
10968                                    else {
10969                                            query.append(_ORDER_BY_ENTITY_TABLE);
10970                                    }
10971    
10972                                    query.append(orderByFields[i]);
10973    
10974                                    if ((i + 1) < orderByFields.length) {
10975                                            if (orderByComparator.isAscending() ^ previous) {
10976                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10977                                            }
10978                                            else {
10979                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10980                                            }
10981                                    }
10982                                    else {
10983                                            if (orderByComparator.isAscending() ^ previous) {
10984                                                    query.append(ORDER_BY_ASC);
10985                                            }
10986                                            else {
10987                                                    query.append(ORDER_BY_DESC);
10988                                            }
10989                                    }
10990                            }
10991                    }
10992    
10993                    else {
10994                            if (getDB().isSupportsInlineDistinct()) {
10995                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
10996                            }
10997                            else {
10998                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
10999                            }
11000                    }
11001    
11002                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11003                                    JournalArticle.class.getName(),
11004                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11005    
11006                    SQLQuery q = session.createSQLQuery(sql);
11007    
11008                    q.setFirstResult(0);
11009                    q.setMaxResults(2);
11010    
11011                    if (getDB().isSupportsInlineDistinct()) {
11012                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11013                    }
11014                    else {
11015                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11016                    }
11017    
11018                    QueryPos qPos = QueryPos.getInstance(q);
11019    
11020                    qPos.add(groupId);
11021    
11022                    qPos.add(classNameId);
11023    
11024                    if (templateId != null) {
11025                            qPos.add(templateId);
11026                    }
11027    
11028                    if (orderByComparator != null) {
11029                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11030    
11031                            for (Object value : values) {
11032                                    qPos.add(value);
11033                            }
11034                    }
11035    
11036                    List<JournalArticle> list = q.list();
11037    
11038                    if (list.size() == 2) {
11039                            return list.get(1);
11040                    }
11041                    else {
11042                            return null;
11043                    }
11044            }
11045    
11046            /**
11047             * Returns all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11048             *
11049             * @param groupId the group ID
11050             * @param classNameId the class name ID
11051             * @param layoutUuid the layout uuid
11052             * @return the matching journal articles
11053             * @throws SystemException if a system exception occurred
11054             */
11055            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
11056                    String layoutUuid) throws SystemException {
11057                    return findByG_C_L(groupId, classNameId, layoutUuid, QueryUtil.ALL_POS,
11058                            QueryUtil.ALL_POS, null);
11059            }
11060    
11061            /**
11062             * Returns a range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11063             *
11064             * <p>
11065             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11066             * </p>
11067             *
11068             * @param groupId the group ID
11069             * @param classNameId the class name ID
11070             * @param layoutUuid the layout uuid
11071             * @param start the lower bound of the range of journal articles
11072             * @param end the upper bound of the range of journal articles (not inclusive)
11073             * @return the range of matching journal articles
11074             * @throws SystemException if a system exception occurred
11075             */
11076            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
11077                    String layoutUuid, int start, int end) throws SystemException {
11078                    return findByG_C_L(groupId, classNameId, layoutUuid, start, end, null);
11079            }
11080    
11081            /**
11082             * Returns an ordered range of all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11083             *
11084             * <p>
11085             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11086             * </p>
11087             *
11088             * @param groupId the group ID
11089             * @param classNameId the class name ID
11090             * @param layoutUuid the layout uuid
11091             * @param start the lower bound of the range of journal articles
11092             * @param end the upper bound of the range of journal articles (not inclusive)
11093             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11094             * @return the ordered range of matching journal articles
11095             * @throws SystemException if a system exception occurred
11096             */
11097            public List<JournalArticle> findByG_C_L(long groupId, long classNameId,
11098                    String layoutUuid, int start, int end,
11099                    OrderByComparator orderByComparator) throws SystemException {
11100                    FinderPath finderPath = null;
11101                    Object[] finderArgs = null;
11102    
11103                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11104                                    (orderByComparator == null)) {
11105                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_L;
11106                            finderArgs = new Object[] { groupId, classNameId, layoutUuid };
11107                    }
11108                    else {
11109                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_L;
11110                            finderArgs = new Object[] {
11111                                            groupId, classNameId, layoutUuid,
11112                                            
11113                                            start, end, orderByComparator
11114                                    };
11115                    }
11116    
11117                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
11118                                    finderArgs, this);
11119    
11120                    if (list == null) {
11121                            StringBundler query = null;
11122    
11123                            if (orderByComparator != null) {
11124                                    query = new StringBundler(5 +
11125                                                    (orderByComparator.getOrderByFields().length * 3));
11126                            }
11127                            else {
11128                                    query = new StringBundler(5);
11129                            }
11130    
11131                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11132    
11133                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11134    
11135                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11136    
11137                            if (layoutUuid == null) {
11138                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11139                            }
11140                            else {
11141                                    if (layoutUuid.equals(StringPool.BLANK)) {
11142                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11143                                    }
11144                                    else {
11145                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11146                                    }
11147                            }
11148    
11149                            if (orderByComparator != null) {
11150                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11151                                            orderByComparator);
11152                            }
11153    
11154                            else {
11155                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11156                            }
11157    
11158                            String sql = query.toString();
11159    
11160                            Session session = null;
11161    
11162                            try {
11163                                    session = openSession();
11164    
11165                                    Query q = session.createQuery(sql);
11166    
11167                                    QueryPos qPos = QueryPos.getInstance(q);
11168    
11169                                    qPos.add(groupId);
11170    
11171                                    qPos.add(classNameId);
11172    
11173                                    if (layoutUuid != null) {
11174                                            qPos.add(layoutUuid);
11175                                    }
11176    
11177                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
11178                                                    start, end);
11179                            }
11180                            catch (Exception e) {
11181                                    throw processException(e);
11182                            }
11183                            finally {
11184                                    if (list == null) {
11185                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11186                                    }
11187                                    else {
11188                                            cacheResult(list);
11189    
11190                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11191                                    }
11192    
11193                                    closeSession(session);
11194                            }
11195                    }
11196    
11197                    return list;
11198            }
11199    
11200            /**
11201             * Returns the first journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11202             *
11203             * <p>
11204             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11205             * </p>
11206             *
11207             * @param groupId the group ID
11208             * @param classNameId the class name ID
11209             * @param layoutUuid the layout uuid
11210             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11211             * @return the first matching journal article
11212             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11213             * @throws SystemException if a system exception occurred
11214             */
11215            public JournalArticle findByG_C_L_First(long groupId, long classNameId,
11216                    String layoutUuid, OrderByComparator orderByComparator)
11217                    throws NoSuchArticleException, SystemException {
11218                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
11219                                    layoutUuid, 0, 1, orderByComparator);
11220    
11221                    if (list.isEmpty()) {
11222                            StringBundler msg = new StringBundler(8);
11223    
11224                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11225    
11226                            msg.append("groupId=");
11227                            msg.append(groupId);
11228    
11229                            msg.append(", classNameId=");
11230                            msg.append(classNameId);
11231    
11232                            msg.append(", layoutUuid=");
11233                            msg.append(layoutUuid);
11234    
11235                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11236    
11237                            throw new NoSuchArticleException(msg.toString());
11238                    }
11239                    else {
11240                            return list.get(0);
11241                    }
11242            }
11243    
11244            /**
11245             * Returns the last journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11246             *
11247             * <p>
11248             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11249             * </p>
11250             *
11251             * @param groupId the group ID
11252             * @param classNameId the class name ID
11253             * @param layoutUuid the layout uuid
11254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11255             * @return the last matching journal article
11256             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11257             * @throws SystemException if a system exception occurred
11258             */
11259            public JournalArticle findByG_C_L_Last(long groupId, long classNameId,
11260                    String layoutUuid, OrderByComparator orderByComparator)
11261                    throws NoSuchArticleException, SystemException {
11262                    int count = countByG_C_L(groupId, classNameId, layoutUuid);
11263    
11264                    List<JournalArticle> list = findByG_C_L(groupId, classNameId,
11265                                    layoutUuid, count - 1, count, orderByComparator);
11266    
11267                    if (list.isEmpty()) {
11268                            StringBundler msg = new StringBundler(8);
11269    
11270                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11271    
11272                            msg.append("groupId=");
11273                            msg.append(groupId);
11274    
11275                            msg.append(", classNameId=");
11276                            msg.append(classNameId);
11277    
11278                            msg.append(", layoutUuid=");
11279                            msg.append(layoutUuid);
11280    
11281                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11282    
11283                            throw new NoSuchArticleException(msg.toString());
11284                    }
11285                    else {
11286                            return list.get(0);
11287                    }
11288            }
11289    
11290            /**
11291             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11292             *
11293             * <p>
11294             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11295             * </p>
11296             *
11297             * @param id the primary key of the current journal article
11298             * @param groupId the group ID
11299             * @param classNameId the class name ID
11300             * @param layoutUuid the layout uuid
11301             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11302             * @return the previous, current, and next journal article
11303             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11304             * @throws SystemException if a system exception occurred
11305             */
11306            public JournalArticle[] findByG_C_L_PrevAndNext(long id, long groupId,
11307                    long classNameId, String layoutUuid, OrderByComparator orderByComparator)
11308                    throws NoSuchArticleException, SystemException {
11309                    JournalArticle journalArticle = findByPrimaryKey(id);
11310    
11311                    Session session = null;
11312    
11313                    try {
11314                            session = openSession();
11315    
11316                            JournalArticle[] array = new JournalArticleImpl[3];
11317    
11318                            array[0] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
11319                                            classNameId, layoutUuid, orderByComparator, true);
11320    
11321                            array[1] = journalArticle;
11322    
11323                            array[2] = getByG_C_L_PrevAndNext(session, journalArticle, groupId,
11324                                            classNameId, layoutUuid, orderByComparator, false);
11325    
11326                            return array;
11327                    }
11328                    catch (Exception e) {
11329                            throw processException(e);
11330                    }
11331                    finally {
11332                            closeSession(session);
11333                    }
11334            }
11335    
11336            protected JournalArticle getByG_C_L_PrevAndNext(Session session,
11337                    JournalArticle journalArticle, long groupId, long classNameId,
11338                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
11339                    StringBundler query = null;
11340    
11341                    if (orderByComparator != null) {
11342                            query = new StringBundler(6 +
11343                                            (orderByComparator.getOrderByFields().length * 6));
11344                    }
11345                    else {
11346                            query = new StringBundler(3);
11347                    }
11348    
11349                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11350    
11351                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11352    
11353                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11354    
11355                    if (layoutUuid == null) {
11356                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11357                    }
11358                    else {
11359                            if (layoutUuid.equals(StringPool.BLANK)) {
11360                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11361                            }
11362                            else {
11363                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11364                            }
11365                    }
11366    
11367                    if (orderByComparator != null) {
11368                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11369    
11370                            if (orderByConditionFields.length > 0) {
11371                                    query.append(WHERE_AND);
11372                            }
11373    
11374                            for (int i = 0; i < orderByConditionFields.length; i++) {
11375                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11376                                    query.append(orderByConditionFields[i]);
11377    
11378                                    if ((i + 1) < orderByConditionFields.length) {
11379                                            if (orderByComparator.isAscending() ^ previous) {
11380                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11381                                            }
11382                                            else {
11383                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11384                                            }
11385                                    }
11386                                    else {
11387                                            if (orderByComparator.isAscending() ^ previous) {
11388                                                    query.append(WHERE_GREATER_THAN);
11389                                            }
11390                                            else {
11391                                                    query.append(WHERE_LESSER_THAN);
11392                                            }
11393                                    }
11394                            }
11395    
11396                            query.append(ORDER_BY_CLAUSE);
11397    
11398                            String[] orderByFields = orderByComparator.getOrderByFields();
11399    
11400                            for (int i = 0; i < orderByFields.length; i++) {
11401                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11402                                    query.append(orderByFields[i]);
11403    
11404                                    if ((i + 1) < orderByFields.length) {
11405                                            if (orderByComparator.isAscending() ^ previous) {
11406                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11407                                            }
11408                                            else {
11409                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11410                                            }
11411                                    }
11412                                    else {
11413                                            if (orderByComparator.isAscending() ^ previous) {
11414                                                    query.append(ORDER_BY_ASC);
11415                                            }
11416                                            else {
11417                                                    query.append(ORDER_BY_DESC);
11418                                            }
11419                                    }
11420                            }
11421                    }
11422    
11423                    else {
11424                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11425                    }
11426    
11427                    String sql = query.toString();
11428    
11429                    Query q = session.createQuery(sql);
11430    
11431                    q.setFirstResult(0);
11432                    q.setMaxResults(2);
11433    
11434                    QueryPos qPos = QueryPos.getInstance(q);
11435    
11436                    qPos.add(groupId);
11437    
11438                    qPos.add(classNameId);
11439    
11440                    if (layoutUuid != null) {
11441                            qPos.add(layoutUuid);
11442                    }
11443    
11444                    if (orderByComparator != null) {
11445                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11446    
11447                            for (Object value : values) {
11448                                    qPos.add(value);
11449                            }
11450                    }
11451    
11452                    List<JournalArticle> list = q.list();
11453    
11454                    if (list.size() == 2) {
11455                            return list.get(1);
11456                    }
11457                    else {
11458                            return null;
11459                    }
11460            }
11461    
11462            /**
11463             * Returns all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11464             *
11465             * @param groupId the group ID
11466             * @param classNameId the class name ID
11467             * @param layoutUuid the layout uuid
11468             * @return the matching journal articles that the user has permission to view
11469             * @throws SystemException if a system exception occurred
11470             */
11471            public List<JournalArticle> filterFindByG_C_L(long groupId,
11472                    long classNameId, String layoutUuid) throws SystemException {
11473                    return filterFindByG_C_L(groupId, classNameId, layoutUuid,
11474                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11475            }
11476    
11477            /**
11478             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
11479             *
11480             * <p>
11481             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11482             * </p>
11483             *
11484             * @param groupId the group ID
11485             * @param classNameId the class name ID
11486             * @param layoutUuid the layout uuid
11487             * @param start the lower bound of the range of journal articles
11488             * @param end the upper bound of the range of journal articles (not inclusive)
11489             * @return the range of matching journal articles that the user has permission to view
11490             * @throws SystemException if a system exception occurred
11491             */
11492            public List<JournalArticle> filterFindByG_C_L(long groupId,
11493                    long classNameId, String layoutUuid, int start, int end)
11494                    throws SystemException {
11495                    return filterFindByG_C_L(groupId, classNameId, layoutUuid, start, end,
11496                            null);
11497            }
11498    
11499            /**
11500             * 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;.
11501             *
11502             * <p>
11503             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11504             * </p>
11505             *
11506             * @param groupId the group ID
11507             * @param classNameId the class name ID
11508             * @param layoutUuid the layout uuid
11509             * @param start the lower bound of the range of journal articles
11510             * @param end the upper bound of the range of journal articles (not inclusive)
11511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11512             * @return the ordered range of matching journal articles that the user has permission to view
11513             * @throws SystemException if a system exception occurred
11514             */
11515            public List<JournalArticle> filterFindByG_C_L(long groupId,
11516                    long classNameId, String layoutUuid, int start, int end,
11517                    OrderByComparator orderByComparator) throws SystemException {
11518                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11519                            return findByG_C_L(groupId, classNameId, layoutUuid, start, end,
11520                                    orderByComparator);
11521                    }
11522    
11523                    StringBundler query = null;
11524    
11525                    if (orderByComparator != null) {
11526                            query = new StringBundler(5 +
11527                                            (orderByComparator.getOrderByFields().length * 3));
11528                    }
11529                    else {
11530                            query = new StringBundler(5);
11531                    }
11532    
11533                    if (getDB().isSupportsInlineDistinct()) {
11534                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11535                    }
11536                    else {
11537                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11538                    }
11539    
11540                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11541    
11542                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11543    
11544                    if (layoutUuid == null) {
11545                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11546                    }
11547                    else {
11548                            if (layoutUuid.equals(StringPool.BLANK)) {
11549                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11550                            }
11551                            else {
11552                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11553                            }
11554                    }
11555    
11556                    if (!getDB().isSupportsInlineDistinct()) {
11557                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11558                    }
11559    
11560                    if (orderByComparator != null) {
11561                            if (getDB().isSupportsInlineDistinct()) {
11562                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11563                                            orderByComparator);
11564                            }
11565                            else {
11566                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11567                                            orderByComparator);
11568                            }
11569                    }
11570    
11571                    else {
11572                            if (getDB().isSupportsInlineDistinct()) {
11573                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11574                            }
11575                            else {
11576                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11577                            }
11578                    }
11579    
11580                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11581                                    JournalArticle.class.getName(),
11582                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11583    
11584                    Session session = null;
11585    
11586                    try {
11587                            session = openSession();
11588    
11589                            SQLQuery q = session.createSQLQuery(sql);
11590    
11591                            if (getDB().isSupportsInlineDistinct()) {
11592                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11593                            }
11594                            else {
11595                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11596                            }
11597    
11598                            QueryPos qPos = QueryPos.getInstance(q);
11599    
11600                            qPos.add(groupId);
11601    
11602                            qPos.add(classNameId);
11603    
11604                            if (layoutUuid != null) {
11605                                    qPos.add(layoutUuid);
11606                            }
11607    
11608                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
11609                                    end);
11610                    }
11611                    catch (Exception e) {
11612                            throw processException(e);
11613                    }
11614                    finally {
11615                            closeSession(session);
11616                    }
11617            }
11618    
11619            /**
11620             * 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;.
11621             *
11622             * @param id the primary key of the current journal article
11623             * @param groupId the group ID
11624             * @param classNameId the class name ID
11625             * @param layoutUuid the layout uuid
11626             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11627             * @return the previous, current, and next journal article
11628             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
11629             * @throws SystemException if a system exception occurred
11630             */
11631            public JournalArticle[] filterFindByG_C_L_PrevAndNext(long id,
11632                    long groupId, long classNameId, String layoutUuid,
11633                    OrderByComparator orderByComparator)
11634                    throws NoSuchArticleException, SystemException {
11635                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11636                            return findByG_C_L_PrevAndNext(id, groupId, classNameId,
11637                                    layoutUuid, orderByComparator);
11638                    }
11639    
11640                    JournalArticle journalArticle = findByPrimaryKey(id);
11641    
11642                    Session session = null;
11643    
11644                    try {
11645                            session = openSession();
11646    
11647                            JournalArticle[] array = new JournalArticleImpl[3];
11648    
11649                            array[0] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
11650                                            groupId, classNameId, layoutUuid, orderByComparator, true);
11651    
11652                            array[1] = journalArticle;
11653    
11654                            array[2] = filterGetByG_C_L_PrevAndNext(session, journalArticle,
11655                                            groupId, classNameId, layoutUuid, orderByComparator, false);
11656    
11657                            return array;
11658                    }
11659                    catch (Exception e) {
11660                            throw processException(e);
11661                    }
11662                    finally {
11663                            closeSession(session);
11664                    }
11665            }
11666    
11667            protected JournalArticle filterGetByG_C_L_PrevAndNext(Session session,
11668                    JournalArticle journalArticle, long groupId, long classNameId,
11669                    String layoutUuid, OrderByComparator orderByComparator, boolean previous) {
11670                    StringBundler query = null;
11671    
11672                    if (orderByComparator != null) {
11673                            query = new StringBundler(6 +
11674                                            (orderByComparator.getOrderByFields().length * 6));
11675                    }
11676                    else {
11677                            query = new StringBundler(3);
11678                    }
11679    
11680                    if (getDB().isSupportsInlineDistinct()) {
11681                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
11682                    }
11683                    else {
11684                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
11685                    }
11686    
11687                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
11688    
11689                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
11690    
11691                    if (layoutUuid == null) {
11692                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
11693                    }
11694                    else {
11695                            if (layoutUuid.equals(StringPool.BLANK)) {
11696                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
11697                            }
11698                            else {
11699                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
11700                            }
11701                    }
11702    
11703                    if (!getDB().isSupportsInlineDistinct()) {
11704                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
11705                    }
11706    
11707                    if (orderByComparator != null) {
11708                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11709    
11710                            if (orderByConditionFields.length > 0) {
11711                                    query.append(WHERE_AND);
11712                            }
11713    
11714                            for (int i = 0; i < orderByConditionFields.length; i++) {
11715                                    if (getDB().isSupportsInlineDistinct()) {
11716                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11717                                    }
11718                                    else {
11719                                            query.append(_ORDER_BY_ENTITY_TABLE);
11720                                    }
11721    
11722                                    query.append(orderByConditionFields[i]);
11723    
11724                                    if ((i + 1) < orderByConditionFields.length) {
11725                                            if (orderByComparator.isAscending() ^ previous) {
11726                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11727                                            }
11728                                            else {
11729                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11730                                            }
11731                                    }
11732                                    else {
11733                                            if (orderByComparator.isAscending() ^ previous) {
11734                                                    query.append(WHERE_GREATER_THAN);
11735                                            }
11736                                            else {
11737                                                    query.append(WHERE_LESSER_THAN);
11738                                            }
11739                                    }
11740                            }
11741    
11742                            query.append(ORDER_BY_CLAUSE);
11743    
11744                            String[] orderByFields = orderByComparator.getOrderByFields();
11745    
11746                            for (int i = 0; i < orderByFields.length; i++) {
11747                                    if (getDB().isSupportsInlineDistinct()) {
11748                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11749                                    }
11750                                    else {
11751                                            query.append(_ORDER_BY_ENTITY_TABLE);
11752                                    }
11753    
11754                                    query.append(orderByFields[i]);
11755    
11756                                    if ((i + 1) < orderByFields.length) {
11757                                            if (orderByComparator.isAscending() ^ previous) {
11758                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11759                                            }
11760                                            else {
11761                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11762                                            }
11763                                    }
11764                                    else {
11765                                            if (orderByComparator.isAscending() ^ previous) {
11766                                                    query.append(ORDER_BY_ASC);
11767                                            }
11768                                            else {
11769                                                    query.append(ORDER_BY_DESC);
11770                                            }
11771                                    }
11772                            }
11773                    }
11774    
11775                    else {
11776                            if (getDB().isSupportsInlineDistinct()) {
11777                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11778                            }
11779                            else {
11780                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
11781                            }
11782                    }
11783    
11784                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11785                                    JournalArticle.class.getName(),
11786                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11787    
11788                    SQLQuery q = session.createSQLQuery(sql);
11789    
11790                    q.setFirstResult(0);
11791                    q.setMaxResults(2);
11792    
11793                    if (getDB().isSupportsInlineDistinct()) {
11794                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
11795                    }
11796                    else {
11797                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
11798                    }
11799    
11800                    QueryPos qPos = QueryPos.getInstance(q);
11801    
11802                    qPos.add(groupId);
11803    
11804                    qPos.add(classNameId);
11805    
11806                    if (layoutUuid != null) {
11807                            qPos.add(layoutUuid);
11808                    }
11809    
11810                    if (orderByComparator != null) {
11811                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
11812    
11813                            for (Object value : values) {
11814                                    qPos.add(value);
11815                            }
11816                    }
11817    
11818                    List<JournalArticle> list = q.list();
11819    
11820                    if (list.size() == 2) {
11821                            return list.get(1);
11822                    }
11823                    else {
11824                            return null;
11825                    }
11826            }
11827    
11828            /**
11829             * 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.
11830             *
11831             * @param groupId the group ID
11832             * @param articleId the article ID
11833             * @param version the version
11834             * @return the matching journal article
11835             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
11836             * @throws SystemException if a system exception occurred
11837             */
11838            public JournalArticle findByG_A_V(long groupId, String articleId,
11839                    double version) throws NoSuchArticleException, SystemException {
11840                    JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
11841    
11842                    if (journalArticle == null) {
11843                            StringBundler msg = new StringBundler(8);
11844    
11845                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11846    
11847                            msg.append("groupId=");
11848                            msg.append(groupId);
11849    
11850                            msg.append(", articleId=");
11851                            msg.append(articleId);
11852    
11853                            msg.append(", version=");
11854                            msg.append(version);
11855    
11856                            msg.append(StringPool.CLOSE_CURLY_BRACE);
11857    
11858                            if (_log.isWarnEnabled()) {
11859                                    _log.warn(msg.toString());
11860                            }
11861    
11862                            throw new NoSuchArticleException(msg.toString());
11863                    }
11864    
11865                    return journalArticle;
11866            }
11867    
11868            /**
11869             * 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.
11870             *
11871             * @param groupId the group ID
11872             * @param articleId the article ID
11873             * @param version the version
11874             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11875             * @throws SystemException if a system exception occurred
11876             */
11877            public JournalArticle fetchByG_A_V(long groupId, String articleId,
11878                    double version) throws SystemException {
11879                    return fetchByG_A_V(groupId, articleId, version, true);
11880            }
11881    
11882            /**
11883             * 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.
11884             *
11885             * @param groupId the group ID
11886             * @param articleId the article ID
11887             * @param version the version
11888             * @param retrieveFromCache whether to use the finder cache
11889             * @return the matching journal article, or <code>null</code> if a matching journal article could not be found
11890             * @throws SystemException if a system exception occurred
11891             */
11892            public JournalArticle fetchByG_A_V(long groupId, String articleId,
11893                    double version, boolean retrieveFromCache) throws SystemException {
11894                    Object[] finderArgs = new Object[] { groupId, articleId, version };
11895    
11896                    Object result = null;
11897    
11898                    if (retrieveFromCache) {
11899                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_V,
11900                                            finderArgs, this);
11901                    }
11902    
11903                    if (result == null) {
11904                            StringBundler query = new StringBundler(5);
11905    
11906                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
11907    
11908                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
11909    
11910                            if (articleId == null) {
11911                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
11912                            }
11913                            else {
11914                                    if (articleId.equals(StringPool.BLANK)) {
11915                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
11916                                    }
11917                                    else {
11918                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
11919                                    }
11920                            }
11921    
11922                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
11923    
11924                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
11925    
11926                            String sql = query.toString();
11927    
11928                            Session session = null;
11929    
11930                            try {
11931                                    session = openSession();
11932    
11933                                    Query q = session.createQuery(sql);
11934    
11935                                    QueryPos qPos = QueryPos.getInstance(q);
11936    
11937                                    qPos.add(groupId);
11938    
11939                                    if (articleId != null) {
11940                                            qPos.add(articleId);
11941                                    }
11942    
11943                                    qPos.add(version);
11944    
11945                                    List<JournalArticle> list = q.list();
11946    
11947                                    result = list;
11948    
11949                                    JournalArticle journalArticle = null;
11950    
11951                                    if (list.isEmpty()) {
11952                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
11953                                                    finderArgs, list);
11954                                    }
11955                                    else {
11956                                            journalArticle = list.get(0);
11957    
11958                                            cacheResult(journalArticle);
11959    
11960                                            if ((journalArticle.getGroupId() != groupId) ||
11961                                                            (journalArticle.getArticleId() == null) ||
11962                                                            !journalArticle.getArticleId().equals(articleId) ||
11963                                                            (journalArticle.getVersion() != version)) {
11964                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_V,
11965                                                            finderArgs, journalArticle);
11966                                            }
11967                                    }
11968    
11969                                    return journalArticle;
11970                            }
11971                            catch (Exception e) {
11972                                    throw processException(e);
11973                            }
11974                            finally {
11975                                    if (result == null) {
11976                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_V,
11977                                                    finderArgs);
11978                                    }
11979    
11980                                    closeSession(session);
11981                            }
11982                    }
11983                    else {
11984                            if (result instanceof List<?>) {
11985                                    return null;
11986                            }
11987                            else {
11988                                    return (JournalArticle)result;
11989                            }
11990                    }
11991            }
11992    
11993            /**
11994             * Returns all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
11995             *
11996             * @param groupId the group ID
11997             * @param articleId the article ID
11998             * @param status the status
11999             * @return the matching journal articles
12000             * @throws SystemException if a system exception occurred
12001             */
12002            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12003                    int status) throws SystemException {
12004                    return findByG_A_ST(groupId, articleId, status, QueryUtil.ALL_POS,
12005                            QueryUtil.ALL_POS, null);
12006            }
12007    
12008            /**
12009             * Returns a range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
12010             *
12011             * <p>
12012             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12013             * </p>
12014             *
12015             * @param groupId the group ID
12016             * @param articleId the article ID
12017             * @param status the status
12018             * @param start the lower bound of the range of journal articles
12019             * @param end the upper bound of the range of journal articles (not inclusive)
12020             * @return the range of matching journal articles
12021             * @throws SystemException if a system exception occurred
12022             */
12023            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12024                    int status, int start, int end) throws SystemException {
12025                    return findByG_A_ST(groupId, articleId, status, start, end, null);
12026            }
12027    
12028            /**
12029             * Returns an ordered range of all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
12030             *
12031             * <p>
12032             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12033             * </p>
12034             *
12035             * @param groupId the group ID
12036             * @param articleId the article ID
12037             * @param status the status
12038             * @param start the lower bound of the range of journal articles
12039             * @param end the upper bound of the range of journal articles (not inclusive)
12040             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12041             * @return the ordered range of matching journal articles
12042             * @throws SystemException if a system exception occurred
12043             */
12044            public List<JournalArticle> findByG_A_ST(long groupId, String articleId,
12045                    int status, int start, int end, OrderByComparator orderByComparator)
12046                    throws SystemException {
12047                    FinderPath finderPath = null;
12048                    Object[] finderArgs = null;
12049    
12050                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12051                                    (orderByComparator == null)) {
12052                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_A_ST;
12053                            finderArgs = new Object[] { groupId, articleId, status };
12054                    }
12055                    else {
12056                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_A_ST;
12057                            finderArgs = new Object[] {
12058                                            groupId, articleId, status,
12059                                            
12060                                            start, end, orderByComparator
12061                                    };
12062                    }
12063    
12064                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12065                                    finderArgs, this);
12066    
12067                    if (list == null) {
12068                            StringBundler query = null;
12069    
12070                            if (orderByComparator != null) {
12071                                    query = new StringBundler(5 +
12072                                                    (orderByComparator.getOrderByFields().length * 3));
12073                            }
12074                            else {
12075                                    query = new StringBundler(5);
12076                            }
12077    
12078                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12079    
12080                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12081    
12082                            if (articleId == null) {
12083                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12084                            }
12085                            else {
12086                                    if (articleId.equals(StringPool.BLANK)) {
12087                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12088                                    }
12089                                    else {
12090                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12091                                    }
12092                            }
12093    
12094                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12095    
12096                            if (orderByComparator != null) {
12097                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12098                                            orderByComparator);
12099                            }
12100    
12101                            else {
12102                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12103                            }
12104    
12105                            String sql = query.toString();
12106    
12107                            Session session = null;
12108    
12109                            try {
12110                                    session = openSession();
12111    
12112                                    Query q = session.createQuery(sql);
12113    
12114                                    QueryPos qPos = QueryPos.getInstance(q);
12115    
12116                                    qPos.add(groupId);
12117    
12118                                    if (articleId != null) {
12119                                            qPos.add(articleId);
12120                                    }
12121    
12122                                    qPos.add(status);
12123    
12124                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12125                                                    start, end);
12126                            }
12127                            catch (Exception e) {
12128                                    throw processException(e);
12129                            }
12130                            finally {
12131                                    if (list == null) {
12132                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12133                                    }
12134                                    else {
12135                                            cacheResult(list);
12136    
12137                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12138                                    }
12139    
12140                                    closeSession(session);
12141                            }
12142                    }
12143    
12144                    return list;
12145            }
12146    
12147            /**
12148             * Returns the first journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
12149             *
12150             * <p>
12151             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12152             * </p>
12153             *
12154             * @param groupId the group ID
12155             * @param articleId the article ID
12156             * @param status the status
12157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12158             * @return the first matching journal article
12159             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12160             * @throws SystemException if a system exception occurred
12161             */
12162            public JournalArticle findByG_A_ST_First(long groupId, String articleId,
12163                    int status, OrderByComparator orderByComparator)
12164                    throws NoSuchArticleException, SystemException {
12165                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status, 0,
12166                                    1, orderByComparator);
12167    
12168                    if (list.isEmpty()) {
12169                            StringBundler msg = new StringBundler(8);
12170    
12171                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12172    
12173                            msg.append("groupId=");
12174                            msg.append(groupId);
12175    
12176                            msg.append(", articleId=");
12177                            msg.append(articleId);
12178    
12179                            msg.append(", status=");
12180                            msg.append(status);
12181    
12182                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12183    
12184                            throw new NoSuchArticleException(msg.toString());
12185                    }
12186                    else {
12187                            return list.get(0);
12188                    }
12189            }
12190    
12191            /**
12192             * Returns the last journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
12193             *
12194             * <p>
12195             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12196             * </p>
12197             *
12198             * @param groupId the group ID
12199             * @param articleId the article ID
12200             * @param status the status
12201             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12202             * @return the last matching journal article
12203             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12204             * @throws SystemException if a system exception occurred
12205             */
12206            public JournalArticle findByG_A_ST_Last(long groupId, String articleId,
12207                    int status, OrderByComparator orderByComparator)
12208                    throws NoSuchArticleException, SystemException {
12209                    int count = countByG_A_ST(groupId, articleId, status);
12210    
12211                    List<JournalArticle> list = findByG_A_ST(groupId, articleId, status,
12212                                    count - 1, count, orderByComparator);
12213    
12214                    if (list.isEmpty()) {
12215                            StringBundler msg = new StringBundler(8);
12216    
12217                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12218    
12219                            msg.append("groupId=");
12220                            msg.append(groupId);
12221    
12222                            msg.append(", articleId=");
12223                            msg.append(articleId);
12224    
12225                            msg.append(", status=");
12226                            msg.append(status);
12227    
12228                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12229    
12230                            throw new NoSuchArticleException(msg.toString());
12231                    }
12232                    else {
12233                            return list.get(0);
12234                    }
12235            }
12236    
12237            /**
12238             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and articleId = &#63; and status = &#63;.
12239             *
12240             * <p>
12241             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12242             * </p>
12243             *
12244             * @param id the primary key of the current journal article
12245             * @param groupId the group ID
12246             * @param articleId the article ID
12247             * @param status the status
12248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12249             * @return the previous, current, and next journal article
12250             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12251             * @throws SystemException if a system exception occurred
12252             */
12253            public JournalArticle[] findByG_A_ST_PrevAndNext(long id, long groupId,
12254                    String articleId, int status, OrderByComparator orderByComparator)
12255                    throws NoSuchArticleException, SystemException {
12256                    JournalArticle journalArticle = findByPrimaryKey(id);
12257    
12258                    Session session = null;
12259    
12260                    try {
12261                            session = openSession();
12262    
12263                            JournalArticle[] array = new JournalArticleImpl[3];
12264    
12265                            array[0] = getByG_A_ST_PrevAndNext(session, journalArticle,
12266                                            groupId, articleId, status, orderByComparator, true);
12267    
12268                            array[1] = journalArticle;
12269    
12270                            array[2] = getByG_A_ST_PrevAndNext(session, journalArticle,
12271                                            groupId, articleId, status, orderByComparator, false);
12272    
12273                            return array;
12274                    }
12275                    catch (Exception e) {
12276                            throw processException(e);
12277                    }
12278                    finally {
12279                            closeSession(session);
12280                    }
12281            }
12282    
12283            protected JournalArticle getByG_A_ST_PrevAndNext(Session session,
12284                    JournalArticle journalArticle, long groupId, String articleId,
12285                    int status, OrderByComparator orderByComparator, boolean previous) {
12286                    StringBundler query = null;
12287    
12288                    if (orderByComparator != null) {
12289                            query = new StringBundler(6 +
12290                                            (orderByComparator.getOrderByFields().length * 6));
12291                    }
12292                    else {
12293                            query = new StringBundler(3);
12294                    }
12295    
12296                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12297    
12298                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12299    
12300                    if (articleId == null) {
12301                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12302                    }
12303                    else {
12304                            if (articleId.equals(StringPool.BLANK)) {
12305                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12306                            }
12307                            else {
12308                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12309                            }
12310                    }
12311    
12312                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12313    
12314                    if (orderByComparator != null) {
12315                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12316    
12317                            if (orderByConditionFields.length > 0) {
12318                                    query.append(WHERE_AND);
12319                            }
12320    
12321                            for (int i = 0; i < orderByConditionFields.length; i++) {
12322                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12323                                    query.append(orderByConditionFields[i]);
12324    
12325                                    if ((i + 1) < orderByConditionFields.length) {
12326                                            if (orderByComparator.isAscending() ^ previous) {
12327                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12328                                            }
12329                                            else {
12330                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12331                                            }
12332                                    }
12333                                    else {
12334                                            if (orderByComparator.isAscending() ^ previous) {
12335                                                    query.append(WHERE_GREATER_THAN);
12336                                            }
12337                                            else {
12338                                                    query.append(WHERE_LESSER_THAN);
12339                                            }
12340                                    }
12341                            }
12342    
12343                            query.append(ORDER_BY_CLAUSE);
12344    
12345                            String[] orderByFields = orderByComparator.getOrderByFields();
12346    
12347                            for (int i = 0; i < orderByFields.length; i++) {
12348                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12349                                    query.append(orderByFields[i]);
12350    
12351                                    if ((i + 1) < orderByFields.length) {
12352                                            if (orderByComparator.isAscending() ^ previous) {
12353                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12354                                            }
12355                                            else {
12356                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12357                                            }
12358                                    }
12359                                    else {
12360                                            if (orderByComparator.isAscending() ^ previous) {
12361                                                    query.append(ORDER_BY_ASC);
12362                                            }
12363                                            else {
12364                                                    query.append(ORDER_BY_DESC);
12365                                            }
12366                                    }
12367                            }
12368                    }
12369    
12370                    else {
12371                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12372                    }
12373    
12374                    String sql = query.toString();
12375    
12376                    Query q = session.createQuery(sql);
12377    
12378                    q.setFirstResult(0);
12379                    q.setMaxResults(2);
12380    
12381                    QueryPos qPos = QueryPos.getInstance(q);
12382    
12383                    qPos.add(groupId);
12384    
12385                    if (articleId != null) {
12386                            qPos.add(articleId);
12387                    }
12388    
12389                    qPos.add(status);
12390    
12391                    if (orderByComparator != null) {
12392                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12393    
12394                            for (Object value : values) {
12395                                    qPos.add(value);
12396                            }
12397                    }
12398    
12399                    List<JournalArticle> list = q.list();
12400    
12401                    if (list.size() == 2) {
12402                            return list.get(1);
12403                    }
12404                    else {
12405                            return null;
12406                    }
12407            }
12408    
12409            /**
12410             * Returns all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
12411             *
12412             * @param groupId the group ID
12413             * @param articleId the article ID
12414             * @param status the status
12415             * @return the matching journal articles that the user has permission to view
12416             * @throws SystemException if a system exception occurred
12417             */
12418            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12419                    String articleId, int status) throws SystemException {
12420                    return filterFindByG_A_ST(groupId, articleId, status,
12421                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12422            }
12423    
12424            /**
12425             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#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 status the status
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             * @return the range of matching journal articles that the user has permission to view
12437             * @throws SystemException if a system exception occurred
12438             */
12439            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12440                    String articleId, int status, int start, int end)
12441                    throws SystemException {
12442                    return filterFindByG_A_ST(groupId, articleId, status, start, end, null);
12443            }
12444    
12445            /**
12446             * 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;.
12447             *
12448             * <p>
12449             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12450             * </p>
12451             *
12452             * @param groupId the group ID
12453             * @param articleId the article ID
12454             * @param status the status
12455             * @param start the lower bound of the range of journal articles
12456             * @param end the upper bound of the range of journal articles (not inclusive)
12457             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12458             * @return the ordered range of matching journal articles that the user has permission to view
12459             * @throws SystemException if a system exception occurred
12460             */
12461            public List<JournalArticle> filterFindByG_A_ST(long groupId,
12462                    String articleId, int status, int start, int end,
12463                    OrderByComparator orderByComparator) throws SystemException {
12464                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12465                            return findByG_A_ST(groupId, articleId, status, start, end,
12466                                    orderByComparator);
12467                    }
12468    
12469                    StringBundler query = null;
12470    
12471                    if (orderByComparator != null) {
12472                            query = new StringBundler(5 +
12473                                            (orderByComparator.getOrderByFields().length * 3));
12474                    }
12475                    else {
12476                            query = new StringBundler(5);
12477                    }
12478    
12479                    if (getDB().isSupportsInlineDistinct()) {
12480                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12481                    }
12482                    else {
12483                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12484                    }
12485    
12486                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12487    
12488                    if (articleId == null) {
12489                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12490                    }
12491                    else {
12492                            if (articleId.equals(StringPool.BLANK)) {
12493                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12494                            }
12495                            else {
12496                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12497                            }
12498                    }
12499    
12500                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12501    
12502                    if (!getDB().isSupportsInlineDistinct()) {
12503                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12504                    }
12505    
12506                    if (orderByComparator != null) {
12507                            if (getDB().isSupportsInlineDistinct()) {
12508                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12509                                            orderByComparator);
12510                            }
12511                            else {
12512                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12513                                            orderByComparator);
12514                            }
12515                    }
12516    
12517                    else {
12518                            if (getDB().isSupportsInlineDistinct()) {
12519                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12520                            }
12521                            else {
12522                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12523                            }
12524                    }
12525    
12526                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12527                                    JournalArticle.class.getName(),
12528                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12529    
12530                    Session session = null;
12531    
12532                    try {
12533                            session = openSession();
12534    
12535                            SQLQuery q = session.createSQLQuery(sql);
12536    
12537                            if (getDB().isSupportsInlineDistinct()) {
12538                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12539                            }
12540                            else {
12541                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12542                            }
12543    
12544                            QueryPos qPos = QueryPos.getInstance(q);
12545    
12546                            qPos.add(groupId);
12547    
12548                            if (articleId != null) {
12549                                    qPos.add(articleId);
12550                            }
12551    
12552                            qPos.add(status);
12553    
12554                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
12555                                    end);
12556                    }
12557                    catch (Exception e) {
12558                            throw processException(e);
12559                    }
12560                    finally {
12561                            closeSession(session);
12562                    }
12563            }
12564    
12565            /**
12566             * 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;.
12567             *
12568             * @param id the primary key of the current journal article
12569             * @param groupId the group ID
12570             * @param articleId the article ID
12571             * @param status the status
12572             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12573             * @return the previous, current, and next journal article
12574             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
12575             * @throws SystemException if a system exception occurred
12576             */
12577            public JournalArticle[] filterFindByG_A_ST_PrevAndNext(long id,
12578                    long groupId, String articleId, int status,
12579                    OrderByComparator orderByComparator)
12580                    throws NoSuchArticleException, SystemException {
12581                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12582                            return findByG_A_ST_PrevAndNext(id, groupId, articleId, status,
12583                                    orderByComparator);
12584                    }
12585    
12586                    JournalArticle journalArticle = findByPrimaryKey(id);
12587    
12588                    Session session = null;
12589    
12590                    try {
12591                            session = openSession();
12592    
12593                            JournalArticle[] array = new JournalArticleImpl[3];
12594    
12595                            array[0] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
12596                                            groupId, articleId, status, orderByComparator, true);
12597    
12598                            array[1] = journalArticle;
12599    
12600                            array[2] = filterGetByG_A_ST_PrevAndNext(session, journalArticle,
12601                                            groupId, articleId, status, orderByComparator, false);
12602    
12603                            return array;
12604                    }
12605                    catch (Exception e) {
12606                            throw processException(e);
12607                    }
12608                    finally {
12609                            closeSession(session);
12610                    }
12611            }
12612    
12613            protected JournalArticle filterGetByG_A_ST_PrevAndNext(Session session,
12614                    JournalArticle journalArticle, long groupId, String articleId,
12615                    int status, OrderByComparator orderByComparator, boolean previous) {
12616                    StringBundler query = null;
12617    
12618                    if (orderByComparator != null) {
12619                            query = new StringBundler(6 +
12620                                            (orderByComparator.getOrderByFields().length * 6));
12621                    }
12622                    else {
12623                            query = new StringBundler(3);
12624                    }
12625    
12626                    if (getDB().isSupportsInlineDistinct()) {
12627                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
12628                    }
12629                    else {
12630                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
12631                    }
12632    
12633                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
12634    
12635                    if (articleId == null) {
12636                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
12637                    }
12638                    else {
12639                            if (articleId.equals(StringPool.BLANK)) {
12640                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
12641                            }
12642                            else {
12643                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
12644                            }
12645                    }
12646    
12647                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
12648    
12649                    if (!getDB().isSupportsInlineDistinct()) {
12650                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
12651                    }
12652    
12653                    if (orderByComparator != null) {
12654                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12655    
12656                            if (orderByConditionFields.length > 0) {
12657                                    query.append(WHERE_AND);
12658                            }
12659    
12660                            for (int i = 0; i < orderByConditionFields.length; i++) {
12661                                    if (getDB().isSupportsInlineDistinct()) {
12662                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12663                                    }
12664                                    else {
12665                                            query.append(_ORDER_BY_ENTITY_TABLE);
12666                                    }
12667    
12668                                    query.append(orderByConditionFields[i]);
12669    
12670                                    if ((i + 1) < orderByConditionFields.length) {
12671                                            if (orderByComparator.isAscending() ^ previous) {
12672                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12673                                            }
12674                                            else {
12675                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12676                                            }
12677                                    }
12678                                    else {
12679                                            if (orderByComparator.isAscending() ^ previous) {
12680                                                    query.append(WHERE_GREATER_THAN);
12681                                            }
12682                                            else {
12683                                                    query.append(WHERE_LESSER_THAN);
12684                                            }
12685                                    }
12686                            }
12687    
12688                            query.append(ORDER_BY_CLAUSE);
12689    
12690                            String[] orderByFields = orderByComparator.getOrderByFields();
12691    
12692                            for (int i = 0; i < orderByFields.length; i++) {
12693                                    if (getDB().isSupportsInlineDistinct()) {
12694                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12695                                    }
12696                                    else {
12697                                            query.append(_ORDER_BY_ENTITY_TABLE);
12698                                    }
12699    
12700                                    query.append(orderByFields[i]);
12701    
12702                                    if ((i + 1) < orderByFields.length) {
12703                                            if (orderByComparator.isAscending() ^ previous) {
12704                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12705                                            }
12706                                            else {
12707                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12708                                            }
12709                                    }
12710                                    else {
12711                                            if (orderByComparator.isAscending() ^ previous) {
12712                                                    query.append(ORDER_BY_ASC);
12713                                            }
12714                                            else {
12715                                                    query.append(ORDER_BY_DESC);
12716                                            }
12717                                    }
12718                            }
12719                    }
12720    
12721                    else {
12722                            if (getDB().isSupportsInlineDistinct()) {
12723                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12724                            }
12725                            else {
12726                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
12727                            }
12728                    }
12729    
12730                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12731                                    JournalArticle.class.getName(),
12732                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12733    
12734                    SQLQuery q = session.createSQLQuery(sql);
12735    
12736                    q.setFirstResult(0);
12737                    q.setMaxResults(2);
12738    
12739                    if (getDB().isSupportsInlineDistinct()) {
12740                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
12741                    }
12742                    else {
12743                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
12744                    }
12745    
12746                    QueryPos qPos = QueryPos.getInstance(q);
12747    
12748                    qPos.add(groupId);
12749    
12750                    if (articleId != null) {
12751                            qPos.add(articleId);
12752                    }
12753    
12754                    qPos.add(status);
12755    
12756                    if (orderByComparator != null) {
12757                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
12758    
12759                            for (Object value : values) {
12760                                    qPos.add(value);
12761                            }
12762                    }
12763    
12764                    List<JournalArticle> list = q.list();
12765    
12766                    if (list.size() == 2) {
12767                            return list.get(1);
12768                    }
12769                    else {
12770                            return null;
12771                    }
12772            }
12773    
12774            /**
12775             * Returns all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12776             *
12777             * @param groupId the group ID
12778             * @param urlTitle the url title
12779             * @param status the status
12780             * @return the matching journal articles
12781             * @throws SystemException if a system exception occurred
12782             */
12783            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
12784                    int status) throws SystemException {
12785                    return findByG_UT_ST(groupId, urlTitle, status, QueryUtil.ALL_POS,
12786                            QueryUtil.ALL_POS, null);
12787            }
12788    
12789            /**
12790             * Returns a range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12791             *
12792             * <p>
12793             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12794             * </p>
12795             *
12796             * @param groupId the group ID
12797             * @param urlTitle the url title
12798             * @param status the status
12799             * @param start the lower bound of the range of journal articles
12800             * @param end the upper bound of the range of journal articles (not inclusive)
12801             * @return the range of matching journal articles
12802             * @throws SystemException if a system exception occurred
12803             */
12804            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
12805                    int status, int start, int end) throws SystemException {
12806                    return findByG_UT_ST(groupId, urlTitle, status, start, end, null);
12807            }
12808    
12809            /**
12810             * Returns an ordered range of all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12811             *
12812             * <p>
12813             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12814             * </p>
12815             *
12816             * @param groupId the group ID
12817             * @param urlTitle the url title
12818             * @param status the status
12819             * @param start the lower bound of the range of journal articles
12820             * @param end the upper bound of the range of journal articles (not inclusive)
12821             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12822             * @return the ordered range of matching journal articles
12823             * @throws SystemException if a system exception occurred
12824             */
12825            public List<JournalArticle> findByG_UT_ST(long groupId, String urlTitle,
12826                    int status, int start, int end, OrderByComparator orderByComparator)
12827                    throws SystemException {
12828                    FinderPath finderPath = null;
12829                    Object[] finderArgs = null;
12830    
12831                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12832                                    (orderByComparator == null)) {
12833                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_UT_ST;
12834                            finderArgs = new Object[] { groupId, urlTitle, status };
12835                    }
12836                    else {
12837                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_UT_ST;
12838                            finderArgs = new Object[] {
12839                                            groupId, urlTitle, status,
12840                                            
12841                                            start, end, orderByComparator
12842                                    };
12843                    }
12844    
12845                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
12846                                    finderArgs, this);
12847    
12848                    if (list == null) {
12849                            StringBundler query = null;
12850    
12851                            if (orderByComparator != null) {
12852                                    query = new StringBundler(5 +
12853                                                    (orderByComparator.getOrderByFields().length * 3));
12854                            }
12855                            else {
12856                                    query = new StringBundler(5);
12857                            }
12858    
12859                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
12860    
12861                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
12862    
12863                            if (urlTitle == null) {
12864                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
12865                            }
12866                            else {
12867                                    if (urlTitle.equals(StringPool.BLANK)) {
12868                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
12869                                    }
12870                                    else {
12871                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
12872                                    }
12873                            }
12874    
12875                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
12876    
12877                            if (orderByComparator != null) {
12878                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12879                                            orderByComparator);
12880                            }
12881    
12882                            else {
12883                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
12884                            }
12885    
12886                            String sql = query.toString();
12887    
12888                            Session session = null;
12889    
12890                            try {
12891                                    session = openSession();
12892    
12893                                    Query q = session.createQuery(sql);
12894    
12895                                    QueryPos qPos = QueryPos.getInstance(q);
12896    
12897                                    qPos.add(groupId);
12898    
12899                                    if (urlTitle != null) {
12900                                            qPos.add(urlTitle);
12901                                    }
12902    
12903                                    qPos.add(status);
12904    
12905                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
12906                                                    start, end);
12907                            }
12908                            catch (Exception e) {
12909                                    throw processException(e);
12910                            }
12911                            finally {
12912                                    if (list == null) {
12913                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12914                                    }
12915                                    else {
12916                                            cacheResult(list);
12917    
12918                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12919                                    }
12920    
12921                                    closeSession(session);
12922                            }
12923                    }
12924    
12925                    return list;
12926            }
12927    
12928            /**
12929             * Returns the first journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
12930             *
12931             * <p>
12932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12933             * </p>
12934             *
12935             * @param groupId the group ID
12936             * @param urlTitle the url title
12937             * @param status the status
12938             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12939             * @return the first matching journal article
12940             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12941             * @throws SystemException if a system exception occurred
12942             */
12943            public JournalArticle findByG_UT_ST_First(long groupId, String urlTitle,
12944                    int status, OrderByComparator orderByComparator)
12945                    throws NoSuchArticleException, SystemException {
12946                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status, 0,
12947                                    1, orderByComparator);
12948    
12949                    if (list.isEmpty()) {
12950                            StringBundler msg = new StringBundler(8);
12951    
12952                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12953    
12954                            msg.append("groupId=");
12955                            msg.append(groupId);
12956    
12957                            msg.append(", urlTitle=");
12958                            msg.append(urlTitle);
12959    
12960                            msg.append(", status=");
12961                            msg.append(status);
12962    
12963                            msg.append(StringPool.CLOSE_CURLY_BRACE);
12964    
12965                            throw new NoSuchArticleException(msg.toString());
12966                    }
12967                    else {
12968                            return list.get(0);
12969                    }
12970            }
12971    
12972            /**
12973             * Returns the last journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#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 urlTitle the url title
12981             * @param status the status
12982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12983             * @return the last matching journal article
12984             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
12985             * @throws SystemException if a system exception occurred
12986             */
12987            public JournalArticle findByG_UT_ST_Last(long groupId, String urlTitle,
12988                    int status, OrderByComparator orderByComparator)
12989                    throws NoSuchArticleException, SystemException {
12990                    int count = countByG_UT_ST(groupId, urlTitle, status);
12991    
12992                    List<JournalArticle> list = findByG_UT_ST(groupId, urlTitle, status,
12993                                    count - 1, count, orderByComparator);
12994    
12995                    if (list.isEmpty()) {
12996                            StringBundler msg = new StringBundler(8);
12997    
12998                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12999    
13000                            msg.append("groupId=");
13001                            msg.append(groupId);
13002    
13003                            msg.append(", urlTitle=");
13004                            msg.append(urlTitle);
13005    
13006                            msg.append(", status=");
13007                            msg.append(status);
13008    
13009                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13010    
13011                            throw new NoSuchArticleException(msg.toString());
13012                    }
13013                    else {
13014                            return list.get(0);
13015                    }
13016            }
13017    
13018            /**
13019             * Returns the journal articles before and after the current journal article in the ordered set where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13020             *
13021             * <p>
13022             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13023             * </p>
13024             *
13025             * @param id the primary key of the current journal article
13026             * @param groupId the group ID
13027             * @param urlTitle the url title
13028             * @param status the status
13029             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13030             * @return the previous, current, and next journal article
13031             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13032             * @throws SystemException if a system exception occurred
13033             */
13034            public JournalArticle[] findByG_UT_ST_PrevAndNext(long id, long groupId,
13035                    String urlTitle, int status, OrderByComparator orderByComparator)
13036                    throws NoSuchArticleException, SystemException {
13037                    JournalArticle journalArticle = findByPrimaryKey(id);
13038    
13039                    Session session = null;
13040    
13041                    try {
13042                            session = openSession();
13043    
13044                            JournalArticle[] array = new JournalArticleImpl[3];
13045    
13046                            array[0] = getByG_UT_ST_PrevAndNext(session, journalArticle,
13047                                            groupId, urlTitle, status, orderByComparator, true);
13048    
13049                            array[1] = journalArticle;
13050    
13051                            array[2] = getByG_UT_ST_PrevAndNext(session, journalArticle,
13052                                            groupId, urlTitle, status, orderByComparator, false);
13053    
13054                            return array;
13055                    }
13056                    catch (Exception e) {
13057                            throw processException(e);
13058                    }
13059                    finally {
13060                            closeSession(session);
13061                    }
13062            }
13063    
13064            protected JournalArticle getByG_UT_ST_PrevAndNext(Session session,
13065                    JournalArticle journalArticle, long groupId, String urlTitle,
13066                    int status, OrderByComparator orderByComparator, boolean previous) {
13067                    StringBundler query = null;
13068    
13069                    if (orderByComparator != null) {
13070                            query = new StringBundler(6 +
13071                                            (orderByComparator.getOrderByFields().length * 6));
13072                    }
13073                    else {
13074                            query = new StringBundler(3);
13075                    }
13076    
13077                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13078    
13079                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13080    
13081                    if (urlTitle == null) {
13082                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13083                    }
13084                    else {
13085                            if (urlTitle.equals(StringPool.BLANK)) {
13086                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13087                            }
13088                            else {
13089                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13090                            }
13091                    }
13092    
13093                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13094    
13095                    if (orderByComparator != null) {
13096                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13097    
13098                            if (orderByConditionFields.length > 0) {
13099                                    query.append(WHERE_AND);
13100                            }
13101    
13102                            for (int i = 0; i < orderByConditionFields.length; i++) {
13103                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13104                                    query.append(orderByConditionFields[i]);
13105    
13106                                    if ((i + 1) < orderByConditionFields.length) {
13107                                            if (orderByComparator.isAscending() ^ previous) {
13108                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13109                                            }
13110                                            else {
13111                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13112                                            }
13113                                    }
13114                                    else {
13115                                            if (orderByComparator.isAscending() ^ previous) {
13116                                                    query.append(WHERE_GREATER_THAN);
13117                                            }
13118                                            else {
13119                                                    query.append(WHERE_LESSER_THAN);
13120                                            }
13121                                    }
13122                            }
13123    
13124                            query.append(ORDER_BY_CLAUSE);
13125    
13126                            String[] orderByFields = orderByComparator.getOrderByFields();
13127    
13128                            for (int i = 0; i < orderByFields.length; i++) {
13129                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13130                                    query.append(orderByFields[i]);
13131    
13132                                    if ((i + 1) < orderByFields.length) {
13133                                            if (orderByComparator.isAscending() ^ previous) {
13134                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13135                                            }
13136                                            else {
13137                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13138                                            }
13139                                    }
13140                                    else {
13141                                            if (orderByComparator.isAscending() ^ previous) {
13142                                                    query.append(ORDER_BY_ASC);
13143                                            }
13144                                            else {
13145                                                    query.append(ORDER_BY_DESC);
13146                                            }
13147                                    }
13148                            }
13149                    }
13150    
13151                    else {
13152                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13153                    }
13154    
13155                    String sql = query.toString();
13156    
13157                    Query q = session.createQuery(sql);
13158    
13159                    q.setFirstResult(0);
13160                    q.setMaxResults(2);
13161    
13162                    QueryPos qPos = QueryPos.getInstance(q);
13163    
13164                    qPos.add(groupId);
13165    
13166                    if (urlTitle != null) {
13167                            qPos.add(urlTitle);
13168                    }
13169    
13170                    qPos.add(status);
13171    
13172                    if (orderByComparator != null) {
13173                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13174    
13175                            for (Object value : values) {
13176                                    qPos.add(value);
13177                            }
13178                    }
13179    
13180                    List<JournalArticle> list = q.list();
13181    
13182                    if (list.size() == 2) {
13183                            return list.get(1);
13184                    }
13185                    else {
13186                            return null;
13187                    }
13188            }
13189    
13190            /**
13191             * Returns all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13192             *
13193             * @param groupId the group ID
13194             * @param urlTitle the url title
13195             * @param status the status
13196             * @return the matching journal articles that the user has permission to view
13197             * @throws SystemException if a system exception occurred
13198             */
13199            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13200                    String urlTitle, int status) throws SystemException {
13201                    return filterFindByG_UT_ST(groupId, urlTitle, status,
13202                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13203            }
13204    
13205            /**
13206             * Returns a range of all the journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
13207             *
13208             * <p>
13209             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13210             * </p>
13211             *
13212             * @param groupId the group ID
13213             * @param urlTitle the url title
13214             * @param status the status
13215             * @param start the lower bound of the range of journal articles
13216             * @param end the upper bound of the range of journal articles (not inclusive)
13217             * @return the range of matching journal articles that the user has permission to view
13218             * @throws SystemException if a system exception occurred
13219             */
13220            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13221                    String urlTitle, int status, int start, int end)
13222                    throws SystemException {
13223                    return filterFindByG_UT_ST(groupId, urlTitle, status, start, end, null);
13224            }
13225    
13226            /**
13227             * 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;.
13228             *
13229             * <p>
13230             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13231             * </p>
13232             *
13233             * @param groupId the group ID
13234             * @param urlTitle the url title
13235             * @param status the status
13236             * @param start the lower bound of the range of journal articles
13237             * @param end the upper bound of the range of journal articles (not inclusive)
13238             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13239             * @return the ordered range of matching journal articles that the user has permission to view
13240             * @throws SystemException if a system exception occurred
13241             */
13242            public List<JournalArticle> filterFindByG_UT_ST(long groupId,
13243                    String urlTitle, int status, int start, int end,
13244                    OrderByComparator orderByComparator) throws SystemException {
13245                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13246                            return findByG_UT_ST(groupId, urlTitle, status, start, end,
13247                                    orderByComparator);
13248                    }
13249    
13250                    StringBundler query = null;
13251    
13252                    if (orderByComparator != null) {
13253                            query = new StringBundler(5 +
13254                                            (orderByComparator.getOrderByFields().length * 3));
13255                    }
13256                    else {
13257                            query = new StringBundler(5);
13258                    }
13259    
13260                    if (getDB().isSupportsInlineDistinct()) {
13261                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13262                    }
13263                    else {
13264                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13265                    }
13266    
13267                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13268    
13269                    if (urlTitle == null) {
13270                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13271                    }
13272                    else {
13273                            if (urlTitle.equals(StringPool.BLANK)) {
13274                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13275                            }
13276                            else {
13277                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13278                            }
13279                    }
13280    
13281                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13282    
13283                    if (!getDB().isSupportsInlineDistinct()) {
13284                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13285                    }
13286    
13287                    if (orderByComparator != null) {
13288                            if (getDB().isSupportsInlineDistinct()) {
13289                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13290                                            orderByComparator);
13291                            }
13292                            else {
13293                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13294                                            orderByComparator);
13295                            }
13296                    }
13297    
13298                    else {
13299                            if (getDB().isSupportsInlineDistinct()) {
13300                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13301                            }
13302                            else {
13303                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13304                            }
13305                    }
13306    
13307                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13308                                    JournalArticle.class.getName(),
13309                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13310    
13311                    Session session = null;
13312    
13313                    try {
13314                            session = openSession();
13315    
13316                            SQLQuery q = session.createSQLQuery(sql);
13317    
13318                            if (getDB().isSupportsInlineDistinct()) {
13319                                    q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13320                            }
13321                            else {
13322                                    q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13323                            }
13324    
13325                            QueryPos qPos = QueryPos.getInstance(q);
13326    
13327                            qPos.add(groupId);
13328    
13329                            if (urlTitle != null) {
13330                                    qPos.add(urlTitle);
13331                            }
13332    
13333                            qPos.add(status);
13334    
13335                            return (List<JournalArticle>)QueryUtil.list(q, getDialect(), start,
13336                                    end);
13337                    }
13338                    catch (Exception e) {
13339                            throw processException(e);
13340                    }
13341                    finally {
13342                            closeSession(session);
13343                    }
13344            }
13345    
13346            /**
13347             * 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;.
13348             *
13349             * @param id the primary key of the current journal article
13350             * @param groupId the group ID
13351             * @param urlTitle the url title
13352             * @param status the status
13353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13354             * @return the previous, current, and next journal article
13355             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13356             * @throws SystemException if a system exception occurred
13357             */
13358            public JournalArticle[] filterFindByG_UT_ST_PrevAndNext(long id,
13359                    long groupId, String urlTitle, int status,
13360                    OrderByComparator orderByComparator)
13361                    throws NoSuchArticleException, SystemException {
13362                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13363                            return findByG_UT_ST_PrevAndNext(id, groupId, urlTitle, status,
13364                                    orderByComparator);
13365                    }
13366    
13367                    JournalArticle journalArticle = findByPrimaryKey(id);
13368    
13369                    Session session = null;
13370    
13371                    try {
13372                            session = openSession();
13373    
13374                            JournalArticle[] array = new JournalArticleImpl[3];
13375    
13376                            array[0] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
13377                                            groupId, urlTitle, status, orderByComparator, true);
13378    
13379                            array[1] = journalArticle;
13380    
13381                            array[2] = filterGetByG_UT_ST_PrevAndNext(session, journalArticle,
13382                                            groupId, urlTitle, status, orderByComparator, false);
13383    
13384                            return array;
13385                    }
13386                    catch (Exception e) {
13387                            throw processException(e);
13388                    }
13389                    finally {
13390                            closeSession(session);
13391                    }
13392            }
13393    
13394            protected JournalArticle filterGetByG_UT_ST_PrevAndNext(Session session,
13395                    JournalArticle journalArticle, long groupId, String urlTitle,
13396                    int status, OrderByComparator orderByComparator, boolean previous) {
13397                    StringBundler query = null;
13398    
13399                    if (orderByComparator != null) {
13400                            query = new StringBundler(6 +
13401                                            (orderByComparator.getOrderByFields().length * 6));
13402                    }
13403                    else {
13404                            query = new StringBundler(3);
13405                    }
13406    
13407                    if (getDB().isSupportsInlineDistinct()) {
13408                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_WHERE);
13409                    }
13410                    else {
13411                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1);
13412                    }
13413    
13414                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
13415    
13416                    if (urlTitle == null) {
13417                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
13418                    }
13419                    else {
13420                            if (urlTitle.equals(StringPool.BLANK)) {
13421                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
13422                            }
13423                            else {
13424                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
13425                            }
13426                    }
13427    
13428                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
13429    
13430                    if (!getDB().isSupportsInlineDistinct()) {
13431                            query.append(_FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2);
13432                    }
13433    
13434                    if (orderByComparator != null) {
13435                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13436    
13437                            if (orderByConditionFields.length > 0) {
13438                                    query.append(WHERE_AND);
13439                            }
13440    
13441                            for (int i = 0; i < orderByConditionFields.length; i++) {
13442                                    if (getDB().isSupportsInlineDistinct()) {
13443                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13444                                    }
13445                                    else {
13446                                            query.append(_ORDER_BY_ENTITY_TABLE);
13447                                    }
13448    
13449                                    query.append(orderByConditionFields[i]);
13450    
13451                                    if ((i + 1) < orderByConditionFields.length) {
13452                                            if (orderByComparator.isAscending() ^ previous) {
13453                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13454                                            }
13455                                            else {
13456                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13457                                            }
13458                                    }
13459                                    else {
13460                                            if (orderByComparator.isAscending() ^ previous) {
13461                                                    query.append(WHERE_GREATER_THAN);
13462                                            }
13463                                            else {
13464                                                    query.append(WHERE_LESSER_THAN);
13465                                            }
13466                                    }
13467                            }
13468    
13469                            query.append(ORDER_BY_CLAUSE);
13470    
13471                            String[] orderByFields = orderByComparator.getOrderByFields();
13472    
13473                            for (int i = 0; i < orderByFields.length; i++) {
13474                                    if (getDB().isSupportsInlineDistinct()) {
13475                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13476                                    }
13477                                    else {
13478                                            query.append(_ORDER_BY_ENTITY_TABLE);
13479                                    }
13480    
13481                                    query.append(orderByFields[i]);
13482    
13483                                    if ((i + 1) < orderByFields.length) {
13484                                            if (orderByComparator.isAscending() ^ previous) {
13485                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13486                                            }
13487                                            else {
13488                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13489                                            }
13490                                    }
13491                                    else {
13492                                            if (orderByComparator.isAscending() ^ previous) {
13493                                                    query.append(ORDER_BY_ASC);
13494                                            }
13495                                            else {
13496                                                    query.append(ORDER_BY_DESC);
13497                                            }
13498                                    }
13499                            }
13500                    }
13501    
13502                    else {
13503                            if (getDB().isSupportsInlineDistinct()) {
13504                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13505                            }
13506                            else {
13507                                    query.append(JournalArticleModelImpl.ORDER_BY_SQL);
13508                            }
13509                    }
13510    
13511                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13512                                    JournalArticle.class.getName(),
13513                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13514    
13515                    SQLQuery q = session.createSQLQuery(sql);
13516    
13517                    q.setFirstResult(0);
13518                    q.setMaxResults(2);
13519    
13520                    if (getDB().isSupportsInlineDistinct()) {
13521                            q.addEntity(_FILTER_ENTITY_ALIAS, JournalArticleImpl.class);
13522                    }
13523                    else {
13524                            q.addEntity(_FILTER_ENTITY_TABLE, JournalArticleImpl.class);
13525                    }
13526    
13527                    QueryPos qPos = QueryPos.getInstance(q);
13528    
13529                    qPos.add(groupId);
13530    
13531                    if (urlTitle != null) {
13532                            qPos.add(urlTitle);
13533                    }
13534    
13535                    qPos.add(status);
13536    
13537                    if (orderByComparator != null) {
13538                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13539    
13540                            for (Object value : values) {
13541                                    qPos.add(value);
13542                            }
13543                    }
13544    
13545                    List<JournalArticle> list = q.list();
13546    
13547                    if (list.size() == 2) {
13548                            return list.get(1);
13549                    }
13550                    else {
13551                            return null;
13552                    }
13553            }
13554    
13555            /**
13556             * Returns all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13557             *
13558             * @param companyId the company ID
13559             * @param version the version
13560             * @param status the status
13561             * @return the matching journal articles
13562             * @throws SystemException if a system exception occurred
13563             */
13564            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13565                    int status) throws SystemException {
13566                    return findByC_V_ST(companyId, version, status, QueryUtil.ALL_POS,
13567                            QueryUtil.ALL_POS, null);
13568            }
13569    
13570            /**
13571             * Returns a range of all the journal articles where companyId = &#63; and version = &#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 companyId the company ID
13578             * @param version the version
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             * @return the range of matching journal articles
13583             * @throws SystemException if a system exception occurred
13584             */
13585            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13586                    int status, int start, int end) throws SystemException {
13587                    return findByC_V_ST(companyId, version, status, start, end, null);
13588            }
13589    
13590            /**
13591             * Returns an ordered range of all the journal articles where companyId = &#63; and version = &#63; and status = &#63;.
13592             *
13593             * <p>
13594             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13595             * </p>
13596             *
13597             * @param companyId the company ID
13598             * @param version the version
13599             * @param status the status
13600             * @param start the lower bound of the range of journal articles
13601             * @param end the upper bound of the range of journal articles (not inclusive)
13602             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13603             * @return the ordered range of matching journal articles
13604             * @throws SystemException if a system exception occurred
13605             */
13606            public List<JournalArticle> findByC_V_ST(long companyId, double version,
13607                    int status, int start, int end, OrderByComparator orderByComparator)
13608                    throws SystemException {
13609                    FinderPath finderPath = null;
13610                    Object[] finderArgs = null;
13611    
13612                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13613                                    (orderByComparator == null)) {
13614                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_V_ST;
13615                            finderArgs = new Object[] { companyId, version, status };
13616                    }
13617                    else {
13618                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_V_ST;
13619                            finderArgs = new Object[] {
13620                                            companyId, version, status,
13621                                            
13622                                            start, end, orderByComparator
13623                                    };
13624                    }
13625    
13626                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
13627                                    finderArgs, this);
13628    
13629                    if (list == null) {
13630                            StringBundler query = null;
13631    
13632                            if (orderByComparator != null) {
13633                                    query = new StringBundler(5 +
13634                                                    (orderByComparator.getOrderByFields().length * 3));
13635                            }
13636                            else {
13637                                    query = new StringBundler(5);
13638                            }
13639    
13640                            query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13641    
13642                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
13643    
13644                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
13645    
13646                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
13647    
13648                            if (orderByComparator != null) {
13649                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13650                                            orderByComparator);
13651                            }
13652    
13653                            else {
13654                                    query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13655                            }
13656    
13657                            String sql = query.toString();
13658    
13659                            Session session = null;
13660    
13661                            try {
13662                                    session = openSession();
13663    
13664                                    Query q = session.createQuery(sql);
13665    
13666                                    QueryPos qPos = QueryPos.getInstance(q);
13667    
13668                                    qPos.add(companyId);
13669    
13670                                    qPos.add(version);
13671    
13672                                    qPos.add(status);
13673    
13674                                    list = (List<JournalArticle>)QueryUtil.list(q, getDialect(),
13675                                                    start, end);
13676                            }
13677                            catch (Exception e) {
13678                                    throw processException(e);
13679                            }
13680                            finally {
13681                                    if (list == null) {
13682                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13683                                    }
13684                                    else {
13685                                            cacheResult(list);
13686    
13687                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13688                                    }
13689    
13690                                    closeSession(session);
13691                            }
13692                    }
13693    
13694                    return list;
13695            }
13696    
13697            /**
13698             * Returns the first journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
13699             *
13700             * <p>
13701             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13702             * </p>
13703             *
13704             * @param companyId the company ID
13705             * @param version the version
13706             * @param status the status
13707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13708             * @return the first matching journal article
13709             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13710             * @throws SystemException if a system exception occurred
13711             */
13712            public JournalArticle findByC_V_ST_First(long companyId, double version,
13713                    int status, OrderByComparator orderByComparator)
13714                    throws NoSuchArticleException, SystemException {
13715                    List<JournalArticle> list = findByC_V_ST(companyId, version, status, 0,
13716                                    1, orderByComparator);
13717    
13718                    if (list.isEmpty()) {
13719                            StringBundler msg = new StringBundler(8);
13720    
13721                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13722    
13723                            msg.append("companyId=");
13724                            msg.append(companyId);
13725    
13726                            msg.append(", version=");
13727                            msg.append(version);
13728    
13729                            msg.append(", status=");
13730                            msg.append(status);
13731    
13732                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13733    
13734                            throw new NoSuchArticleException(msg.toString());
13735                    }
13736                    else {
13737                            return list.get(0);
13738                    }
13739            }
13740    
13741            /**
13742             * Returns the last journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
13743             *
13744             * <p>
13745             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13746             * </p>
13747             *
13748             * @param companyId the company ID
13749             * @param version the version
13750             * @param status the status
13751             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13752             * @return the last matching journal article
13753             * @throws com.liferay.portlet.journal.NoSuchArticleException if a matching journal article could not be found
13754             * @throws SystemException if a system exception occurred
13755             */
13756            public JournalArticle findByC_V_ST_Last(long companyId, double version,
13757                    int status, OrderByComparator orderByComparator)
13758                    throws NoSuchArticleException, SystemException {
13759                    int count = countByC_V_ST(companyId, version, status);
13760    
13761                    List<JournalArticle> list = findByC_V_ST(companyId, version, status,
13762                                    count - 1, count, orderByComparator);
13763    
13764                    if (list.isEmpty()) {
13765                            StringBundler msg = new StringBundler(8);
13766    
13767                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13768    
13769                            msg.append("companyId=");
13770                            msg.append(companyId);
13771    
13772                            msg.append(", version=");
13773                            msg.append(version);
13774    
13775                            msg.append(", status=");
13776                            msg.append(status);
13777    
13778                            msg.append(StringPool.CLOSE_CURLY_BRACE);
13779    
13780                            throw new NoSuchArticleException(msg.toString());
13781                    }
13782                    else {
13783                            return list.get(0);
13784                    }
13785            }
13786    
13787            /**
13788             * Returns the journal articles before and after the current journal article in the ordered set where companyId = &#63; and version = &#63; and status = &#63;.
13789             *
13790             * <p>
13791             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13792             * </p>
13793             *
13794             * @param id the primary key of the current journal article
13795             * @param companyId the company ID
13796             * @param version the version
13797             * @param status the status
13798             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13799             * @return the previous, current, and next journal article
13800             * @throws com.liferay.portlet.journal.NoSuchArticleException if a journal article with the primary key could not be found
13801             * @throws SystemException if a system exception occurred
13802             */
13803            public JournalArticle[] findByC_V_ST_PrevAndNext(long id, long companyId,
13804                    double version, int status, OrderByComparator orderByComparator)
13805                    throws NoSuchArticleException, SystemException {
13806                    JournalArticle journalArticle = findByPrimaryKey(id);
13807    
13808                    Session session = null;
13809    
13810                    try {
13811                            session = openSession();
13812    
13813                            JournalArticle[] array = new JournalArticleImpl[3];
13814    
13815                            array[0] = getByC_V_ST_PrevAndNext(session, journalArticle,
13816                                            companyId, version, status, orderByComparator, true);
13817    
13818                            array[1] = journalArticle;
13819    
13820                            array[2] = getByC_V_ST_PrevAndNext(session, journalArticle,
13821                                            companyId, version, status, orderByComparator, false);
13822    
13823                            return array;
13824                    }
13825                    catch (Exception e) {
13826                            throw processException(e);
13827                    }
13828                    finally {
13829                            closeSession(session);
13830                    }
13831            }
13832    
13833            protected JournalArticle getByC_V_ST_PrevAndNext(Session session,
13834                    JournalArticle journalArticle, long companyId, double version,
13835                    int status, OrderByComparator orderByComparator, boolean previous) {
13836                    StringBundler query = null;
13837    
13838                    if (orderByComparator != null) {
13839                            query = new StringBundler(6 +
13840                                            (orderByComparator.getOrderByFields().length * 6));
13841                    }
13842                    else {
13843                            query = new StringBundler(3);
13844                    }
13845    
13846                    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE);
13847    
13848                    query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
13849    
13850                    query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
13851    
13852                    query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
13853    
13854                    if (orderByComparator != null) {
13855                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13856    
13857                            if (orderByConditionFields.length > 0) {
13858                                    query.append(WHERE_AND);
13859                            }
13860    
13861                            for (int i = 0; i < orderByConditionFields.length; i++) {
13862                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13863                                    query.append(orderByConditionFields[i]);
13864    
13865                                    if ((i + 1) < orderByConditionFields.length) {
13866                                            if (orderByComparator.isAscending() ^ previous) {
13867                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13868                                            }
13869                                            else {
13870                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13871                                            }
13872                                    }
13873                                    else {
13874                                            if (orderByComparator.isAscending() ^ previous) {
13875                                                    query.append(WHERE_GREATER_THAN);
13876                                            }
13877                                            else {
13878                                                    query.append(WHERE_LESSER_THAN);
13879                                            }
13880                                    }
13881                            }
13882    
13883                            query.append(ORDER_BY_CLAUSE);
13884    
13885                            String[] orderByFields = orderByComparator.getOrderByFields();
13886    
13887                            for (int i = 0; i < orderByFields.length; i++) {
13888                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13889                                    query.append(orderByFields[i]);
13890    
13891                                    if ((i + 1) < orderByFields.length) {
13892                                            if (orderByComparator.isAscending() ^ previous) {
13893                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13894                                            }
13895                                            else {
13896                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13897                                            }
13898                                    }
13899                                    else {
13900                                            if (orderByComparator.isAscending() ^ previous) {
13901                                                    query.append(ORDER_BY_ASC);
13902                                            }
13903                                            else {
13904                                                    query.append(ORDER_BY_DESC);
13905                                            }
13906                                    }
13907                            }
13908                    }
13909    
13910                    else {
13911                            query.append(JournalArticleModelImpl.ORDER_BY_JPQL);
13912                    }
13913    
13914                    String sql = query.toString();
13915    
13916                    Query q = session.createQuery(sql);
13917    
13918                    q.setFirstResult(0);
13919                    q.setMaxResults(2);
13920    
13921                    QueryPos qPos = QueryPos.getInstance(q);
13922    
13923                    qPos.add(companyId);
13924    
13925                    qPos.add(version);
13926    
13927                    qPos.add(status);
13928    
13929                    if (orderByComparator != null) {
13930                            Object[] values = orderByComparator.getOrderByConditionValues(journalArticle);
13931    
13932                            for (Object value : values) {
13933                                    qPos.add(value);
13934                            }
13935                    }
13936    
13937                    List<JournalArticle> list = q.list();
13938    
13939                    if (list.size() == 2) {
13940                            return list.get(1);
13941                    }
13942                    else {
13943                            return null;
13944                    }
13945            }
13946    
13947            /**
13948             * Returns all the journal articles.
13949             *
13950             * @return the journal articles
13951             * @throws SystemException if a system exception occurred
13952             */
13953            public List<JournalArticle> findAll() throws SystemException {
13954                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13955            }
13956    
13957            /**
13958             * Returns a range of all the journal articles.
13959             *
13960             * <p>
13961             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13962             * </p>
13963             *
13964             * @param start the lower bound of the range of journal articles
13965             * @param end the upper bound of the range of journal articles (not inclusive)
13966             * @return the range of journal articles
13967             * @throws SystemException if a system exception occurred
13968             */
13969            public List<JournalArticle> findAll(int start, int end)
13970                    throws SystemException {
13971                    return findAll(start, end, null);
13972            }
13973    
13974            /**
13975             * Returns an ordered range of all the journal articles.
13976             *
13977             * <p>
13978             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13979             * </p>
13980             *
13981             * @param start the lower bound of the range of journal articles
13982             * @param end the upper bound of the range of journal articles (not inclusive)
13983             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13984             * @return the ordered range of journal articles
13985             * @throws SystemException if a system exception occurred
13986             */
13987            public List<JournalArticle> findAll(int start, int end,
13988                    OrderByComparator orderByComparator) throws SystemException {
13989                    FinderPath finderPath = null;
13990                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
13991    
13992                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13993                                    (orderByComparator == null)) {
13994                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
13995                            finderArgs = FINDER_ARGS_EMPTY;
13996                    }
13997                    else {
13998                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
13999                            finderArgs = new Object[] { start, end, orderByComparator };
14000                    }
14001    
14002                    List<JournalArticle> list = (List<JournalArticle>)FinderCacheUtil.getResult(finderPath,
14003                                    finderArgs, this);
14004    
14005                    if (list == null) {
14006                            StringBundler query = null;
14007                            String sql = null;
14008    
14009                            if (orderByComparator != null) {
14010                                    query = new StringBundler(2 +
14011                                                    (orderByComparator.getOrderByFields().length * 3));
14012    
14013                                    query.append(_SQL_SELECT_JOURNALARTICLE);
14014    
14015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14016                                            orderByComparator);
14017    
14018                                    sql = query.toString();
14019                            }
14020                            else {
14021                                    sql = _SQL_SELECT_JOURNALARTICLE.concat(JournalArticleModelImpl.ORDER_BY_JPQL);
14022                            }
14023    
14024                            Session session = null;
14025    
14026                            try {
14027                                    session = openSession();
14028    
14029                                    Query q = session.createQuery(sql);
14030    
14031                                    if (orderByComparator == null) {
14032                                            list = (List<JournalArticle>)QueryUtil.list(q,
14033                                                            getDialect(), start, end, false);
14034    
14035                                            Collections.sort(list);
14036                                    }
14037                                    else {
14038                                            list = (List<JournalArticle>)QueryUtil.list(q,
14039                                                            getDialect(), start, end);
14040                                    }
14041                            }
14042                            catch (Exception e) {
14043                                    throw processException(e);
14044                            }
14045                            finally {
14046                                    if (list == null) {
14047                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14048                                    }
14049                                    else {
14050                                            cacheResult(list);
14051    
14052                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14053                                    }
14054    
14055                                    closeSession(session);
14056                            }
14057                    }
14058    
14059                    return list;
14060            }
14061    
14062            /**
14063             * Removes all the journal articles where uuid = &#63; from the database.
14064             *
14065             * @param uuid the uuid
14066             * @throws SystemException if a system exception occurred
14067             */
14068            public void removeByUuid(String uuid) throws SystemException {
14069                    for (JournalArticle journalArticle : findByUuid(uuid)) {
14070                            journalArticlePersistence.remove(journalArticle);
14071                    }
14072            }
14073    
14074            /**
14075             * Removes the journal article where uuid = &#63; and groupId = &#63; from the database.
14076             *
14077             * @param uuid the uuid
14078             * @param groupId the group ID
14079             * @throws SystemException if a system exception occurred
14080             */
14081            public void removeByUUID_G(String uuid, long groupId)
14082                    throws NoSuchArticleException, SystemException {
14083                    JournalArticle journalArticle = findByUUID_G(uuid, groupId);
14084    
14085                    journalArticlePersistence.remove(journalArticle);
14086            }
14087    
14088            /**
14089             * Removes all the journal articles where resourcePrimKey = &#63; from the database.
14090             *
14091             * @param resourcePrimKey the resource prim key
14092             * @throws SystemException if a system exception occurred
14093             */
14094            public void removeByResourcePrimKey(long resourcePrimKey)
14095                    throws SystemException {
14096                    for (JournalArticle journalArticle : findByResourcePrimKey(
14097                                    resourcePrimKey)) {
14098                            journalArticlePersistence.remove(journalArticle);
14099                    }
14100            }
14101    
14102            /**
14103             * Removes all the journal articles where groupId = &#63; from the database.
14104             *
14105             * @param groupId the group ID
14106             * @throws SystemException if a system exception occurred
14107             */
14108            public void removeByGroupId(long groupId) throws SystemException {
14109                    for (JournalArticle journalArticle : findByGroupId(groupId)) {
14110                            journalArticlePersistence.remove(journalArticle);
14111                    }
14112            }
14113    
14114            /**
14115             * Removes all the journal articles where companyId = &#63; from the database.
14116             *
14117             * @param companyId the company ID
14118             * @throws SystemException if a system exception occurred
14119             */
14120            public void removeByCompanyId(long companyId) throws SystemException {
14121                    for (JournalArticle journalArticle : findByCompanyId(companyId)) {
14122                            journalArticlePersistence.remove(journalArticle);
14123                    }
14124            }
14125    
14126            /**
14127             * Removes all the journal articles where smallImageId = &#63; from the database.
14128             *
14129             * @param smallImageId the small image ID
14130             * @throws SystemException if a system exception occurred
14131             */
14132            public void removeBySmallImageId(long smallImageId)
14133                    throws SystemException {
14134                    for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
14135                            journalArticlePersistence.remove(journalArticle);
14136                    }
14137            }
14138    
14139            /**
14140             * Removes all the journal articles where resourcePrimKey = &#63; and status = &#63; from the database.
14141             *
14142             * @param resourcePrimKey the resource prim key
14143             * @param status the status
14144             * @throws SystemException if a system exception occurred
14145             */
14146            public void removeByR_ST(long resourcePrimKey, int status)
14147                    throws SystemException {
14148                    for (JournalArticle journalArticle : findByR_ST(resourcePrimKey, status)) {
14149                            journalArticlePersistence.remove(journalArticle);
14150                    }
14151            }
14152    
14153            /**
14154             * Removes all the journal articles where groupId = &#63; and articleId = &#63; from the database.
14155             *
14156             * @param groupId the group ID
14157             * @param articleId the article ID
14158             * @throws SystemException if a system exception occurred
14159             */
14160            public void removeByG_A(long groupId, String articleId)
14161                    throws SystemException {
14162                    for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
14163                            journalArticlePersistence.remove(journalArticle);
14164                    }
14165            }
14166    
14167            /**
14168             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; from the database.
14169             *
14170             * @param groupId the group ID
14171             * @param urlTitle the url title
14172             * @throws SystemException if a system exception occurred
14173             */
14174            public void removeByG_UT(long groupId, String urlTitle)
14175                    throws SystemException {
14176                    for (JournalArticle journalArticle : findByG_UT(groupId, urlTitle)) {
14177                            journalArticlePersistence.remove(journalArticle);
14178                    }
14179            }
14180    
14181            /**
14182             * Removes all the journal articles where groupId = &#63; and structureId = &#63; from the database.
14183             *
14184             * @param groupId the group ID
14185             * @param structureId the structure ID
14186             * @throws SystemException if a system exception occurred
14187             */
14188            public void removeByG_S(long groupId, String structureId)
14189                    throws SystemException {
14190                    for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
14191                            journalArticlePersistence.remove(journalArticle);
14192                    }
14193            }
14194    
14195            /**
14196             * Removes all the journal articles where groupId = &#63; and templateId = &#63; from the database.
14197             *
14198             * @param groupId the group ID
14199             * @param templateId the template ID
14200             * @throws SystemException if a system exception occurred
14201             */
14202            public void removeByG_T(long groupId, String templateId)
14203                    throws SystemException {
14204                    for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
14205                            journalArticlePersistence.remove(journalArticle);
14206                    }
14207            }
14208    
14209            /**
14210             * Removes all the journal articles where groupId = &#63; and layoutUuid = &#63; from the database.
14211             *
14212             * @param groupId the group ID
14213             * @param layoutUuid the layout uuid
14214             * @throws SystemException if a system exception occurred
14215             */
14216            public void removeByG_L(long groupId, String layoutUuid)
14217                    throws SystemException {
14218                    for (JournalArticle journalArticle : findByG_L(groupId, layoutUuid)) {
14219                            journalArticlePersistence.remove(journalArticle);
14220                    }
14221            }
14222    
14223            /**
14224             * Removes all the journal articles where groupId = &#63; and status = &#63; from the database.
14225             *
14226             * @param groupId the group ID
14227             * @param status the status
14228             * @throws SystemException if a system exception occurred
14229             */
14230            public void removeByG_ST(long groupId, int status)
14231                    throws SystemException {
14232                    for (JournalArticle journalArticle : findByG_ST(groupId, status)) {
14233                            journalArticlePersistence.remove(journalArticle);
14234                    }
14235            }
14236    
14237            /**
14238             * Removes all the journal articles where companyId = &#63; and version = &#63; from the database.
14239             *
14240             * @param companyId the company ID
14241             * @param version the version
14242             * @throws SystemException if a system exception occurred
14243             */
14244            public void removeByC_V(long companyId, double version)
14245                    throws SystemException {
14246                    for (JournalArticle journalArticle : findByC_V(companyId, version)) {
14247                            journalArticlePersistence.remove(journalArticle);
14248                    }
14249            }
14250    
14251            /**
14252             * Removes all the journal articles where companyId = &#63; and status = &#63; from the database.
14253             *
14254             * @param companyId the company ID
14255             * @param status the status
14256             * @throws SystemException if a system exception occurred
14257             */
14258            public void removeByC_ST(long companyId, int status)
14259                    throws SystemException {
14260                    for (JournalArticle journalArticle : findByC_ST(companyId, status)) {
14261                            journalArticlePersistence.remove(journalArticle);
14262                    }
14263            }
14264    
14265            /**
14266             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
14267             *
14268             * @param groupId the group ID
14269             * @param classNameId the class name ID
14270             * @param classPK the class p k
14271             * @throws SystemException if a system exception occurred
14272             */
14273            public void removeByG_C_C(long groupId, long classNameId, long classPK)
14274                    throws SystemException {
14275                    for (JournalArticle journalArticle : findByG_C_C(groupId, classNameId,
14276                                    classPK)) {
14277                            journalArticlePersistence.remove(journalArticle);
14278                    }
14279            }
14280    
14281            /**
14282             * Removes the journal article where groupId = &#63; and classNameId = &#63; and structureId = &#63; from the database.
14283             *
14284             * @param groupId the group ID
14285             * @param classNameId the class name ID
14286             * @param structureId the structure ID
14287             * @throws SystemException if a system exception occurred
14288             */
14289            public void removeByG_C_S(long groupId, long classNameId, String structureId)
14290                    throws NoSuchArticleException, SystemException {
14291                    JournalArticle journalArticle = findByG_C_S(groupId, classNameId,
14292                                    structureId);
14293    
14294                    journalArticlePersistence.remove(journalArticle);
14295            }
14296    
14297            /**
14298             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63; from the database.
14299             *
14300             * @param groupId the group ID
14301             * @param classNameId the class name ID
14302             * @param templateId the template ID
14303             * @throws SystemException if a system exception occurred
14304             */
14305            public void removeByG_C_T(long groupId, long classNameId, String templateId)
14306                    throws SystemException {
14307                    for (JournalArticle journalArticle : findByG_C_T(groupId, classNameId,
14308                                    templateId)) {
14309                            journalArticlePersistence.remove(journalArticle);
14310                    }
14311            }
14312    
14313            /**
14314             * Removes all the journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63; from the database.
14315             *
14316             * @param groupId the group ID
14317             * @param classNameId the class name ID
14318             * @param layoutUuid the layout uuid
14319             * @throws SystemException if a system exception occurred
14320             */
14321            public void removeByG_C_L(long groupId, long classNameId, String layoutUuid)
14322                    throws SystemException {
14323                    for (JournalArticle journalArticle : findByG_C_L(groupId, classNameId,
14324                                    layoutUuid)) {
14325                            journalArticlePersistence.remove(journalArticle);
14326                    }
14327            }
14328    
14329            /**
14330             * Removes the journal article where groupId = &#63; and articleId = &#63; and version = &#63; from the database.
14331             *
14332             * @param groupId the group ID
14333             * @param articleId the article ID
14334             * @param version the version
14335             * @throws SystemException if a system exception occurred
14336             */
14337            public void removeByG_A_V(long groupId, String articleId, double version)
14338                    throws NoSuchArticleException, SystemException {
14339                    JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
14340    
14341                    journalArticlePersistence.remove(journalArticle);
14342            }
14343    
14344            /**
14345             * Removes all the journal articles where groupId = &#63; and articleId = &#63; and status = &#63; from the database.
14346             *
14347             * @param groupId the group ID
14348             * @param articleId the article ID
14349             * @param status the status
14350             * @throws SystemException if a system exception occurred
14351             */
14352            public void removeByG_A_ST(long groupId, String articleId, int status)
14353                    throws SystemException {
14354                    for (JournalArticle journalArticle : findByG_A_ST(groupId, articleId,
14355                                    status)) {
14356                            journalArticlePersistence.remove(journalArticle);
14357                    }
14358            }
14359    
14360            /**
14361             * Removes all the journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63; from the database.
14362             *
14363             * @param groupId the group ID
14364             * @param urlTitle the url title
14365             * @param status the status
14366             * @throws SystemException if a system exception occurred
14367             */
14368            public void removeByG_UT_ST(long groupId, String urlTitle, int status)
14369                    throws SystemException {
14370                    for (JournalArticle journalArticle : findByG_UT_ST(groupId, urlTitle,
14371                                    status)) {
14372                            journalArticlePersistence.remove(journalArticle);
14373                    }
14374            }
14375    
14376            /**
14377             * Removes all the journal articles where companyId = &#63; and version = &#63; and status = &#63; from the database.
14378             *
14379             * @param companyId the company ID
14380             * @param version the version
14381             * @param status the status
14382             * @throws SystemException if a system exception occurred
14383             */
14384            public void removeByC_V_ST(long companyId, double version, int status)
14385                    throws SystemException {
14386                    for (JournalArticle journalArticle : findByC_V_ST(companyId, version,
14387                                    status)) {
14388                            journalArticlePersistence.remove(journalArticle);
14389                    }
14390            }
14391    
14392            /**
14393             * Removes all the journal articles from the database.
14394             *
14395             * @throws SystemException if a system exception occurred
14396             */
14397            public void removeAll() throws SystemException {
14398                    for (JournalArticle journalArticle : findAll()) {
14399                            journalArticlePersistence.remove(journalArticle);
14400                    }
14401            }
14402    
14403            /**
14404             * Returns the number of journal articles where uuid = &#63;.
14405             *
14406             * @param uuid the uuid
14407             * @return the number of matching journal articles
14408             * @throws SystemException if a system exception occurred
14409             */
14410            public int countByUuid(String uuid) throws SystemException {
14411                    Object[] finderArgs = new Object[] { uuid };
14412    
14413                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
14414                                    finderArgs, this);
14415    
14416                    if (count == null) {
14417                            StringBundler query = new StringBundler(2);
14418    
14419                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14420    
14421                            if (uuid == null) {
14422                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
14423                            }
14424                            else {
14425                                    if (uuid.equals(StringPool.BLANK)) {
14426                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
14427                                    }
14428                                    else {
14429                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
14430                                    }
14431                            }
14432    
14433                            String sql = query.toString();
14434    
14435                            Session session = null;
14436    
14437                            try {
14438                                    session = openSession();
14439    
14440                                    Query q = session.createQuery(sql);
14441    
14442                                    QueryPos qPos = QueryPos.getInstance(q);
14443    
14444                                    if (uuid != null) {
14445                                            qPos.add(uuid);
14446                                    }
14447    
14448                                    count = (Long)q.uniqueResult();
14449                            }
14450                            catch (Exception e) {
14451                                    throw processException(e);
14452                            }
14453                            finally {
14454                                    if (count == null) {
14455                                            count = Long.valueOf(0);
14456                                    }
14457    
14458                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
14459                                            finderArgs, count);
14460    
14461                                    closeSession(session);
14462                            }
14463                    }
14464    
14465                    return count.intValue();
14466            }
14467    
14468            /**
14469             * Returns the number of journal articles where uuid = &#63; and groupId = &#63;.
14470             *
14471             * @param uuid the uuid
14472             * @param groupId the group ID
14473             * @return the number of matching journal articles
14474             * @throws SystemException if a system exception occurred
14475             */
14476            public int countByUUID_G(String uuid, long groupId)
14477                    throws SystemException {
14478                    Object[] finderArgs = new Object[] { uuid, groupId };
14479    
14480                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
14481                                    finderArgs, this);
14482    
14483                    if (count == null) {
14484                            StringBundler query = new StringBundler(3);
14485    
14486                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14487    
14488                            if (uuid == null) {
14489                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
14490                            }
14491                            else {
14492                                    if (uuid.equals(StringPool.BLANK)) {
14493                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
14494                                    }
14495                                    else {
14496                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
14497                                    }
14498                            }
14499    
14500                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
14501    
14502                            String sql = query.toString();
14503    
14504                            Session session = null;
14505    
14506                            try {
14507                                    session = openSession();
14508    
14509                                    Query q = session.createQuery(sql);
14510    
14511                                    QueryPos qPos = QueryPos.getInstance(q);
14512    
14513                                    if (uuid != null) {
14514                                            qPos.add(uuid);
14515                                    }
14516    
14517                                    qPos.add(groupId);
14518    
14519                                    count = (Long)q.uniqueResult();
14520                            }
14521                            catch (Exception e) {
14522                                    throw processException(e);
14523                            }
14524                            finally {
14525                                    if (count == null) {
14526                                            count = Long.valueOf(0);
14527                                    }
14528    
14529                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
14530                                            finderArgs, count);
14531    
14532                                    closeSession(session);
14533                            }
14534                    }
14535    
14536                    return count.intValue();
14537            }
14538    
14539            /**
14540             * Returns the number of journal articles where resourcePrimKey = &#63;.
14541             *
14542             * @param resourcePrimKey the resource prim key
14543             * @return the number of matching journal articles
14544             * @throws SystemException if a system exception occurred
14545             */
14546            public int countByResourcePrimKey(long resourcePrimKey)
14547                    throws SystemException {
14548                    Object[] finderArgs = new Object[] { resourcePrimKey };
14549    
14550                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
14551                                    finderArgs, this);
14552    
14553                    if (count == null) {
14554                            StringBundler query = new StringBundler(2);
14555    
14556                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14557    
14558                            query.append(_FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2);
14559    
14560                            String sql = query.toString();
14561    
14562                            Session session = null;
14563    
14564                            try {
14565                                    session = openSession();
14566    
14567                                    Query q = session.createQuery(sql);
14568    
14569                                    QueryPos qPos = QueryPos.getInstance(q);
14570    
14571                                    qPos.add(resourcePrimKey);
14572    
14573                                    count = (Long)q.uniqueResult();
14574                            }
14575                            catch (Exception e) {
14576                                    throw processException(e);
14577                            }
14578                            finally {
14579                                    if (count == null) {
14580                                            count = Long.valueOf(0);
14581                                    }
14582    
14583                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEPRIMKEY,
14584                                            finderArgs, count);
14585    
14586                                    closeSession(session);
14587                            }
14588                    }
14589    
14590                    return count.intValue();
14591            }
14592    
14593            /**
14594             * Returns the number of journal articles where groupId = &#63;.
14595             *
14596             * @param groupId the group ID
14597             * @return the number of matching journal articles
14598             * @throws SystemException if a system exception occurred
14599             */
14600            public int countByGroupId(long groupId) throws SystemException {
14601                    Object[] finderArgs = new Object[] { groupId };
14602    
14603                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
14604                                    finderArgs, this);
14605    
14606                    if (count == null) {
14607                            StringBundler query = new StringBundler(2);
14608    
14609                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14610    
14611                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
14612    
14613                            String sql = query.toString();
14614    
14615                            Session session = null;
14616    
14617                            try {
14618                                    session = openSession();
14619    
14620                                    Query q = session.createQuery(sql);
14621    
14622                                    QueryPos qPos = QueryPos.getInstance(q);
14623    
14624                                    qPos.add(groupId);
14625    
14626                                    count = (Long)q.uniqueResult();
14627                            }
14628                            catch (Exception e) {
14629                                    throw processException(e);
14630                            }
14631                            finally {
14632                                    if (count == null) {
14633                                            count = Long.valueOf(0);
14634                                    }
14635    
14636                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
14637                                            finderArgs, count);
14638    
14639                                    closeSession(session);
14640                            }
14641                    }
14642    
14643                    return count.intValue();
14644            }
14645    
14646            /**
14647             * Returns the number of journal articles that the user has permission to view where groupId = &#63;.
14648             *
14649             * @param groupId the group ID
14650             * @return the number of matching journal articles that the user has permission to view
14651             * @throws SystemException if a system exception occurred
14652             */
14653            public int filterCountByGroupId(long groupId) throws SystemException {
14654                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14655                            return countByGroupId(groupId);
14656                    }
14657    
14658                    StringBundler query = new StringBundler(2);
14659    
14660                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14661    
14662                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
14663    
14664                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14665                                    JournalArticle.class.getName(),
14666                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14667    
14668                    Session session = null;
14669    
14670                    try {
14671                            session = openSession();
14672    
14673                            SQLQuery q = session.createSQLQuery(sql);
14674    
14675                            q.addScalar(COUNT_COLUMN_NAME,
14676                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14677    
14678                            QueryPos qPos = QueryPos.getInstance(q);
14679    
14680                            qPos.add(groupId);
14681    
14682                            Long count = (Long)q.uniqueResult();
14683    
14684                            return count.intValue();
14685                    }
14686                    catch (Exception e) {
14687                            throw processException(e);
14688                    }
14689                    finally {
14690                            closeSession(session);
14691                    }
14692            }
14693    
14694            /**
14695             * Returns the number of journal articles where companyId = &#63;.
14696             *
14697             * @param companyId the company ID
14698             * @return the number of matching journal articles
14699             * @throws SystemException if a system exception occurred
14700             */
14701            public int countByCompanyId(long companyId) throws SystemException {
14702                    Object[] finderArgs = new Object[] { companyId };
14703    
14704                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
14705                                    finderArgs, this);
14706    
14707                    if (count == null) {
14708                            StringBundler query = new StringBundler(2);
14709    
14710                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14711    
14712                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
14713    
14714                            String sql = query.toString();
14715    
14716                            Session session = null;
14717    
14718                            try {
14719                                    session = openSession();
14720    
14721                                    Query q = session.createQuery(sql);
14722    
14723                                    QueryPos qPos = QueryPos.getInstance(q);
14724    
14725                                    qPos.add(companyId);
14726    
14727                                    count = (Long)q.uniqueResult();
14728                            }
14729                            catch (Exception e) {
14730                                    throw processException(e);
14731                            }
14732                            finally {
14733                                    if (count == null) {
14734                                            count = Long.valueOf(0);
14735                                    }
14736    
14737                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
14738                                            finderArgs, count);
14739    
14740                                    closeSession(session);
14741                            }
14742                    }
14743    
14744                    return count.intValue();
14745            }
14746    
14747            /**
14748             * Returns the number of journal articles where smallImageId = &#63;.
14749             *
14750             * @param smallImageId the small image ID
14751             * @return the number of matching journal articles
14752             * @throws SystemException if a system exception occurred
14753             */
14754            public int countBySmallImageId(long smallImageId) throws SystemException {
14755                    Object[] finderArgs = new Object[] { smallImageId };
14756    
14757                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
14758                                    finderArgs, this);
14759    
14760                    if (count == null) {
14761                            StringBundler query = new StringBundler(2);
14762    
14763                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14764    
14765                            query.append(_FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2);
14766    
14767                            String sql = query.toString();
14768    
14769                            Session session = null;
14770    
14771                            try {
14772                                    session = openSession();
14773    
14774                                    Query q = session.createQuery(sql);
14775    
14776                                    QueryPos qPos = QueryPos.getInstance(q);
14777    
14778                                    qPos.add(smallImageId);
14779    
14780                                    count = (Long)q.uniqueResult();
14781                            }
14782                            catch (Exception e) {
14783                                    throw processException(e);
14784                            }
14785                            finally {
14786                                    if (count == null) {
14787                                            count = Long.valueOf(0);
14788                                    }
14789    
14790                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SMALLIMAGEID,
14791                                            finderArgs, count);
14792    
14793                                    closeSession(session);
14794                            }
14795                    }
14796    
14797                    return count.intValue();
14798            }
14799    
14800            /**
14801             * Returns the number of journal articles where resourcePrimKey = &#63; and status = &#63;.
14802             *
14803             * @param resourcePrimKey the resource prim key
14804             * @param status the status
14805             * @return the number of matching journal articles
14806             * @throws SystemException if a system exception occurred
14807             */
14808            public int countByR_ST(long resourcePrimKey, int status)
14809                    throws SystemException {
14810                    Object[] finderArgs = new Object[] { resourcePrimKey, status };
14811    
14812                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_ST,
14813                                    finderArgs, this);
14814    
14815                    if (count == null) {
14816                            StringBundler query = new StringBundler(3);
14817    
14818                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14819    
14820                            query.append(_FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2);
14821    
14822                            query.append(_FINDER_COLUMN_R_ST_STATUS_2);
14823    
14824                            String sql = query.toString();
14825    
14826                            Session session = null;
14827    
14828                            try {
14829                                    session = openSession();
14830    
14831                                    Query q = session.createQuery(sql);
14832    
14833                                    QueryPos qPos = QueryPos.getInstance(q);
14834    
14835                                    qPos.add(resourcePrimKey);
14836    
14837                                    qPos.add(status);
14838    
14839                                    count = (Long)q.uniqueResult();
14840                            }
14841                            catch (Exception e) {
14842                                    throw processException(e);
14843                            }
14844                            finally {
14845                                    if (count == null) {
14846                                            count = Long.valueOf(0);
14847                                    }
14848    
14849                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_ST,
14850                                            finderArgs, count);
14851    
14852                                    closeSession(session);
14853                            }
14854                    }
14855    
14856                    return count.intValue();
14857            }
14858    
14859            /**
14860             * Returns the number of journal articles where groupId = &#63; and articleId = &#63;.
14861             *
14862             * @param groupId the group ID
14863             * @param articleId the article ID
14864             * @return the number of matching journal articles
14865             * @throws SystemException if a system exception occurred
14866             */
14867            public int countByG_A(long groupId, String articleId)
14868                    throws SystemException {
14869                    Object[] finderArgs = new Object[] { groupId, articleId };
14870    
14871                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
14872                                    finderArgs, this);
14873    
14874                    if (count == null) {
14875                            StringBundler query = new StringBundler(3);
14876    
14877                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
14878    
14879                            query.append(_FINDER_COLUMN_G_A_GROUPID_2);
14880    
14881                            if (articleId == null) {
14882                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
14883                            }
14884                            else {
14885                                    if (articleId.equals(StringPool.BLANK)) {
14886                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
14887                                    }
14888                                    else {
14889                                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
14890                                    }
14891                            }
14892    
14893                            String sql = query.toString();
14894    
14895                            Session session = null;
14896    
14897                            try {
14898                                    session = openSession();
14899    
14900                                    Query q = session.createQuery(sql);
14901    
14902                                    QueryPos qPos = QueryPos.getInstance(q);
14903    
14904                                    qPos.add(groupId);
14905    
14906                                    if (articleId != null) {
14907                                            qPos.add(articleId);
14908                                    }
14909    
14910                                    count = (Long)q.uniqueResult();
14911                            }
14912                            catch (Exception e) {
14913                                    throw processException(e);
14914                            }
14915                            finally {
14916                                    if (count == null) {
14917                                            count = Long.valueOf(0);
14918                                    }
14919    
14920                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
14921                                            count);
14922    
14923                                    closeSession(session);
14924                            }
14925                    }
14926    
14927                    return count.intValue();
14928            }
14929    
14930            /**
14931             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63;.
14932             *
14933             * @param groupId the group ID
14934             * @param articleId the article ID
14935             * @return the number of matching journal articles that the user has permission to view
14936             * @throws SystemException if a system exception occurred
14937             */
14938            public int filterCountByG_A(long groupId, String articleId)
14939                    throws SystemException {
14940                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14941                            return countByG_A(groupId, articleId);
14942                    }
14943    
14944                    StringBundler query = new StringBundler(3);
14945    
14946                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
14947    
14948                    query.append(_FINDER_COLUMN_G_A_GROUPID_2);
14949    
14950                    if (articleId == null) {
14951                            query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
14952                    }
14953                    else {
14954                            if (articleId.equals(StringPool.BLANK)) {
14955                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
14956                            }
14957                            else {
14958                                    query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
14959                            }
14960                    }
14961    
14962                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14963                                    JournalArticle.class.getName(),
14964                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14965    
14966                    Session session = null;
14967    
14968                    try {
14969                            session = openSession();
14970    
14971                            SQLQuery q = session.createSQLQuery(sql);
14972    
14973                            q.addScalar(COUNT_COLUMN_NAME,
14974                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14975    
14976                            QueryPos qPos = QueryPos.getInstance(q);
14977    
14978                            qPos.add(groupId);
14979    
14980                            if (articleId != null) {
14981                                    qPos.add(articleId);
14982                            }
14983    
14984                            Long count = (Long)q.uniqueResult();
14985    
14986                            return count.intValue();
14987                    }
14988                    catch (Exception e) {
14989                            throw processException(e);
14990                    }
14991                    finally {
14992                            closeSession(session);
14993                    }
14994            }
14995    
14996            /**
14997             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63;.
14998             *
14999             * @param groupId the group ID
15000             * @param urlTitle the url title
15001             * @return the number of matching journal articles
15002             * @throws SystemException if a system exception occurred
15003             */
15004            public int countByG_UT(long groupId, String urlTitle)
15005                    throws SystemException {
15006                    Object[] finderArgs = new Object[] { groupId, urlTitle };
15007    
15008                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
15009                                    finderArgs, this);
15010    
15011                    if (count == null) {
15012                            StringBundler query = new StringBundler(3);
15013    
15014                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15015    
15016                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
15017    
15018                            if (urlTitle == null) {
15019                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
15020                            }
15021                            else {
15022                                    if (urlTitle.equals(StringPool.BLANK)) {
15023                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
15024                                    }
15025                                    else {
15026                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
15027                                    }
15028                            }
15029    
15030                            String sql = query.toString();
15031    
15032                            Session session = null;
15033    
15034                            try {
15035                                    session = openSession();
15036    
15037                                    Query q = session.createQuery(sql);
15038    
15039                                    QueryPos qPos = QueryPos.getInstance(q);
15040    
15041                                    qPos.add(groupId);
15042    
15043                                    if (urlTitle != null) {
15044                                            qPos.add(urlTitle);
15045                                    }
15046    
15047                                    count = (Long)q.uniqueResult();
15048                            }
15049                            catch (Exception e) {
15050                                    throw processException(e);
15051                            }
15052                            finally {
15053                                    if (count == null) {
15054                                            count = Long.valueOf(0);
15055                                    }
15056    
15057                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
15058                                            finderArgs, count);
15059    
15060                                    closeSession(session);
15061                            }
15062                    }
15063    
15064                    return count.intValue();
15065            }
15066    
15067            /**
15068             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63;.
15069             *
15070             * @param groupId the group ID
15071             * @param urlTitle the url title
15072             * @return the number of matching journal articles that the user has permission to view
15073             * @throws SystemException if a system exception occurred
15074             */
15075            public int filterCountByG_UT(long groupId, String urlTitle)
15076                    throws SystemException {
15077                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15078                            return countByG_UT(groupId, urlTitle);
15079                    }
15080    
15081                    StringBundler query = new StringBundler(3);
15082    
15083                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15084    
15085                    query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
15086    
15087                    if (urlTitle == null) {
15088                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
15089                    }
15090                    else {
15091                            if (urlTitle.equals(StringPool.BLANK)) {
15092                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
15093                            }
15094                            else {
15095                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
15096                            }
15097                    }
15098    
15099                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15100                                    JournalArticle.class.getName(),
15101                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15102    
15103                    Session session = null;
15104    
15105                    try {
15106                            session = openSession();
15107    
15108                            SQLQuery q = session.createSQLQuery(sql);
15109    
15110                            q.addScalar(COUNT_COLUMN_NAME,
15111                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15112    
15113                            QueryPos qPos = QueryPos.getInstance(q);
15114    
15115                            qPos.add(groupId);
15116    
15117                            if (urlTitle != null) {
15118                                    qPos.add(urlTitle);
15119                            }
15120    
15121                            Long count = (Long)q.uniqueResult();
15122    
15123                            return count.intValue();
15124                    }
15125                    catch (Exception e) {
15126                            throw processException(e);
15127                    }
15128                    finally {
15129                            closeSession(session);
15130                    }
15131            }
15132    
15133            /**
15134             * Returns the number of journal articles where groupId = &#63; and structureId = &#63;.
15135             *
15136             * @param groupId the group ID
15137             * @param structureId the structure ID
15138             * @return the number of matching journal articles
15139             * @throws SystemException if a system exception occurred
15140             */
15141            public int countByG_S(long groupId, String structureId)
15142                    throws SystemException {
15143                    Object[] finderArgs = new Object[] { groupId, structureId };
15144    
15145                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
15146                                    finderArgs, this);
15147    
15148                    if (count == null) {
15149                            StringBundler query = new StringBundler(3);
15150    
15151                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15152    
15153                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15154    
15155                            if (structureId == null) {
15156                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
15157                            }
15158                            else {
15159                                    if (structureId.equals(StringPool.BLANK)) {
15160                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
15161                                    }
15162                                    else {
15163                                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
15164                                    }
15165                            }
15166    
15167                            String sql = query.toString();
15168    
15169                            Session session = null;
15170    
15171                            try {
15172                                    session = openSession();
15173    
15174                                    Query q = session.createQuery(sql);
15175    
15176                                    QueryPos qPos = QueryPos.getInstance(q);
15177    
15178                                    qPos.add(groupId);
15179    
15180                                    if (structureId != null) {
15181                                            qPos.add(structureId);
15182                                    }
15183    
15184                                    count = (Long)q.uniqueResult();
15185                            }
15186                            catch (Exception e) {
15187                                    throw processException(e);
15188                            }
15189                            finally {
15190                                    if (count == null) {
15191                                            count = Long.valueOf(0);
15192                                    }
15193    
15194                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
15195                                            count);
15196    
15197                                    closeSession(session);
15198                            }
15199                    }
15200    
15201                    return count.intValue();
15202            }
15203    
15204            /**
15205             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and structureId = &#63;.
15206             *
15207             * @param groupId the group ID
15208             * @param structureId the structure ID
15209             * @return the number of matching journal articles that the user has permission to view
15210             * @throws SystemException if a system exception occurred
15211             */
15212            public int filterCountByG_S(long groupId, String structureId)
15213                    throws SystemException {
15214                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15215                            return countByG_S(groupId, structureId);
15216                    }
15217    
15218                    StringBundler query = new StringBundler(3);
15219    
15220                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15221    
15222                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
15223    
15224                    if (structureId == null) {
15225                            query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
15226                    }
15227                    else {
15228                            if (structureId.equals(StringPool.BLANK)) {
15229                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
15230                            }
15231                            else {
15232                                    query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
15233                            }
15234                    }
15235    
15236                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15237                                    JournalArticle.class.getName(),
15238                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15239    
15240                    Session session = null;
15241    
15242                    try {
15243                            session = openSession();
15244    
15245                            SQLQuery q = session.createSQLQuery(sql);
15246    
15247                            q.addScalar(COUNT_COLUMN_NAME,
15248                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15249    
15250                            QueryPos qPos = QueryPos.getInstance(q);
15251    
15252                            qPos.add(groupId);
15253    
15254                            if (structureId != null) {
15255                                    qPos.add(structureId);
15256                            }
15257    
15258                            Long count = (Long)q.uniqueResult();
15259    
15260                            return count.intValue();
15261                    }
15262                    catch (Exception e) {
15263                            throw processException(e);
15264                    }
15265                    finally {
15266                            closeSession(session);
15267                    }
15268            }
15269    
15270            /**
15271             * Returns the number of journal articles where groupId = &#63; and templateId = &#63;.
15272             *
15273             * @param groupId the group ID
15274             * @param templateId the template ID
15275             * @return the number of matching journal articles
15276             * @throws SystemException if a system exception occurred
15277             */
15278            public int countByG_T(long groupId, String templateId)
15279                    throws SystemException {
15280                    Object[] finderArgs = new Object[] { groupId, templateId };
15281    
15282                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T,
15283                                    finderArgs, this);
15284    
15285                    if (count == null) {
15286                            StringBundler query = new StringBundler(3);
15287    
15288                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15289    
15290                            query.append(_FINDER_COLUMN_G_T_GROUPID_2);
15291    
15292                            if (templateId == null) {
15293                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
15294                            }
15295                            else {
15296                                    if (templateId.equals(StringPool.BLANK)) {
15297                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
15298                                    }
15299                                    else {
15300                                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
15301                                    }
15302                            }
15303    
15304                            String sql = query.toString();
15305    
15306                            Session session = null;
15307    
15308                            try {
15309                                    session = openSession();
15310    
15311                                    Query q = session.createQuery(sql);
15312    
15313                                    QueryPos qPos = QueryPos.getInstance(q);
15314    
15315                                    qPos.add(groupId);
15316    
15317                                    if (templateId != null) {
15318                                            qPos.add(templateId);
15319                                    }
15320    
15321                                    count = (Long)q.uniqueResult();
15322                            }
15323                            catch (Exception e) {
15324                                    throw processException(e);
15325                            }
15326                            finally {
15327                                    if (count == null) {
15328                                            count = Long.valueOf(0);
15329                                    }
15330    
15331                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_T, finderArgs,
15332                                            count);
15333    
15334                                    closeSession(session);
15335                            }
15336                    }
15337    
15338                    return count.intValue();
15339            }
15340    
15341            /**
15342             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and templateId = &#63;.
15343             *
15344             * @param groupId the group ID
15345             * @param templateId the template ID
15346             * @return the number of matching journal articles that the user has permission to view
15347             * @throws SystemException if a system exception occurred
15348             */
15349            public int filterCountByG_T(long groupId, String templateId)
15350                    throws SystemException {
15351                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15352                            return countByG_T(groupId, templateId);
15353                    }
15354    
15355                    StringBundler query = new StringBundler(3);
15356    
15357                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15358    
15359                    query.append(_FINDER_COLUMN_G_T_GROUPID_2);
15360    
15361                    if (templateId == null) {
15362                            query.append(_FINDER_COLUMN_G_T_TEMPLATEID_1);
15363                    }
15364                    else {
15365                            if (templateId.equals(StringPool.BLANK)) {
15366                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_3);
15367                            }
15368                            else {
15369                                    query.append(_FINDER_COLUMN_G_T_TEMPLATEID_2);
15370                            }
15371                    }
15372    
15373                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15374                                    JournalArticle.class.getName(),
15375                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15376    
15377                    Session session = null;
15378    
15379                    try {
15380                            session = openSession();
15381    
15382                            SQLQuery q = session.createSQLQuery(sql);
15383    
15384                            q.addScalar(COUNT_COLUMN_NAME,
15385                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15386    
15387                            QueryPos qPos = QueryPos.getInstance(q);
15388    
15389                            qPos.add(groupId);
15390    
15391                            if (templateId != null) {
15392                                    qPos.add(templateId);
15393                            }
15394    
15395                            Long count = (Long)q.uniqueResult();
15396    
15397                            return count.intValue();
15398                    }
15399                    catch (Exception e) {
15400                            throw processException(e);
15401                    }
15402                    finally {
15403                            closeSession(session);
15404                    }
15405            }
15406    
15407            /**
15408             * Returns the number of journal articles where groupId = &#63; and layoutUuid = &#63;.
15409             *
15410             * @param groupId the group ID
15411             * @param layoutUuid the layout uuid
15412             * @return the number of matching journal articles
15413             * @throws SystemException if a system exception occurred
15414             */
15415            public int countByG_L(long groupId, String layoutUuid)
15416                    throws SystemException {
15417                    Object[] finderArgs = new Object[] { groupId, layoutUuid };
15418    
15419                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_L,
15420                                    finderArgs, this);
15421    
15422                    if (count == null) {
15423                            StringBundler query = new StringBundler(3);
15424    
15425                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15426    
15427                            query.append(_FINDER_COLUMN_G_L_GROUPID_2);
15428    
15429                            if (layoutUuid == null) {
15430                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
15431                            }
15432                            else {
15433                                    if (layoutUuid.equals(StringPool.BLANK)) {
15434                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
15435                                    }
15436                                    else {
15437                                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
15438                                    }
15439                            }
15440    
15441                            String sql = query.toString();
15442    
15443                            Session session = null;
15444    
15445                            try {
15446                                    session = openSession();
15447    
15448                                    Query q = session.createQuery(sql);
15449    
15450                                    QueryPos qPos = QueryPos.getInstance(q);
15451    
15452                                    qPos.add(groupId);
15453    
15454                                    if (layoutUuid != null) {
15455                                            qPos.add(layoutUuid);
15456                                    }
15457    
15458                                    count = (Long)q.uniqueResult();
15459                            }
15460                            catch (Exception e) {
15461                                    throw processException(e);
15462                            }
15463                            finally {
15464                                    if (count == null) {
15465                                            count = Long.valueOf(0);
15466                                    }
15467    
15468                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_L, finderArgs,
15469                                            count);
15470    
15471                                    closeSession(session);
15472                            }
15473                    }
15474    
15475                    return count.intValue();
15476            }
15477    
15478            /**
15479             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and layoutUuid = &#63;.
15480             *
15481             * @param groupId the group ID
15482             * @param layoutUuid the layout uuid
15483             * @return the number of matching journal articles that the user has permission to view
15484             * @throws SystemException if a system exception occurred
15485             */
15486            public int filterCountByG_L(long groupId, String layoutUuid)
15487                    throws SystemException {
15488                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15489                            return countByG_L(groupId, layoutUuid);
15490                    }
15491    
15492                    StringBundler query = new StringBundler(3);
15493    
15494                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15495    
15496                    query.append(_FINDER_COLUMN_G_L_GROUPID_2);
15497    
15498                    if (layoutUuid == null) {
15499                            query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_1);
15500                    }
15501                    else {
15502                            if (layoutUuid.equals(StringPool.BLANK)) {
15503                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_3);
15504                            }
15505                            else {
15506                                    query.append(_FINDER_COLUMN_G_L_LAYOUTUUID_2);
15507                            }
15508                    }
15509    
15510                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15511                                    JournalArticle.class.getName(),
15512                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15513    
15514                    Session session = null;
15515    
15516                    try {
15517                            session = openSession();
15518    
15519                            SQLQuery q = session.createSQLQuery(sql);
15520    
15521                            q.addScalar(COUNT_COLUMN_NAME,
15522                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15523    
15524                            QueryPos qPos = QueryPos.getInstance(q);
15525    
15526                            qPos.add(groupId);
15527    
15528                            if (layoutUuid != null) {
15529                                    qPos.add(layoutUuid);
15530                            }
15531    
15532                            Long count = (Long)q.uniqueResult();
15533    
15534                            return count.intValue();
15535                    }
15536                    catch (Exception e) {
15537                            throw processException(e);
15538                    }
15539                    finally {
15540                            closeSession(session);
15541                    }
15542            }
15543    
15544            /**
15545             * Returns the number of journal articles where groupId = &#63; and status = &#63;.
15546             *
15547             * @param groupId the group ID
15548             * @param status the status
15549             * @return the number of matching journal articles
15550             * @throws SystemException if a system exception occurred
15551             */
15552            public int countByG_ST(long groupId, int status) throws SystemException {
15553                    Object[] finderArgs = new Object[] { groupId, status };
15554    
15555                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_ST,
15556                                    finderArgs, this);
15557    
15558                    if (count == null) {
15559                            StringBundler query = new StringBundler(3);
15560    
15561                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15562    
15563                            query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15564    
15565                            query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15566    
15567                            String sql = query.toString();
15568    
15569                            Session session = null;
15570    
15571                            try {
15572                                    session = openSession();
15573    
15574                                    Query q = session.createQuery(sql);
15575    
15576                                    QueryPos qPos = QueryPos.getInstance(q);
15577    
15578                                    qPos.add(groupId);
15579    
15580                                    qPos.add(status);
15581    
15582                                    count = (Long)q.uniqueResult();
15583                            }
15584                            catch (Exception e) {
15585                                    throw processException(e);
15586                            }
15587                            finally {
15588                                    if (count == null) {
15589                                            count = Long.valueOf(0);
15590                                    }
15591    
15592                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_ST,
15593                                            finderArgs, count);
15594    
15595                                    closeSession(session);
15596                            }
15597                    }
15598    
15599                    return count.intValue();
15600            }
15601    
15602            /**
15603             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and status = &#63;.
15604             *
15605             * @param groupId the group ID
15606             * @param status the status
15607             * @return the number of matching journal articles that the user has permission to view
15608             * @throws SystemException if a system exception occurred
15609             */
15610            public int filterCountByG_ST(long groupId, int status)
15611                    throws SystemException {
15612                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15613                            return countByG_ST(groupId, status);
15614                    }
15615    
15616                    StringBundler query = new StringBundler(3);
15617    
15618                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15619    
15620                    query.append(_FINDER_COLUMN_G_ST_GROUPID_2);
15621    
15622                    query.append(_FINDER_COLUMN_G_ST_STATUS_2);
15623    
15624                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15625                                    JournalArticle.class.getName(),
15626                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15627    
15628                    Session session = null;
15629    
15630                    try {
15631                            session = openSession();
15632    
15633                            SQLQuery q = session.createSQLQuery(sql);
15634    
15635                            q.addScalar(COUNT_COLUMN_NAME,
15636                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15637    
15638                            QueryPos qPos = QueryPos.getInstance(q);
15639    
15640                            qPos.add(groupId);
15641    
15642                            qPos.add(status);
15643    
15644                            Long count = (Long)q.uniqueResult();
15645    
15646                            return count.intValue();
15647                    }
15648                    catch (Exception e) {
15649                            throw processException(e);
15650                    }
15651                    finally {
15652                            closeSession(session);
15653                    }
15654            }
15655    
15656            /**
15657             * Returns the number of journal articles where companyId = &#63; and version = &#63;.
15658             *
15659             * @param companyId the company ID
15660             * @param version the version
15661             * @return the number of matching journal articles
15662             * @throws SystemException if a system exception occurred
15663             */
15664            public int countByC_V(long companyId, double version)
15665                    throws SystemException {
15666                    Object[] finderArgs = new Object[] { companyId, version };
15667    
15668                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V,
15669                                    finderArgs, this);
15670    
15671                    if (count == null) {
15672                            StringBundler query = new StringBundler(3);
15673    
15674                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15675    
15676                            query.append(_FINDER_COLUMN_C_V_COMPANYID_2);
15677    
15678                            query.append(_FINDER_COLUMN_C_V_VERSION_2);
15679    
15680                            String sql = query.toString();
15681    
15682                            Session session = null;
15683    
15684                            try {
15685                                    session = openSession();
15686    
15687                                    Query q = session.createQuery(sql);
15688    
15689                                    QueryPos qPos = QueryPos.getInstance(q);
15690    
15691                                    qPos.add(companyId);
15692    
15693                                    qPos.add(version);
15694    
15695                                    count = (Long)q.uniqueResult();
15696                            }
15697                            catch (Exception e) {
15698                                    throw processException(e);
15699                            }
15700                            finally {
15701                                    if (count == null) {
15702                                            count = Long.valueOf(0);
15703                                    }
15704    
15705                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V, finderArgs,
15706                                            count);
15707    
15708                                    closeSession(session);
15709                            }
15710                    }
15711    
15712                    return count.intValue();
15713            }
15714    
15715            /**
15716             * Returns the number of journal articles where companyId = &#63; and status = &#63;.
15717             *
15718             * @param companyId the company ID
15719             * @param status the status
15720             * @return the number of matching journal articles
15721             * @throws SystemException if a system exception occurred
15722             */
15723            public int countByC_ST(long companyId, int status)
15724                    throws SystemException {
15725                    Object[] finderArgs = new Object[] { companyId, status };
15726    
15727                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_ST,
15728                                    finderArgs, this);
15729    
15730                    if (count == null) {
15731                            StringBundler query = new StringBundler(3);
15732    
15733                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15734    
15735                            query.append(_FINDER_COLUMN_C_ST_COMPANYID_2);
15736    
15737                            query.append(_FINDER_COLUMN_C_ST_STATUS_2);
15738    
15739                            String sql = query.toString();
15740    
15741                            Session session = null;
15742    
15743                            try {
15744                                    session = openSession();
15745    
15746                                    Query q = session.createQuery(sql);
15747    
15748                                    QueryPos qPos = QueryPos.getInstance(q);
15749    
15750                                    qPos.add(companyId);
15751    
15752                                    qPos.add(status);
15753    
15754                                    count = (Long)q.uniqueResult();
15755                            }
15756                            catch (Exception e) {
15757                                    throw processException(e);
15758                            }
15759                            finally {
15760                                    if (count == null) {
15761                                            count = Long.valueOf(0);
15762                                    }
15763    
15764                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_ST,
15765                                            finderArgs, count);
15766    
15767                                    closeSession(session);
15768                            }
15769                    }
15770    
15771                    return count.intValue();
15772            }
15773    
15774            /**
15775             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15776             *
15777             * @param groupId the group ID
15778             * @param classNameId the class name ID
15779             * @param classPK the class p k
15780             * @return the number of matching journal articles
15781             * @throws SystemException if a system exception occurred
15782             */
15783            public int countByG_C_C(long groupId, long classNameId, long classPK)
15784                    throws SystemException {
15785                    Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
15786    
15787                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
15788                                    finderArgs, this);
15789    
15790                    if (count == null) {
15791                            StringBundler query = new StringBundler(4);
15792    
15793                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15794    
15795                            query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
15796    
15797                            query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
15798    
15799                            query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
15800    
15801                            String sql = query.toString();
15802    
15803                            Session session = null;
15804    
15805                            try {
15806                                    session = openSession();
15807    
15808                                    Query q = session.createQuery(sql);
15809    
15810                                    QueryPos qPos = QueryPos.getInstance(q);
15811    
15812                                    qPos.add(groupId);
15813    
15814                                    qPos.add(classNameId);
15815    
15816                                    qPos.add(classPK);
15817    
15818                                    count = (Long)q.uniqueResult();
15819                            }
15820                            catch (Exception e) {
15821                                    throw processException(e);
15822                            }
15823                            finally {
15824                                    if (count == null) {
15825                                            count = Long.valueOf(0);
15826                                    }
15827    
15828                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
15829                                            finderArgs, count);
15830    
15831                                    closeSession(session);
15832                            }
15833                    }
15834    
15835                    return count.intValue();
15836            }
15837    
15838            /**
15839             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and classPK = &#63;.
15840             *
15841             * @param groupId the group ID
15842             * @param classNameId the class name ID
15843             * @param classPK the class p k
15844             * @return the number of matching journal articles that the user has permission to view
15845             * @throws SystemException if a system exception occurred
15846             */
15847            public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
15848                    throws SystemException {
15849                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15850                            return countByG_C_C(groupId, classNameId, classPK);
15851                    }
15852    
15853                    StringBundler query = new StringBundler(4);
15854    
15855                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
15856    
15857                    query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
15858    
15859                    query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
15860    
15861                    query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
15862    
15863                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15864                                    JournalArticle.class.getName(),
15865                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15866    
15867                    Session session = null;
15868    
15869                    try {
15870                            session = openSession();
15871    
15872                            SQLQuery q = session.createSQLQuery(sql);
15873    
15874                            q.addScalar(COUNT_COLUMN_NAME,
15875                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15876    
15877                            QueryPos qPos = QueryPos.getInstance(q);
15878    
15879                            qPos.add(groupId);
15880    
15881                            qPos.add(classNameId);
15882    
15883                            qPos.add(classPK);
15884    
15885                            Long count = (Long)q.uniqueResult();
15886    
15887                            return count.intValue();
15888                    }
15889                    catch (Exception e) {
15890                            throw processException(e);
15891                    }
15892                    finally {
15893                            closeSession(session);
15894                    }
15895            }
15896    
15897            /**
15898             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and structureId = &#63;.
15899             *
15900             * @param groupId the group ID
15901             * @param classNameId the class name ID
15902             * @param structureId the structure ID
15903             * @return the number of matching journal articles
15904             * @throws SystemException if a system exception occurred
15905             */
15906            public int countByG_C_S(long groupId, long classNameId, String structureId)
15907                    throws SystemException {
15908                    Object[] finderArgs = new Object[] { groupId, classNameId, structureId };
15909    
15910                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S,
15911                                    finderArgs, this);
15912    
15913                    if (count == null) {
15914                            StringBundler query = new StringBundler(4);
15915    
15916                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15917    
15918                            query.append(_FINDER_COLUMN_G_C_S_GROUPID_2);
15919    
15920                            query.append(_FINDER_COLUMN_G_C_S_CLASSNAMEID_2);
15921    
15922                            if (structureId == null) {
15923                                    query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_1);
15924                            }
15925                            else {
15926                                    if (structureId.equals(StringPool.BLANK)) {
15927                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_3);
15928                                    }
15929                                    else {
15930                                            query.append(_FINDER_COLUMN_G_C_S_STRUCTUREID_2);
15931                                    }
15932                            }
15933    
15934                            String sql = query.toString();
15935    
15936                            Session session = null;
15937    
15938                            try {
15939                                    session = openSession();
15940    
15941                                    Query q = session.createQuery(sql);
15942    
15943                                    QueryPos qPos = QueryPos.getInstance(q);
15944    
15945                                    qPos.add(groupId);
15946    
15947                                    qPos.add(classNameId);
15948    
15949                                    if (structureId != null) {
15950                                            qPos.add(structureId);
15951                                    }
15952    
15953                                    count = (Long)q.uniqueResult();
15954                            }
15955                            catch (Exception e) {
15956                                    throw processException(e);
15957                            }
15958                            finally {
15959                                    if (count == null) {
15960                                            count = Long.valueOf(0);
15961                                    }
15962    
15963                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_S,
15964                                            finderArgs, count);
15965    
15966                                    closeSession(session);
15967                            }
15968                    }
15969    
15970                    return count.intValue();
15971            }
15972    
15973            /**
15974             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
15975             *
15976             * @param groupId the group ID
15977             * @param classNameId the class name ID
15978             * @param templateId the template ID
15979             * @return the number of matching journal articles
15980             * @throws SystemException if a system exception occurred
15981             */
15982            public int countByG_C_T(long groupId, long classNameId, String templateId)
15983                    throws SystemException {
15984                    Object[] finderArgs = new Object[] { groupId, classNameId, templateId };
15985    
15986                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_T,
15987                                    finderArgs, this);
15988    
15989                    if (count == null) {
15990                            StringBundler query = new StringBundler(4);
15991    
15992                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
15993    
15994                            query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
15995    
15996                            query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
15997    
15998                            if (templateId == null) {
15999                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16000                            }
16001                            else {
16002                                    if (templateId.equals(StringPool.BLANK)) {
16003                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16004                                    }
16005                                    else {
16006                                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16007                                    }
16008                            }
16009    
16010                            String sql = query.toString();
16011    
16012                            Session session = null;
16013    
16014                            try {
16015                                    session = openSession();
16016    
16017                                    Query q = session.createQuery(sql);
16018    
16019                                    QueryPos qPos = QueryPos.getInstance(q);
16020    
16021                                    qPos.add(groupId);
16022    
16023                                    qPos.add(classNameId);
16024    
16025                                    if (templateId != null) {
16026                                            qPos.add(templateId);
16027                                    }
16028    
16029                                    count = (Long)q.uniqueResult();
16030                            }
16031                            catch (Exception e) {
16032                                    throw processException(e);
16033                            }
16034                            finally {
16035                                    if (count == null) {
16036                                            count = Long.valueOf(0);
16037                                    }
16038    
16039                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_T,
16040                                            finderArgs, count);
16041    
16042                                    closeSession(session);
16043                            }
16044                    }
16045    
16046                    return count.intValue();
16047            }
16048    
16049            /**
16050             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and templateId = &#63;.
16051             *
16052             * @param groupId the group ID
16053             * @param classNameId the class name ID
16054             * @param templateId the template ID
16055             * @return the number of matching journal articles that the user has permission to view
16056             * @throws SystemException if a system exception occurred
16057             */
16058            public int filterCountByG_C_T(long groupId, long classNameId,
16059                    String templateId) throws SystemException {
16060                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16061                            return countByG_C_T(groupId, classNameId, templateId);
16062                    }
16063    
16064                    StringBundler query = new StringBundler(4);
16065    
16066                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16067    
16068                    query.append(_FINDER_COLUMN_G_C_T_GROUPID_2);
16069    
16070                    query.append(_FINDER_COLUMN_G_C_T_CLASSNAMEID_2);
16071    
16072                    if (templateId == null) {
16073                            query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_1);
16074                    }
16075                    else {
16076                            if (templateId.equals(StringPool.BLANK)) {
16077                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_3);
16078                            }
16079                            else {
16080                                    query.append(_FINDER_COLUMN_G_C_T_TEMPLATEID_2);
16081                            }
16082                    }
16083    
16084                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16085                                    JournalArticle.class.getName(),
16086                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16087    
16088                    Session session = null;
16089    
16090                    try {
16091                            session = openSession();
16092    
16093                            SQLQuery q = session.createSQLQuery(sql);
16094    
16095                            q.addScalar(COUNT_COLUMN_NAME,
16096                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16097    
16098                            QueryPos qPos = QueryPos.getInstance(q);
16099    
16100                            qPos.add(groupId);
16101    
16102                            qPos.add(classNameId);
16103    
16104                            if (templateId != null) {
16105                                    qPos.add(templateId);
16106                            }
16107    
16108                            Long count = (Long)q.uniqueResult();
16109    
16110                            return count.intValue();
16111                    }
16112                    catch (Exception e) {
16113                            throw processException(e);
16114                    }
16115                    finally {
16116                            closeSession(session);
16117                    }
16118            }
16119    
16120            /**
16121             * Returns the number of journal articles where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16122             *
16123             * @param groupId the group ID
16124             * @param classNameId the class name ID
16125             * @param layoutUuid the layout uuid
16126             * @return the number of matching journal articles
16127             * @throws SystemException if a system exception occurred
16128             */
16129            public int countByG_C_L(long groupId, long classNameId, String layoutUuid)
16130                    throws SystemException {
16131                    Object[] finderArgs = new Object[] { groupId, classNameId, layoutUuid };
16132    
16133                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_L,
16134                                    finderArgs, this);
16135    
16136                    if (count == null) {
16137                            StringBundler query = new StringBundler(4);
16138    
16139                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16140    
16141                            query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16142    
16143                            query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16144    
16145                            if (layoutUuid == null) {
16146                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16147                            }
16148                            else {
16149                                    if (layoutUuid.equals(StringPool.BLANK)) {
16150                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16151                                    }
16152                                    else {
16153                                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16154                                    }
16155                            }
16156    
16157                            String sql = query.toString();
16158    
16159                            Session session = null;
16160    
16161                            try {
16162                                    session = openSession();
16163    
16164                                    Query q = session.createQuery(sql);
16165    
16166                                    QueryPos qPos = QueryPos.getInstance(q);
16167    
16168                                    qPos.add(groupId);
16169    
16170                                    qPos.add(classNameId);
16171    
16172                                    if (layoutUuid != null) {
16173                                            qPos.add(layoutUuid);
16174                                    }
16175    
16176                                    count = (Long)q.uniqueResult();
16177                            }
16178                            catch (Exception e) {
16179                                    throw processException(e);
16180                            }
16181                            finally {
16182                                    if (count == null) {
16183                                            count = Long.valueOf(0);
16184                                    }
16185    
16186                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_L,
16187                                            finderArgs, count);
16188    
16189                                    closeSession(session);
16190                            }
16191                    }
16192    
16193                    return count.intValue();
16194            }
16195    
16196            /**
16197             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and classNameId = &#63; and layoutUuid = &#63;.
16198             *
16199             * @param groupId the group ID
16200             * @param classNameId the class name ID
16201             * @param layoutUuid the layout uuid
16202             * @return the number of matching journal articles that the user has permission to view
16203             * @throws SystemException if a system exception occurred
16204             */
16205            public int filterCountByG_C_L(long groupId, long classNameId,
16206                    String layoutUuid) throws SystemException {
16207                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16208                            return countByG_C_L(groupId, classNameId, layoutUuid);
16209                    }
16210    
16211                    StringBundler query = new StringBundler(4);
16212    
16213                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16214    
16215                    query.append(_FINDER_COLUMN_G_C_L_GROUPID_2);
16216    
16217                    query.append(_FINDER_COLUMN_G_C_L_CLASSNAMEID_2);
16218    
16219                    if (layoutUuid == null) {
16220                            query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_1);
16221                    }
16222                    else {
16223                            if (layoutUuid.equals(StringPool.BLANK)) {
16224                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_3);
16225                            }
16226                            else {
16227                                    query.append(_FINDER_COLUMN_G_C_L_LAYOUTUUID_2);
16228                            }
16229                    }
16230    
16231                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16232                                    JournalArticle.class.getName(),
16233                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16234    
16235                    Session session = null;
16236    
16237                    try {
16238                            session = openSession();
16239    
16240                            SQLQuery q = session.createSQLQuery(sql);
16241    
16242                            q.addScalar(COUNT_COLUMN_NAME,
16243                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16244    
16245                            QueryPos qPos = QueryPos.getInstance(q);
16246    
16247                            qPos.add(groupId);
16248    
16249                            qPos.add(classNameId);
16250    
16251                            if (layoutUuid != null) {
16252                                    qPos.add(layoutUuid);
16253                            }
16254    
16255                            Long count = (Long)q.uniqueResult();
16256    
16257                            return count.intValue();
16258                    }
16259                    catch (Exception e) {
16260                            throw processException(e);
16261                    }
16262                    finally {
16263                            closeSession(session);
16264                    }
16265            }
16266    
16267            /**
16268             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and version = &#63;.
16269             *
16270             * @param groupId the group ID
16271             * @param articleId the article ID
16272             * @param version the version
16273             * @return the number of matching journal articles
16274             * @throws SystemException if a system exception occurred
16275             */
16276            public int countByG_A_V(long groupId, String articleId, double version)
16277                    throws SystemException {
16278                    Object[] finderArgs = new Object[] { groupId, articleId, version };
16279    
16280                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_V,
16281                                    finderArgs, this);
16282    
16283                    if (count == null) {
16284                            StringBundler query = new StringBundler(4);
16285    
16286                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16287    
16288                            query.append(_FINDER_COLUMN_G_A_V_GROUPID_2);
16289    
16290                            if (articleId == null) {
16291                                    query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_1);
16292                            }
16293                            else {
16294                                    if (articleId.equals(StringPool.BLANK)) {
16295                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_3);
16296                                    }
16297                                    else {
16298                                            query.append(_FINDER_COLUMN_G_A_V_ARTICLEID_2);
16299                                    }
16300                            }
16301    
16302                            query.append(_FINDER_COLUMN_G_A_V_VERSION_2);
16303    
16304                            String sql = query.toString();
16305    
16306                            Session session = null;
16307    
16308                            try {
16309                                    session = openSession();
16310    
16311                                    Query q = session.createQuery(sql);
16312    
16313                                    QueryPos qPos = QueryPos.getInstance(q);
16314    
16315                                    qPos.add(groupId);
16316    
16317                                    if (articleId != null) {
16318                                            qPos.add(articleId);
16319                                    }
16320    
16321                                    qPos.add(version);
16322    
16323                                    count = (Long)q.uniqueResult();
16324                            }
16325                            catch (Exception e) {
16326                                    throw processException(e);
16327                            }
16328                            finally {
16329                                    if (count == null) {
16330                                            count = Long.valueOf(0);
16331                                    }
16332    
16333                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_V,
16334                                            finderArgs, count);
16335    
16336                                    closeSession(session);
16337                            }
16338                    }
16339    
16340                    return count.intValue();
16341            }
16342    
16343            /**
16344             * Returns the number of journal articles where groupId = &#63; and articleId = &#63; and status = &#63;.
16345             *
16346             * @param groupId the group ID
16347             * @param articleId the article ID
16348             * @param status the status
16349             * @return the number of matching journal articles
16350             * @throws SystemException if a system exception occurred
16351             */
16352            public int countByG_A_ST(long groupId, String articleId, int status)
16353                    throws SystemException {
16354                    Object[] finderArgs = new Object[] { groupId, articleId, status };
16355    
16356                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A_ST,
16357                                    finderArgs, this);
16358    
16359                    if (count == null) {
16360                            StringBundler query = new StringBundler(4);
16361    
16362                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16363    
16364                            query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
16365    
16366                            if (articleId == null) {
16367                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
16368                            }
16369                            else {
16370                                    if (articleId.equals(StringPool.BLANK)) {
16371                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
16372                                    }
16373                                    else {
16374                                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
16375                                    }
16376                            }
16377    
16378                            query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
16379    
16380                            String sql = query.toString();
16381    
16382                            Session session = null;
16383    
16384                            try {
16385                                    session = openSession();
16386    
16387                                    Query q = session.createQuery(sql);
16388    
16389                                    QueryPos qPos = QueryPos.getInstance(q);
16390    
16391                                    qPos.add(groupId);
16392    
16393                                    if (articleId != null) {
16394                                            qPos.add(articleId);
16395                                    }
16396    
16397                                    qPos.add(status);
16398    
16399                                    count = (Long)q.uniqueResult();
16400                            }
16401                            catch (Exception e) {
16402                                    throw processException(e);
16403                            }
16404                            finally {
16405                                    if (count == null) {
16406                                            count = Long.valueOf(0);
16407                                    }
16408    
16409                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A_ST,
16410                                            finderArgs, count);
16411    
16412                                    closeSession(session);
16413                            }
16414                    }
16415    
16416                    return count.intValue();
16417            }
16418    
16419            /**
16420             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and articleId = &#63; and status = &#63;.
16421             *
16422             * @param groupId the group ID
16423             * @param articleId the article ID
16424             * @param status the status
16425             * @return the number of matching journal articles that the user has permission to view
16426             * @throws SystemException if a system exception occurred
16427             */
16428            public int filterCountByG_A_ST(long groupId, String articleId, int status)
16429                    throws SystemException {
16430                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16431                            return countByG_A_ST(groupId, articleId, status);
16432                    }
16433    
16434                    StringBundler query = new StringBundler(4);
16435    
16436                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16437    
16438                    query.append(_FINDER_COLUMN_G_A_ST_GROUPID_2);
16439    
16440                    if (articleId == null) {
16441                            query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_1);
16442                    }
16443                    else {
16444                            if (articleId.equals(StringPool.BLANK)) {
16445                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_3);
16446                            }
16447                            else {
16448                                    query.append(_FINDER_COLUMN_G_A_ST_ARTICLEID_2);
16449                            }
16450                    }
16451    
16452                    query.append(_FINDER_COLUMN_G_A_ST_STATUS_2);
16453    
16454                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16455                                    JournalArticle.class.getName(),
16456                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16457    
16458                    Session session = null;
16459    
16460                    try {
16461                            session = openSession();
16462    
16463                            SQLQuery q = session.createSQLQuery(sql);
16464    
16465                            q.addScalar(COUNT_COLUMN_NAME,
16466                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16467    
16468                            QueryPos qPos = QueryPos.getInstance(q);
16469    
16470                            qPos.add(groupId);
16471    
16472                            if (articleId != null) {
16473                                    qPos.add(articleId);
16474                            }
16475    
16476                            qPos.add(status);
16477    
16478                            Long count = (Long)q.uniqueResult();
16479    
16480                            return count.intValue();
16481                    }
16482                    catch (Exception e) {
16483                            throw processException(e);
16484                    }
16485                    finally {
16486                            closeSession(session);
16487                    }
16488            }
16489    
16490            /**
16491             * Returns the number of journal articles where groupId = &#63; and urlTitle = &#63; and status = &#63;.
16492             *
16493             * @param groupId the group ID
16494             * @param urlTitle the url title
16495             * @param status the status
16496             * @return the number of matching journal articles
16497             * @throws SystemException if a system exception occurred
16498             */
16499            public int countByG_UT_ST(long groupId, String urlTitle, int status)
16500                    throws SystemException {
16501                    Object[] finderArgs = new Object[] { groupId, urlTitle, status };
16502    
16503                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT_ST,
16504                                    finderArgs, this);
16505    
16506                    if (count == null) {
16507                            StringBundler query = new StringBundler(4);
16508    
16509                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16510    
16511                            query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
16512    
16513                            if (urlTitle == null) {
16514                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
16515                            }
16516                            else {
16517                                    if (urlTitle.equals(StringPool.BLANK)) {
16518                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
16519                                    }
16520                                    else {
16521                                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
16522                                    }
16523                            }
16524    
16525                            query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
16526    
16527                            String sql = query.toString();
16528    
16529                            Session session = null;
16530    
16531                            try {
16532                                    session = openSession();
16533    
16534                                    Query q = session.createQuery(sql);
16535    
16536                                    QueryPos qPos = QueryPos.getInstance(q);
16537    
16538                                    qPos.add(groupId);
16539    
16540                                    if (urlTitle != null) {
16541                                            qPos.add(urlTitle);
16542                                    }
16543    
16544                                    qPos.add(status);
16545    
16546                                    count = (Long)q.uniqueResult();
16547                            }
16548                            catch (Exception e) {
16549                                    throw processException(e);
16550                            }
16551                            finally {
16552                                    if (count == null) {
16553                                            count = Long.valueOf(0);
16554                                    }
16555    
16556                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT_ST,
16557                                            finderArgs, count);
16558    
16559                                    closeSession(session);
16560                            }
16561                    }
16562    
16563                    return count.intValue();
16564            }
16565    
16566            /**
16567             * Returns the number of journal articles that the user has permission to view where groupId = &#63; and urlTitle = &#63; and status = &#63;.
16568             *
16569             * @param groupId the group ID
16570             * @param urlTitle the url title
16571             * @param status the status
16572             * @return the number of matching journal articles that the user has permission to view
16573             * @throws SystemException if a system exception occurred
16574             */
16575            public int filterCountByG_UT_ST(long groupId, String urlTitle, int status)
16576                    throws SystemException {
16577                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16578                            return countByG_UT_ST(groupId, urlTitle, status);
16579                    }
16580    
16581                    StringBundler query = new StringBundler(4);
16582    
16583                    query.append(_FILTER_SQL_COUNT_JOURNALARTICLE_WHERE);
16584    
16585                    query.append(_FINDER_COLUMN_G_UT_ST_GROUPID_2);
16586    
16587                    if (urlTitle == null) {
16588                            query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_1);
16589                    }
16590                    else {
16591                            if (urlTitle.equals(StringPool.BLANK)) {
16592                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_3);
16593                            }
16594                            else {
16595                                    query.append(_FINDER_COLUMN_G_UT_ST_URLTITLE_2);
16596                            }
16597                    }
16598    
16599                    query.append(_FINDER_COLUMN_G_UT_ST_STATUS_2);
16600    
16601                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16602                                    JournalArticle.class.getName(),
16603                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16604    
16605                    Session session = null;
16606    
16607                    try {
16608                            session = openSession();
16609    
16610                            SQLQuery q = session.createSQLQuery(sql);
16611    
16612                            q.addScalar(COUNT_COLUMN_NAME,
16613                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16614    
16615                            QueryPos qPos = QueryPos.getInstance(q);
16616    
16617                            qPos.add(groupId);
16618    
16619                            if (urlTitle != null) {
16620                                    qPos.add(urlTitle);
16621                            }
16622    
16623                            qPos.add(status);
16624    
16625                            Long count = (Long)q.uniqueResult();
16626    
16627                            return count.intValue();
16628                    }
16629                    catch (Exception e) {
16630                            throw processException(e);
16631                    }
16632                    finally {
16633                            closeSession(session);
16634                    }
16635            }
16636    
16637            /**
16638             * Returns the number of journal articles where companyId = &#63; and version = &#63; and status = &#63;.
16639             *
16640             * @param companyId the company ID
16641             * @param version the version
16642             * @param status the status
16643             * @return the number of matching journal articles
16644             * @throws SystemException if a system exception occurred
16645             */
16646            public int countByC_V_ST(long companyId, double version, int status)
16647                    throws SystemException {
16648                    Object[] finderArgs = new Object[] { companyId, version, status };
16649    
16650                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_V_ST,
16651                                    finderArgs, this);
16652    
16653                    if (count == null) {
16654                            StringBundler query = new StringBundler(4);
16655    
16656                            query.append(_SQL_COUNT_JOURNALARTICLE_WHERE);
16657    
16658                            query.append(_FINDER_COLUMN_C_V_ST_COMPANYID_2);
16659    
16660                            query.append(_FINDER_COLUMN_C_V_ST_VERSION_2);
16661    
16662                            query.append(_FINDER_COLUMN_C_V_ST_STATUS_2);
16663    
16664                            String sql = query.toString();
16665    
16666                            Session session = null;
16667    
16668                            try {
16669                                    session = openSession();
16670    
16671                                    Query q = session.createQuery(sql);
16672    
16673                                    QueryPos qPos = QueryPos.getInstance(q);
16674    
16675                                    qPos.add(companyId);
16676    
16677                                    qPos.add(version);
16678    
16679                                    qPos.add(status);
16680    
16681                                    count = (Long)q.uniqueResult();
16682                            }
16683                            catch (Exception e) {
16684                                    throw processException(e);
16685                            }
16686                            finally {
16687                                    if (count == null) {
16688                                            count = Long.valueOf(0);
16689                                    }
16690    
16691                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_V_ST,
16692                                            finderArgs, count);
16693    
16694                                    closeSession(session);
16695                            }
16696                    }
16697    
16698                    return count.intValue();
16699            }
16700    
16701            /**
16702             * Returns the number of journal articles.
16703             *
16704             * @return the number of journal articles
16705             * @throws SystemException if a system exception occurred
16706             */
16707            public int countAll() throws SystemException {
16708                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
16709                                    FINDER_ARGS_EMPTY, this);
16710    
16711                    if (count == null) {
16712                            Session session = null;
16713    
16714                            try {
16715                                    session = openSession();
16716    
16717                                    Query q = session.createQuery(_SQL_COUNT_JOURNALARTICLE);
16718    
16719                                    count = (Long)q.uniqueResult();
16720                            }
16721                            catch (Exception e) {
16722                                    throw processException(e);
16723                            }
16724                            finally {
16725                                    if (count == null) {
16726                                            count = Long.valueOf(0);
16727                                    }
16728    
16729                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
16730                                            FINDER_ARGS_EMPTY, count);
16731    
16732                                    closeSession(session);
16733                            }
16734                    }
16735    
16736                    return count.intValue();
16737            }
16738    
16739            /**
16740             * Initializes the journal article persistence.
16741             */
16742            public void afterPropertiesSet() {
16743                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
16744                                            com.liferay.portal.util.PropsUtil.get(
16745                                                    "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
16746    
16747                    if (listenerClassNames.length > 0) {
16748                            try {
16749                                    List<ModelListener<JournalArticle>> listenersList = new ArrayList<ModelListener<JournalArticle>>();
16750    
16751                                    for (String listenerClassName : listenerClassNames) {
16752                                            listenersList.add((ModelListener<JournalArticle>)InstanceFactory.newInstance(
16753                                                            listenerClassName));
16754                                    }
16755    
16756                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
16757                            }
16758                            catch (Exception e) {
16759                                    _log.error(e);
16760                            }
16761                    }
16762            }
16763    
16764            public void destroy() {
16765                    EntityCacheUtil.removeCache(JournalArticleImpl.class.getName());
16766                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
16767                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
16768            }
16769    
16770            @BeanReference(type = JournalArticlePersistence.class)
16771            protected JournalArticlePersistence journalArticlePersistence;
16772            @BeanReference(type = JournalArticleImagePersistence.class)
16773            protected JournalArticleImagePersistence journalArticleImagePersistence;
16774            @BeanReference(type = JournalArticleResourcePersistence.class)
16775            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
16776            @BeanReference(type = JournalContentSearchPersistence.class)
16777            protected JournalContentSearchPersistence journalContentSearchPersistence;
16778            @BeanReference(type = JournalFeedPersistence.class)
16779            protected JournalFeedPersistence journalFeedPersistence;
16780            @BeanReference(type = JournalStructurePersistence.class)
16781            protected JournalStructurePersistence journalStructurePersistence;
16782            @BeanReference(type = JournalTemplatePersistence.class)
16783            protected JournalTemplatePersistence journalTemplatePersistence;
16784            @BeanReference(type = CompanyPersistence.class)
16785            protected CompanyPersistence companyPersistence;
16786            @BeanReference(type = GroupPersistence.class)
16787            protected GroupPersistence groupPersistence;
16788            @BeanReference(type = ImagePersistence.class)
16789            protected ImagePersistence imagePersistence;
16790            @BeanReference(type = PortletPreferencesPersistence.class)
16791            protected PortletPreferencesPersistence portletPreferencesPersistence;
16792            @BeanReference(type = ResourcePersistence.class)
16793            protected ResourcePersistence resourcePersistence;
16794            @BeanReference(type = SubscriptionPersistence.class)
16795            protected SubscriptionPersistence subscriptionPersistence;
16796            @BeanReference(type = UserPersistence.class)
16797            protected UserPersistence userPersistence;
16798            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
16799            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
16800            @BeanReference(type = AssetCategoryPersistence.class)
16801            protected AssetCategoryPersistence assetCategoryPersistence;
16802            @BeanReference(type = AssetEntryPersistence.class)
16803            protected AssetEntryPersistence assetEntryPersistence;
16804            @BeanReference(type = AssetLinkPersistence.class)
16805            protected AssetLinkPersistence assetLinkPersistence;
16806            @BeanReference(type = AssetTagPersistence.class)
16807            protected AssetTagPersistence assetTagPersistence;
16808            @BeanReference(type = ExpandoValuePersistence.class)
16809            protected ExpandoValuePersistence expandoValuePersistence;
16810            @BeanReference(type = MBMessagePersistence.class)
16811            protected MBMessagePersistence mbMessagePersistence;
16812            @BeanReference(type = RatingsStatsPersistence.class)
16813            protected RatingsStatsPersistence ratingsStatsPersistence;
16814            private static final String _SQL_SELECT_JOURNALARTICLE = "SELECT journalArticle FROM JournalArticle journalArticle";
16815            private static final String _SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT journalArticle FROM JournalArticle journalArticle WHERE ";
16816            private static final String _SQL_COUNT_JOURNALARTICLE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle";
16817            private static final String _SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(journalArticle) FROM JournalArticle journalArticle WHERE ";
16818            private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalArticle.uuid IS NULL";
16819            private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalArticle.uuid = ?";
16820            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?)";
16821            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalArticle.uuid IS NULL AND ";
16822            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalArticle.uuid = ? AND ";
16823            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalArticle.uuid IS NULL OR journalArticle.uuid = ?) AND ";
16824            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalArticle.groupId = ?";
16825            private static final String _FINDER_COLUMN_RESOURCEPRIMKEY_RESOURCEPRIMKEY_2 =
16826                    "journalArticle.resourcePrimKey = ?";
16827            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalArticle.groupId = ?";
16828            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalArticle.companyId = ?";
16829            private static final String _FINDER_COLUMN_SMALLIMAGEID_SMALLIMAGEID_2 = "journalArticle.smallImageId = ?";
16830            private static final String _FINDER_COLUMN_R_ST_RESOURCEPRIMKEY_2 = "journalArticle.resourcePrimKey = ? AND ";
16831            private static final String _FINDER_COLUMN_R_ST_STATUS_2 = "journalArticle.status = ?";
16832            private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalArticle.groupId = ? AND ";
16833            private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalArticle.articleId IS NULL";
16834            private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalArticle.articleId = ?";
16835            private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?)";
16836            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "journalArticle.groupId = ? AND ";
16837            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "journalArticle.urlTitle IS NULL";
16838            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "journalArticle.urlTitle = ?";
16839            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?)";
16840            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
16841            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
16842            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
16843            private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
16844            private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
16845            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
16846            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
16847            private static final String _FINDER_COLUMN_G_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
16848            private static final String _FINDER_COLUMN_G_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
16849            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
16850            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
16851            private static final String _FINDER_COLUMN_G_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
16852            private static final String _FINDER_COLUMN_G_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16853            private static final String _FINDER_COLUMN_G_ST_STATUS_2 = "journalArticle.status = ?";
16854            private static final String _FINDER_COLUMN_C_V_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16855            private static final String _FINDER_COLUMN_C_V_VERSION_2 = "journalArticle.version = ?";
16856            private static final String _FINDER_COLUMN_C_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16857            private static final String _FINDER_COLUMN_C_ST_STATUS_2 = "journalArticle.status = ?";
16858            private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "journalArticle.groupId = ? AND ";
16859            private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16860            private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "journalArticle.classPK = ?";
16861            private static final String _FINDER_COLUMN_G_C_S_GROUPID_2 = "journalArticle.groupId = ? AND ";
16862            private static final String _FINDER_COLUMN_G_C_S_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16863            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_1 = "journalArticle.structureId IS NULL";
16864            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_2 = "journalArticle.structureId = ?";
16865            private static final String _FINDER_COLUMN_G_C_S_STRUCTUREID_3 = "(journalArticle.structureId IS NULL OR journalArticle.structureId = ?)";
16866            private static final String _FINDER_COLUMN_G_C_T_GROUPID_2 = "journalArticle.groupId = ? AND ";
16867            private static final String _FINDER_COLUMN_G_C_T_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16868            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_1 = "journalArticle.templateId IS NULL";
16869            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_2 = "journalArticle.templateId = ?";
16870            private static final String _FINDER_COLUMN_G_C_T_TEMPLATEID_3 = "(journalArticle.templateId IS NULL OR journalArticle.templateId = ?)";
16871            private static final String _FINDER_COLUMN_G_C_L_GROUPID_2 = "journalArticle.groupId = ? AND ";
16872            private static final String _FINDER_COLUMN_G_C_L_CLASSNAMEID_2 = "journalArticle.classNameId = ? AND ";
16873            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_1 = "journalArticle.layoutUuid IS NULL";
16874            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_2 = "journalArticle.layoutUuid = ?";
16875            private static final String _FINDER_COLUMN_G_C_L_LAYOUTUUID_3 = "(journalArticle.layoutUuid IS NULL OR journalArticle.layoutUuid = ?)";
16876            private static final String _FINDER_COLUMN_G_A_V_GROUPID_2 = "journalArticle.groupId = ? AND ";
16877            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
16878            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
16879            private static final String _FINDER_COLUMN_G_A_V_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
16880            private static final String _FINDER_COLUMN_G_A_V_VERSION_2 = "journalArticle.version = ?";
16881            private static final String _FINDER_COLUMN_G_A_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16882            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_1 = "journalArticle.articleId IS NULL AND ";
16883            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_2 = "journalArticle.articleId = ? AND ";
16884            private static final String _FINDER_COLUMN_G_A_ST_ARTICLEID_3 = "(journalArticle.articleId IS NULL OR journalArticle.articleId = ?) AND ";
16885            private static final String _FINDER_COLUMN_G_A_ST_STATUS_2 = "journalArticle.status = ?";
16886            private static final String _FINDER_COLUMN_G_UT_ST_GROUPID_2 = "journalArticle.groupId = ? AND ";
16887            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_1 = "journalArticle.urlTitle IS NULL AND ";
16888            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_2 = "journalArticle.urlTitle = ? AND ";
16889            private static final String _FINDER_COLUMN_G_UT_ST_URLTITLE_3 = "(journalArticle.urlTitle IS NULL OR journalArticle.urlTitle = ?) AND ";
16890            private static final String _FINDER_COLUMN_G_UT_ST_STATUS_2 = "journalArticle.status = ?";
16891            private static final String _FINDER_COLUMN_C_V_ST_COMPANYID_2 = "journalArticle.companyId = ? AND ";
16892            private static final String _FINDER_COLUMN_C_V_ST_VERSION_2 = "journalArticle.version = ? AND ";
16893            private static final String _FINDER_COLUMN_C_V_ST_STATUS_2 = "journalArticle.status = ?";
16894            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalArticle.id_";
16895            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_WHERE = "SELECT DISTINCT {journalArticle.*} FROM JournalArticle journalArticle WHERE ";
16896            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_1 =
16897                    "SELECT {JournalArticle.*} FROM (SELECT DISTINCT journalArticle.id_ FROM JournalArticle journalArticle WHERE ";
16898            private static final String _FILTER_SQL_SELECT_JOURNALARTICLE_NO_INLINE_DISTINCT_WHERE_2 =
16899                    ") TEMP_TABLE INNER JOIN JournalArticle ON TEMP_TABLE.id_ = JournalArticle.id_";
16900            private static final String _FILTER_SQL_COUNT_JOURNALARTICLE_WHERE = "SELECT COUNT(DISTINCT journalArticle.id_) AS COUNT_VALUE FROM JournalArticle journalArticle WHERE ";
16901            private static final String _FILTER_ENTITY_ALIAS = "journalArticle";
16902            private static final String _FILTER_ENTITY_TABLE = "JournalArticle";
16903            private static final String _ORDER_BY_ENTITY_ALIAS = "journalArticle.";
16904            private static final String _ORDER_BY_ENTITY_TABLE = "JournalArticle.";
16905            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalArticle exists with the primary key ";
16906            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalArticle exists with the key {";
16907            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
16908            private static Log _log = LogFactoryUtil.getLog(JournalArticlePersistenceImpl.class);
16909            private static JournalArticle _nullJournalArticle = new JournalArticleImpl() {
16910                            @Override
16911                            public Object clone() {
16912                                    return this;
16913                            }
16914    
16915                            @Override
16916                            public CacheModel<JournalArticle> toCacheModel() {
16917                                    return _nullJournalArticleCacheModel;
16918                            }
16919                    };
16920    
16921            private static CacheModel<JournalArticle> _nullJournalArticleCacheModel = new CacheModel<JournalArticle>() {
16922                            public JournalArticle toEntityModel() {
16923                                    return _nullJournalArticle;
16924                            }
16925                    };
16926    }