001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.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.sanitizer.Sanitizer;
032    import com.liferay.portal.kernel.sanitizer.SanitizerException;
033    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
034    import com.liferay.portal.kernel.util.CalendarUtil;
035    import com.liferay.portal.kernel.util.ContentTypes;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.StringBundler;
040    import com.liferay.portal.kernel.util.StringPool;
041    import com.liferay.portal.kernel.util.StringUtil;
042    import com.liferay.portal.kernel.util.Validator;
043    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
044    import com.liferay.portal.model.CacheModel;
045    import com.liferay.portal.model.ModelListener;
046    import com.liferay.portal.security.auth.PrincipalThreadLocal;
047    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048    import com.liferay.portal.service.persistence.CompanyPersistence;
049    import com.liferay.portal.service.persistence.GroupPersistence;
050    import com.liferay.portal.service.persistence.ImagePersistence;
051    import com.liferay.portal.service.persistence.OrganizationPersistence;
052    import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
053    import com.liferay.portal.service.persistence.SubscriptionPersistence;
054    import com.liferay.portal.service.persistence.UserPersistence;
055    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
056    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
057    
058    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
059    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
060    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
061    import com.liferay.portlet.blogs.NoSuchEntryException;
062    import com.liferay.portlet.blogs.model.BlogsEntry;
063    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
064    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
065    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
066    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
067    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
068    import com.liferay.portlet.social.service.persistence.SocialActivityCounterPersistence;
069    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
070    import com.liferay.portlet.trash.service.persistence.TrashEntryPersistence;
071    
072    import java.io.Serializable;
073    
074    import java.util.ArrayList;
075    import java.util.Collections;
076    import java.util.Date;
077    import java.util.List;
078    
079    /**
080     * The persistence implementation for the blogs entry service.
081     *
082     * <p>
083     * Caching information and settings can be found in <code>portal.properties</code>
084     * </p>
085     *
086     * @author Brian Wing Shun Chan
087     * @see BlogsEntryPersistence
088     * @see BlogsEntryUtil
089     * @generated
090     */
091    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
092            implements BlogsEntryPersistence {
093            /*
094             * NOTE FOR DEVELOPERS:
095             *
096             * Never modify or reference this class directly. Always use {@link BlogsEntryUtil} to access the blogs entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
097             */
098            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
099            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
100                    ".List1";
101            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
102                    ".List2";
103            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
106                            new String[] {
107                                    String.class.getName(),
108                                    
109                            "java.lang.Integer", "java.lang.Integer",
110                                    "com.liferay.portal.kernel.util.OrderByComparator"
111                            });
112            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
113                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
115                            new String[] { String.class.getName() },
116                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK);
117            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
118                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
119                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
120                            new String[] { String.class.getName() });
121            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
122                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
123                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
124                            new String[] { String.class.getName(), Long.class.getName() },
125                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
126                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
127            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
128                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
130                            new String[] { String.class.getName(), Long.class.getName() });
131            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
132                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
133                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
134                            new String[] {
135                                    String.class.getName(), Long.class.getName(),
136                                    
137                            "java.lang.Integer", "java.lang.Integer",
138                                    "com.liferay.portal.kernel.util.OrderByComparator"
139                            });
140            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
141                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
142                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
143                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
144                            new String[] { String.class.getName(), Long.class.getName() },
145                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
146                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK);
147            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
148                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
149                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
150                            new String[] { String.class.getName(), Long.class.getName() });
151            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
152                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
153                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
154                            new String[] {
155                                    Long.class.getName(),
156                                    
157                            "java.lang.Integer", "java.lang.Integer",
158                                    "com.liferay.portal.kernel.util.OrderByComparator"
159                            });
160            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
161                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
162                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
164                            new String[] { Long.class.getName() },
165                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
166            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
167                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
168                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
169                            new String[] { Long.class.getName() });
170            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
171                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
172                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
173                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "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(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
182                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
183                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
184                            new String[] { Long.class.getName() },
185                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK);
186            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
187                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
188                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
189                            new String[] { Long.class.getName() });
190            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
191                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
192                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
193                            new String[] {
194                                    Long.class.getName(), Long.class.getName(),
195                                    
196                            "java.lang.Integer", "java.lang.Integer",
197                                    "com.liferay.portal.kernel.util.OrderByComparator"
198                            });
199            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
200                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
201                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
202                            new String[] { Long.class.getName(), Long.class.getName() },
203                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
204                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK);
205            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
206                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
207                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
208                            new String[] { Long.class.getName(), Long.class.getName() });
209            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
210                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
211                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
212                            new String[] {
213                                    Long.class.getName(), Date.class.getName(),
214                                    
215                            "java.lang.Integer", "java.lang.Integer",
216                                    "com.liferay.portal.kernel.util.OrderByComparator"
217                            });
218            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
219                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
220                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
221                            new String[] { Long.class.getName(), Date.class.getName() });
222            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
223                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
224                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NeS",
225                            new String[] {
226                                    Long.class.getName(), Integer.class.getName(),
227                                    
228                            "java.lang.Integer", "java.lang.Integer",
229                                    "com.liferay.portal.kernel.util.OrderByComparator"
230                            });
231            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
232                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
233                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NeS",
234                            new String[] { Long.class.getName(), Integer.class.getName() });
235            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
236                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
237                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
238                            new String[] {
239                                    Long.class.getName(), Integer.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_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
245                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
246                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
247                            new String[] { Long.class.getName(), Integer.class.getName() },
248                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
249                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
250            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
251                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
252                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
253                            new String[] { Long.class.getName(), Integer.class.getName() });
254            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
255                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
256                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
257                            new String[] { Long.class.getName(), String.class.getName() },
258                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
259                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
260            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
261                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
262                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
263                            new String[] { Long.class.getName(), String.class.getName() });
264            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
265                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
266                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
267                            new String[] {
268                                    Long.class.getName(), Date.class.getName(),
269                                    
270                            "java.lang.Integer", "java.lang.Integer",
271                                    "com.liferay.portal.kernel.util.OrderByComparator"
272                            });
273            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
274                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
275                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
276                            new String[] { Long.class.getName(), Date.class.getName() });
277            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
278                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
279                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NeS",
280                            new String[] {
281                                    Long.class.getName(), Integer.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_WITH_PAGINATION_COUNT_BY_G_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
287                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
288                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NeS",
289                            new String[] { Long.class.getName(), Integer.class.getName() });
290            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
291                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
292                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
293                            new String[] {
294                                    Long.class.getName(), Integer.class.getName(),
295                                    
296                            "java.lang.Integer", "java.lang.Integer",
297                                    "com.liferay.portal.kernel.util.OrderByComparator"
298                            });
299            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
300                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
301                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
302                            new String[] { Long.class.getName(), Integer.class.getName() },
303                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
304                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
305            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
306                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
307                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
308                            new String[] { Long.class.getName(), Integer.class.getName() });
309            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
310                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
311                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
312                            new String[] {
313                                    Date.class.getName(), Integer.class.getName(),
314                                    
315                            "java.lang.Integer", "java.lang.Integer",
316                                    "com.liferay.portal.kernel.util.OrderByComparator"
317                            });
318            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
319                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
320                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
321                            new String[] { Date.class.getName(), Integer.class.getName() });
322            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
323                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
324                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NeS",
325                            new String[] {
326                                    Long.class.getName(), Long.class.getName(),
327                                    Integer.class.getName(),
328                                    
329                            "java.lang.Integer", "java.lang.Integer",
330                                    "com.liferay.portal.kernel.util.OrderByComparator"
331                            });
332            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
333                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
334                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NeS",
335                            new String[] {
336                                    Long.class.getName(), Long.class.getName(),
337                                    Integer.class.getName()
338                            });
339            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
340                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
341                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
342                            new String[] {
343                                    Long.class.getName(), Long.class.getName(),
344                                    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_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
350                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
351                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
352                            new String[] {
353                                    Long.class.getName(), Long.class.getName(),
354                                    Integer.class.getName()
355                            },
356                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
357                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
358                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
359            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
360                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
361                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
362                            new String[] {
363                                    Long.class.getName(), Long.class.getName(),
364                                    Integer.class.getName()
365                            });
366            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NES =
367                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
368                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
369                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NeS",
370                            new String[] {
371                                    Long.class.getName(), Date.class.getName(),
372                                    Integer.class.getName(),
373                                    
374                            "java.lang.Integer", "java.lang.Integer",
375                                    "com.liferay.portal.kernel.util.OrderByComparator"
376                            });
377            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NES =
378                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
379                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
380                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NeS",
381                            new String[] {
382                                    Long.class.getName(), Date.class.getName(),
383                                    Integer.class.getName()
384                            });
385            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
386                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
387                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
388                            new String[] {
389                                    Long.class.getName(), Date.class.getName(),
390                                    Integer.class.getName(),
391                                    
392                            "java.lang.Integer", "java.lang.Integer",
393                                    "com.liferay.portal.kernel.util.OrderByComparator"
394                            });
395            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
396                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
397                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
398                            new String[] {
399                                    Long.class.getName(), Date.class.getName(),
400                                    Integer.class.getName()
401                            });
402            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
403                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
404                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
405                            new String[] {
406                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
407                                    
408                            "java.lang.Integer", "java.lang.Integer",
409                                    "com.liferay.portal.kernel.util.OrderByComparator"
410                            });
411            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
412                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
413                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
414                            new String[] {
415                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
416                            });
417            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
418                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
419                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NeS",
420                            new String[] {
421                                    Long.class.getName(), Long.class.getName(),
422                                    Integer.class.getName(),
423                                    
424                            "java.lang.Integer", "java.lang.Integer",
425                                    "com.liferay.portal.kernel.util.OrderByComparator"
426                            });
427            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NES = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
428                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
429                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NeS",
430                            new String[] {
431                                    Long.class.getName(), Long.class.getName(),
432                                    Integer.class.getName()
433                            });
434            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
435                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
436                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
437                            new String[] {
438                                    Long.class.getName(), Long.class.getName(),
439                                    Integer.class.getName(),
440                                    
441                            "java.lang.Integer", "java.lang.Integer",
442                                    "com.liferay.portal.kernel.util.OrderByComparator"
443                            });
444            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
445                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
446                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
447                            new String[] {
448                                    Long.class.getName(), Long.class.getName(),
449                                    Integer.class.getName()
450                            },
451                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
452                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
453                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK);
454            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
455                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
456                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
457                            new String[] {
458                                    Long.class.getName(), Long.class.getName(),
459                                    Integer.class.getName()
460                            });
461            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NES =
462                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
463                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
464                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NeS",
465                            new String[] {
466                                    Long.class.getName(), Date.class.getName(),
467                                    Integer.class.getName(),
468                                    
469                            "java.lang.Integer", "java.lang.Integer",
470                                    "com.liferay.portal.kernel.util.OrderByComparator"
471                            });
472            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NES =
473                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
474                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
475                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NeS",
476                            new String[] {
477                                    Long.class.getName(), Date.class.getName(),
478                                    Integer.class.getName()
479                            });
480            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
481                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
482                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
483                            new String[] {
484                                    Long.class.getName(), Date.class.getName(),
485                                    Integer.class.getName(),
486                                    
487                            "java.lang.Integer", "java.lang.Integer",
488                                    "com.liferay.portal.kernel.util.OrderByComparator"
489                            });
490            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
491                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
492                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
493                            new String[] {
494                                    Long.class.getName(), Date.class.getName(),
495                                    Integer.class.getName()
496                            });
497            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NES =
498                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
499                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
500                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NeS",
501                            new String[] {
502                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
503                                    Integer.class.getName(),
504                                    
505                            "java.lang.Integer", "java.lang.Integer",
506                                    "com.liferay.portal.kernel.util.OrderByComparator"
507                            });
508            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NES =
509                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
510                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
511                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NeS",
512                            new String[] {
513                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
514                                    Integer.class.getName()
515                            });
516            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
517                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
518                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
519                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
520                            new String[] {
521                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
522                                    Integer.class.getName(),
523                                    
524                            "java.lang.Integer", "java.lang.Integer",
525                                    "com.liferay.portal.kernel.util.OrderByComparator"
526                            });
527            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
528                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
529                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
530                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
531                            new String[] {
532                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
533                                    Integer.class.getName()
534                            });
535            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
536                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
537                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
538            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
539                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
540                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
541            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
542                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
543                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
544    
545            /**
546             * Caches the blogs entry in the entity cache if it is enabled.
547             *
548             * @param blogsEntry the blogs entry
549             */
550            public void cacheResult(BlogsEntry blogsEntry) {
551                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
552                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
553    
554                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
555                            new Object[] {
556                                    blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
557                            }, blogsEntry);
558    
559                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
560                            new Object[] {
561                                    Long.valueOf(blogsEntry.getGroupId()),
562                                    
563                            blogsEntry.getUrlTitle()
564                            }, blogsEntry);
565    
566                    blogsEntry.resetOriginalValues();
567            }
568    
569            /**
570             * Caches the blogs entries in the entity cache if it is enabled.
571             *
572             * @param blogsEntries the blogs entries
573             */
574            public void cacheResult(List<BlogsEntry> blogsEntries) {
575                    for (BlogsEntry blogsEntry : blogsEntries) {
576                            if (EntityCacheUtil.getResult(
577                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
578                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
579                                    cacheResult(blogsEntry);
580                            }
581                            else {
582                                    blogsEntry.resetOriginalValues();
583                            }
584                    }
585            }
586    
587            /**
588             * Clears the cache for all blogs entries.
589             *
590             * <p>
591             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
592             * </p>
593             */
594            @Override
595            public void clearCache() {
596                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
597                            CacheRegistryUtil.clear(BlogsEntryImpl.class.getName());
598                    }
599    
600                    EntityCacheUtil.clearCache(BlogsEntryImpl.class.getName());
601    
602                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
603                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
604                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
605            }
606    
607            /**
608             * Clears the cache for the blogs entry.
609             *
610             * <p>
611             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
612             * </p>
613             */
614            @Override
615            public void clearCache(BlogsEntry blogsEntry) {
616                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
617                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
618    
619                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
620                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
621    
622                    clearUniqueFindersCache(blogsEntry);
623            }
624    
625            @Override
626            public void clearCache(List<BlogsEntry> blogsEntries) {
627                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
628                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
629    
630                    for (BlogsEntry blogsEntry : blogsEntries) {
631                            EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
632                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
633    
634                            clearUniqueFindersCache(blogsEntry);
635                    }
636            }
637    
638            protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
639                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
640                            new Object[] {
641                                    blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
642                            });
643    
644                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
645                            new Object[] {
646                                    Long.valueOf(blogsEntry.getGroupId()),
647                                    
648                            blogsEntry.getUrlTitle()
649                            });
650            }
651    
652            /**
653             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
654             *
655             * @param entryId the primary key for the new blogs entry
656             * @return the new blogs entry
657             */
658            public BlogsEntry create(long entryId) {
659                    BlogsEntry blogsEntry = new BlogsEntryImpl();
660    
661                    blogsEntry.setNew(true);
662                    blogsEntry.setPrimaryKey(entryId);
663    
664                    String uuid = PortalUUIDUtil.generate();
665    
666                    blogsEntry.setUuid(uuid);
667    
668                    return blogsEntry;
669            }
670    
671            /**
672             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
673             *
674             * @param entryId the primary key of the blogs entry
675             * @return the blogs entry that was removed
676             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
677             * @throws SystemException if a system exception occurred
678             */
679            public BlogsEntry remove(long entryId)
680                    throws NoSuchEntryException, SystemException {
681                    return remove(Long.valueOf(entryId));
682            }
683    
684            /**
685             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
686             *
687             * @param primaryKey the primary key of the blogs entry
688             * @return the blogs entry that was removed
689             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
690             * @throws SystemException if a system exception occurred
691             */
692            @Override
693            public BlogsEntry remove(Serializable primaryKey)
694                    throws NoSuchEntryException, SystemException {
695                    Session session = null;
696    
697                    try {
698                            session = openSession();
699    
700                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
701                                            primaryKey);
702    
703                            if (blogsEntry == null) {
704                                    if (_log.isWarnEnabled()) {
705                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
706                                    }
707    
708                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
709                                            primaryKey);
710                            }
711    
712                            return remove(blogsEntry);
713                    }
714                    catch (NoSuchEntryException nsee) {
715                            throw nsee;
716                    }
717                    catch (Exception e) {
718                            throw processException(e);
719                    }
720                    finally {
721                            closeSession(session);
722                    }
723            }
724    
725            @Override
726            protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
727                    throws SystemException {
728                    blogsEntry = toUnwrappedModel(blogsEntry);
729    
730                    Session session = null;
731    
732                    try {
733                            session = openSession();
734    
735                            if (blogsEntry.isCachedModel()) {
736                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
737                                                    blogsEntry.getPrimaryKeyObj());
738                            }
739    
740                            session.delete(blogsEntry);
741                    }
742                    catch (Exception e) {
743                            throw processException(e);
744                    }
745                    finally {
746                            closeSession(session);
747                    }
748    
749                    clearCache(blogsEntry);
750    
751                    return blogsEntry;
752            }
753    
754            @Override
755            public BlogsEntry updateImpl(
756                    com.liferay.portlet.blogs.model.BlogsEntry blogsEntry)
757                    throws SystemException {
758                    blogsEntry = toUnwrappedModel(blogsEntry);
759    
760                    boolean isNew = blogsEntry.isNew();
761    
762                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
763    
764                    if (Validator.isNull(blogsEntry.getUuid())) {
765                            String uuid = PortalUUIDUtil.generate();
766    
767                            blogsEntry.setUuid(uuid);
768                    }
769    
770                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
771    
772                    if (userId > 0) {
773                            long companyId = blogsEntry.getCompanyId();
774    
775                            long groupId = blogsEntry.getGroupId();
776    
777                            long entryId = 0;
778    
779                            if (!isNew) {
780                                    entryId = blogsEntry.getPrimaryKey();
781                            }
782    
783                            try {
784                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
785                                                    userId,
786                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
787                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
788                                                    blogsEntry.getTitle(), null));
789    
790                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
791                                                    groupId, userId,
792                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
793                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
794                                                    blogsEntry.getContent(), null));
795                            }
796                            catch (SanitizerException se) {
797                                    throw new SystemException(se);
798                            }
799                    }
800    
801                    Session session = null;
802    
803                    try {
804                            session = openSession();
805    
806                            if (blogsEntry.isNew()) {
807                                    session.save(blogsEntry);
808    
809                                    blogsEntry.setNew(false);
810                            }
811                            else {
812                                    session.merge(blogsEntry);
813                            }
814                    }
815                    catch (Exception e) {
816                            throw processException(e);
817                    }
818                    finally {
819                            closeSession(session);
820                    }
821    
822                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
823    
824                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
825                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
826                    }
827    
828                    else {
829                            if ((blogsEntryModelImpl.getColumnBitmask() &
830                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
831                                    Object[] args = new Object[] {
832                                                    blogsEntryModelImpl.getOriginalUuid()
833                                            };
834    
835                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
836                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
837                                            args);
838    
839                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
840    
841                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
842                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
843                                            args);
844                            }
845    
846                            if ((blogsEntryModelImpl.getColumnBitmask() &
847                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
848                                    Object[] args = new Object[] {
849                                                    blogsEntryModelImpl.getOriginalUuid(),
850                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId())
851                                            };
852    
853                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
854                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
855                                            args);
856    
857                                    args = new Object[] {
858                                                    blogsEntryModelImpl.getUuid(),
859                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId())
860                                            };
861    
862                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
863                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
864                                            args);
865                            }
866    
867                            if ((blogsEntryModelImpl.getColumnBitmask() &
868                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
869                                    Object[] args = new Object[] {
870                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId())
871                                            };
872    
873                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
874                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
875                                            args);
876    
877                                    args = new Object[] {
878                                                    Long.valueOf(blogsEntryModelImpl.getGroupId())
879                                            };
880    
881                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
882                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
883                                            args);
884                            }
885    
886                            if ((blogsEntryModelImpl.getColumnBitmask() &
887                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
888                                    Object[] args = new Object[] {
889                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId())
890                                            };
891    
892                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
893                                            args);
894                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
895                                            args);
896    
897                                    args = new Object[] {
898                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId())
899                                            };
900    
901                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
902                                            args);
903                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
904                                            args);
905                            }
906    
907                            if ((blogsEntryModelImpl.getColumnBitmask() &
908                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
909                                    Object[] args = new Object[] {
910                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
911                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId())
912                                            };
913    
914                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
915                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
916                                            args);
917    
918                                    args = new Object[] {
919                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
920                                                    Long.valueOf(blogsEntryModelImpl.getUserId())
921                                            };
922    
923                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
924                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
925                                            args);
926                            }
927    
928                            if ((blogsEntryModelImpl.getColumnBitmask() &
929                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
930                                    Object[] args = new Object[] {
931                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
932                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
933                                            };
934    
935                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
936                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
937                                            args);
938    
939                                    args = new Object[] {
940                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
941                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
942                                            };
943    
944                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
945                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
946                                            args);
947                            }
948    
949                            if ((blogsEntryModelImpl.getColumnBitmask() &
950                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
951                                    Object[] args = new Object[] {
952                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
953                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
954                                            };
955    
956                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
957                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
958                                            args);
959    
960                                    args = new Object[] {
961                                                    Long.valueOf(blogsEntryModelImpl.getGroupId()),
962                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
963                                            };
964    
965                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
966                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
967                                            args);
968                            }
969    
970                            if ((blogsEntryModelImpl.getColumnBitmask() &
971                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
972                                    Object[] args = new Object[] {
973                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
974                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId()),
975                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
976                                            };
977    
978                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
979                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
980                                            args);
981    
982                                    args = new Object[] {
983                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
984                                                    Long.valueOf(blogsEntryModelImpl.getUserId()),
985                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
986                                            };
987    
988                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
989                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
990                                            args);
991                            }
992    
993                            if ((blogsEntryModelImpl.getColumnBitmask() &
994                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
995                                    Object[] args = new Object[] {
996                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
997                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId()),
998                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
999                                            };
1000    
1001                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
1002                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
1003                                            args);
1004    
1005                                    args = new Object[] {
1006                                                    Long.valueOf(blogsEntryModelImpl.getGroupId()),
1007                                                    Long.valueOf(blogsEntryModelImpl.getUserId()),
1008                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
1009                                            };
1010    
1011                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
1012                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
1013                                            args);
1014                            }
1015                    }
1016    
1017                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1018                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
1019    
1020                    if (isNew) {
1021                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1022                                    new Object[] {
1023                                            blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
1024                                    }, blogsEntry);
1025    
1026                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
1027                                    new Object[] {
1028                                            Long.valueOf(blogsEntry.getGroupId()),
1029                                            
1030                                    blogsEntry.getUrlTitle()
1031                                    }, blogsEntry);
1032                    }
1033                    else {
1034                            if ((blogsEntryModelImpl.getColumnBitmask() &
1035                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
1036                                    Object[] args = new Object[] {
1037                                                    blogsEntryModelImpl.getOriginalUuid(),
1038                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId())
1039                                            };
1040    
1041                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
1042    
1043                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
1044    
1045                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1046                                            new Object[] {
1047                                                    blogsEntry.getUuid(),
1048                                                    Long.valueOf(blogsEntry.getGroupId())
1049                                            }, blogsEntry);
1050                            }
1051    
1052                            if ((blogsEntryModelImpl.getColumnBitmask() &
1053                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
1054                                    Object[] args = new Object[] {
1055                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
1056                                                    
1057                                                    blogsEntryModelImpl.getOriginalUrlTitle()
1058                                            };
1059    
1060                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
1061    
1062                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
1063    
1064                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
1065                                            new Object[] {
1066                                                    Long.valueOf(blogsEntry.getGroupId()),
1067                                                    
1068                                            blogsEntry.getUrlTitle()
1069                                            }, blogsEntry);
1070                            }
1071                    }
1072    
1073                    return blogsEntry;
1074            }
1075    
1076            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
1077                    if (blogsEntry instanceof BlogsEntryImpl) {
1078                            return blogsEntry;
1079                    }
1080    
1081                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
1082    
1083                    blogsEntryImpl.setNew(blogsEntry.isNew());
1084                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
1085    
1086                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
1087                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
1088                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
1089                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
1090                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
1091                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
1092                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
1093                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
1094                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
1095                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
1096                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
1097                    blogsEntryImpl.setContent(blogsEntry.getContent());
1098                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
1099                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
1100                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
1101                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
1102                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
1103                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
1104                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
1105                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
1106                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
1107                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
1108                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
1109    
1110                    return blogsEntryImpl;
1111            }
1112    
1113            /**
1114             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
1115             *
1116             * @param primaryKey the primary key of the blogs entry
1117             * @return the blogs entry
1118             * @throws com.liferay.portal.NoSuchModelException if a blogs entry with the primary key could not be found
1119             * @throws SystemException if a system exception occurred
1120             */
1121            @Override
1122            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
1123                    throws NoSuchModelException, SystemException {
1124                    return findByPrimaryKey(((Long)primaryKey).longValue());
1125            }
1126    
1127            /**
1128             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
1129             *
1130             * @param entryId the primary key of the blogs entry
1131             * @return the blogs entry
1132             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            public BlogsEntry findByPrimaryKey(long entryId)
1136                    throws NoSuchEntryException, SystemException {
1137                    BlogsEntry blogsEntry = fetchByPrimaryKey(entryId);
1138    
1139                    if (blogsEntry == null) {
1140                            if (_log.isWarnEnabled()) {
1141                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
1142                            }
1143    
1144                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1145                                    entryId);
1146                    }
1147    
1148                    return blogsEntry;
1149            }
1150    
1151            /**
1152             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
1153             *
1154             * @param primaryKey the primary key of the blogs entry
1155             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            @Override
1159            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey)
1160                    throws SystemException {
1161                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1162            }
1163    
1164            /**
1165             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
1166             *
1167             * @param entryId the primary key of the blogs entry
1168             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
1169             * @throws SystemException if a system exception occurred
1170             */
1171            public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
1172                    BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1173                                    BlogsEntryImpl.class, entryId);
1174    
1175                    if (blogsEntry == _nullBlogsEntry) {
1176                            return null;
1177                    }
1178    
1179                    if (blogsEntry == null) {
1180                            Session session = null;
1181    
1182                            boolean hasException = false;
1183    
1184                            try {
1185                                    session = openSession();
1186    
1187                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
1188                                                    Long.valueOf(entryId));
1189                            }
1190                            catch (Exception e) {
1191                                    hasException = true;
1192    
1193                                    throw processException(e);
1194                            }
1195                            finally {
1196                                    if (blogsEntry != null) {
1197                                            cacheResult(blogsEntry);
1198                                    }
1199                                    else if (!hasException) {
1200                                            EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1201                                                    BlogsEntryImpl.class, entryId, _nullBlogsEntry);
1202                                    }
1203    
1204                                    closeSession(session);
1205                            }
1206                    }
1207    
1208                    return blogsEntry;
1209            }
1210    
1211            /**
1212             * Returns all the blogs entries where uuid = &#63;.
1213             *
1214             * @param uuid the uuid
1215             * @return the matching blogs entries
1216             * @throws SystemException if a system exception occurred
1217             */
1218            public List<BlogsEntry> findByUuid(String uuid) throws SystemException {
1219                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1220            }
1221    
1222            /**
1223             * Returns a range of all the blogs entries where uuid = &#63;.
1224             *
1225             * <p>
1226             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1227             * </p>
1228             *
1229             * @param uuid the uuid
1230             * @param start the lower bound of the range of blogs entries
1231             * @param end the upper bound of the range of blogs entries (not inclusive)
1232             * @return the range of matching blogs entries
1233             * @throws SystemException if a system exception occurred
1234             */
1235            public List<BlogsEntry> findByUuid(String uuid, int start, int end)
1236                    throws SystemException {
1237                    return findByUuid(uuid, start, end, null);
1238            }
1239    
1240            /**
1241             * Returns an ordered range of all the blogs entries where uuid = &#63;.
1242             *
1243             * <p>
1244             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1245             * </p>
1246             *
1247             * @param uuid the uuid
1248             * @param start the lower bound of the range of blogs entries
1249             * @param end the upper bound of the range of blogs entries (not inclusive)
1250             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1251             * @return the ordered range of matching blogs entries
1252             * @throws SystemException if a system exception occurred
1253             */
1254            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
1255                    OrderByComparator orderByComparator) throws SystemException {
1256                    FinderPath finderPath = null;
1257                    Object[] finderArgs = null;
1258    
1259                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1260                                    (orderByComparator == null)) {
1261                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1262                            finderArgs = new Object[] { uuid };
1263                    }
1264                    else {
1265                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1266                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1267                    }
1268    
1269                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1270                                    finderArgs, this);
1271    
1272                    if ((list != null) && !list.isEmpty()) {
1273                            for (BlogsEntry blogsEntry : list) {
1274                                    if (!Validator.equals(uuid, blogsEntry.getUuid())) {
1275                                            list = null;
1276    
1277                                            break;
1278                                    }
1279                            }
1280                    }
1281    
1282                    if (list == null) {
1283                            StringBundler query = null;
1284    
1285                            if (orderByComparator != null) {
1286                                    query = new StringBundler(3 +
1287                                                    (orderByComparator.getOrderByFields().length * 3));
1288                            }
1289                            else {
1290                                    query = new StringBundler(3);
1291                            }
1292    
1293                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1294    
1295                            if (uuid == null) {
1296                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1297                            }
1298                            else {
1299                                    if (uuid.equals(StringPool.BLANK)) {
1300                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1301                                    }
1302                                    else {
1303                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1304                                    }
1305                            }
1306    
1307                            if (orderByComparator != null) {
1308                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1309                                            orderByComparator);
1310                            }
1311    
1312                            else {
1313                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1314                            }
1315    
1316                            String sql = query.toString();
1317    
1318                            Session session = null;
1319    
1320                            try {
1321                                    session = openSession();
1322    
1323                                    Query q = session.createQuery(sql);
1324    
1325                                    QueryPos qPos = QueryPos.getInstance(q);
1326    
1327                                    if (uuid != null) {
1328                                            qPos.add(uuid);
1329                                    }
1330    
1331                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
1332                                                    end);
1333                            }
1334                            catch (Exception e) {
1335                                    throw processException(e);
1336                            }
1337                            finally {
1338                                    if (list == null) {
1339                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1340                                    }
1341                                    else {
1342                                            cacheResult(list);
1343    
1344                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1345                                    }
1346    
1347                                    closeSession(session);
1348                            }
1349                    }
1350    
1351                    return list;
1352            }
1353    
1354            /**
1355             * Returns the first blogs entry in the ordered set where uuid = &#63;.
1356             *
1357             * @param uuid the uuid
1358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1359             * @return the first matching blogs entry
1360             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1361             * @throws SystemException if a system exception occurred
1362             */
1363            public BlogsEntry findByUuid_First(String uuid,
1364                    OrderByComparator orderByComparator)
1365                    throws NoSuchEntryException, SystemException {
1366                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
1367    
1368                    if (blogsEntry != null) {
1369                            return blogsEntry;
1370                    }
1371    
1372                    StringBundler msg = new StringBundler(4);
1373    
1374                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1375    
1376                    msg.append("uuid=");
1377                    msg.append(uuid);
1378    
1379                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1380    
1381                    throw new NoSuchEntryException(msg.toString());
1382            }
1383    
1384            /**
1385             * Returns the first blogs entry in the ordered set where uuid = &#63;.
1386             *
1387             * @param uuid the uuid
1388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1389             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1390             * @throws SystemException if a system exception occurred
1391             */
1392            public BlogsEntry fetchByUuid_First(String uuid,
1393                    OrderByComparator orderByComparator) throws SystemException {
1394                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
1395    
1396                    if (!list.isEmpty()) {
1397                            return list.get(0);
1398                    }
1399    
1400                    return null;
1401            }
1402    
1403            /**
1404             * Returns the last blogs entry in the ordered set where uuid = &#63;.
1405             *
1406             * @param uuid the uuid
1407             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1408             * @return the last matching blogs entry
1409             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1410             * @throws SystemException if a system exception occurred
1411             */
1412            public BlogsEntry findByUuid_Last(String uuid,
1413                    OrderByComparator orderByComparator)
1414                    throws NoSuchEntryException, SystemException {
1415                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
1416    
1417                    if (blogsEntry != null) {
1418                            return blogsEntry;
1419                    }
1420    
1421                    StringBundler msg = new StringBundler(4);
1422    
1423                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1424    
1425                    msg.append("uuid=");
1426                    msg.append(uuid);
1427    
1428                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1429    
1430                    throw new NoSuchEntryException(msg.toString());
1431            }
1432    
1433            /**
1434             * Returns the last blogs entry in the ordered set where uuid = &#63;.
1435             *
1436             * @param uuid the uuid
1437             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1438             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1439             * @throws SystemException if a system exception occurred
1440             */
1441            public BlogsEntry fetchByUuid_Last(String uuid,
1442                    OrderByComparator orderByComparator) throws SystemException {
1443                    int count = countByUuid(uuid);
1444    
1445                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
1446                                    orderByComparator);
1447    
1448                    if (!list.isEmpty()) {
1449                            return list.get(0);
1450                    }
1451    
1452                    return null;
1453            }
1454    
1455            /**
1456             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
1457             *
1458             * @param entryId the primary key of the current blogs entry
1459             * @param uuid the uuid
1460             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1461             * @return the previous, current, and next blogs entry
1462             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1463             * @throws SystemException if a system exception occurred
1464             */
1465            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
1466                    OrderByComparator orderByComparator)
1467                    throws NoSuchEntryException, SystemException {
1468                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1469    
1470                    Session session = null;
1471    
1472                    try {
1473                            session = openSession();
1474    
1475                            BlogsEntry[] array = new BlogsEntryImpl[3];
1476    
1477                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
1478                                            orderByComparator, true);
1479    
1480                            array[1] = blogsEntry;
1481    
1482                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
1483                                            orderByComparator, false);
1484    
1485                            return array;
1486                    }
1487                    catch (Exception e) {
1488                            throw processException(e);
1489                    }
1490                    finally {
1491                            closeSession(session);
1492                    }
1493            }
1494    
1495            protected BlogsEntry getByUuid_PrevAndNext(Session session,
1496                    BlogsEntry blogsEntry, String uuid,
1497                    OrderByComparator orderByComparator, boolean previous) {
1498                    StringBundler query = null;
1499    
1500                    if (orderByComparator != null) {
1501                            query = new StringBundler(6 +
1502                                            (orderByComparator.getOrderByFields().length * 6));
1503                    }
1504                    else {
1505                            query = new StringBundler(3);
1506                    }
1507    
1508                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1509    
1510                    if (uuid == null) {
1511                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1512                    }
1513                    else {
1514                            if (uuid.equals(StringPool.BLANK)) {
1515                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1516                            }
1517                            else {
1518                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1519                            }
1520                    }
1521    
1522                    if (orderByComparator != null) {
1523                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1524    
1525                            if (orderByConditionFields.length > 0) {
1526                                    query.append(WHERE_AND);
1527                            }
1528    
1529                            for (int i = 0; i < orderByConditionFields.length; i++) {
1530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1531                                    query.append(orderByConditionFields[i]);
1532    
1533                                    if ((i + 1) < orderByConditionFields.length) {
1534                                            if (orderByComparator.isAscending() ^ previous) {
1535                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1536                                            }
1537                                            else {
1538                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1539                                            }
1540                                    }
1541                                    else {
1542                                            if (orderByComparator.isAscending() ^ previous) {
1543                                                    query.append(WHERE_GREATER_THAN);
1544                                            }
1545                                            else {
1546                                                    query.append(WHERE_LESSER_THAN);
1547                                            }
1548                                    }
1549                            }
1550    
1551                            query.append(ORDER_BY_CLAUSE);
1552    
1553                            String[] orderByFields = orderByComparator.getOrderByFields();
1554    
1555                            for (int i = 0; i < orderByFields.length; i++) {
1556                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1557                                    query.append(orderByFields[i]);
1558    
1559                                    if ((i + 1) < orderByFields.length) {
1560                                            if (orderByComparator.isAscending() ^ previous) {
1561                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1562                                            }
1563                                            else {
1564                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1565                                            }
1566                                    }
1567                                    else {
1568                                            if (orderByComparator.isAscending() ^ previous) {
1569                                                    query.append(ORDER_BY_ASC);
1570                                            }
1571                                            else {
1572                                                    query.append(ORDER_BY_DESC);
1573                                            }
1574                                    }
1575                            }
1576                    }
1577    
1578                    else {
1579                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1580                    }
1581    
1582                    String sql = query.toString();
1583    
1584                    Query q = session.createQuery(sql);
1585    
1586                    q.setFirstResult(0);
1587                    q.setMaxResults(2);
1588    
1589                    QueryPos qPos = QueryPos.getInstance(q);
1590    
1591                    if (uuid != null) {
1592                            qPos.add(uuid);
1593                    }
1594    
1595                    if (orderByComparator != null) {
1596                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1597    
1598                            for (Object value : values) {
1599                                    qPos.add(value);
1600                            }
1601                    }
1602    
1603                    List<BlogsEntry> list = q.list();
1604    
1605                    if (list.size() == 2) {
1606                            return list.get(1);
1607                    }
1608                    else {
1609                            return null;
1610                    }
1611            }
1612    
1613            /**
1614             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
1615             *
1616             * @param uuid the uuid
1617             * @param groupId the group ID
1618             * @return the matching blogs entry
1619             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1620             * @throws SystemException if a system exception occurred
1621             */
1622            public BlogsEntry findByUUID_G(String uuid, long groupId)
1623                    throws NoSuchEntryException, SystemException {
1624                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
1625    
1626                    if (blogsEntry == null) {
1627                            StringBundler msg = new StringBundler(6);
1628    
1629                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1630    
1631                            msg.append("uuid=");
1632                            msg.append(uuid);
1633    
1634                            msg.append(", groupId=");
1635                            msg.append(groupId);
1636    
1637                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1638    
1639                            if (_log.isWarnEnabled()) {
1640                                    _log.warn(msg.toString());
1641                            }
1642    
1643                            throw new NoSuchEntryException(msg.toString());
1644                    }
1645    
1646                    return blogsEntry;
1647            }
1648    
1649            /**
1650             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1651             *
1652             * @param uuid the uuid
1653             * @param groupId the group ID
1654             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1655             * @throws SystemException if a system exception occurred
1656             */
1657            public BlogsEntry fetchByUUID_G(String uuid, long groupId)
1658                    throws SystemException {
1659                    return fetchByUUID_G(uuid, groupId, true);
1660            }
1661    
1662            /**
1663             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1664             *
1665             * @param uuid the uuid
1666             * @param groupId the group ID
1667             * @param retrieveFromCache whether to use the finder cache
1668             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1669             * @throws SystemException if a system exception occurred
1670             */
1671            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
1672                    boolean retrieveFromCache) throws SystemException {
1673                    Object[] finderArgs = new Object[] { uuid, groupId };
1674    
1675                    Object result = null;
1676    
1677                    if (retrieveFromCache) {
1678                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1679                                            finderArgs, this);
1680                    }
1681    
1682                    if (result instanceof BlogsEntry) {
1683                            BlogsEntry blogsEntry = (BlogsEntry)result;
1684    
1685                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1686                                            (groupId != blogsEntry.getGroupId())) {
1687                                    result = null;
1688                            }
1689                    }
1690    
1691                    if (result == null) {
1692                            StringBundler query = new StringBundler(4);
1693    
1694                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1695    
1696                            if (uuid == null) {
1697                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1698                            }
1699                            else {
1700                                    if (uuid.equals(StringPool.BLANK)) {
1701                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1702                                    }
1703                                    else {
1704                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1705                                    }
1706                            }
1707    
1708                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1709    
1710                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1711    
1712                            String sql = query.toString();
1713    
1714                            Session session = null;
1715    
1716                            try {
1717                                    session = openSession();
1718    
1719                                    Query q = session.createQuery(sql);
1720    
1721                                    QueryPos qPos = QueryPos.getInstance(q);
1722    
1723                                    if (uuid != null) {
1724                                            qPos.add(uuid);
1725                                    }
1726    
1727                                    qPos.add(groupId);
1728    
1729                                    List<BlogsEntry> list = q.list();
1730    
1731                                    result = list;
1732    
1733                                    BlogsEntry blogsEntry = null;
1734    
1735                                    if (list.isEmpty()) {
1736                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1737                                                    finderArgs, list);
1738                                    }
1739                                    else {
1740                                            blogsEntry = list.get(0);
1741    
1742                                            cacheResult(blogsEntry);
1743    
1744                                            if ((blogsEntry.getUuid() == null) ||
1745                                                            !blogsEntry.getUuid().equals(uuid) ||
1746                                                            (blogsEntry.getGroupId() != groupId)) {
1747                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1748                                                            finderArgs, blogsEntry);
1749                                            }
1750                                    }
1751    
1752                                    return blogsEntry;
1753                            }
1754                            catch (Exception e) {
1755                                    throw processException(e);
1756                            }
1757                            finally {
1758                                    if (result == null) {
1759                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1760                                                    finderArgs);
1761                                    }
1762    
1763                                    closeSession(session);
1764                            }
1765                    }
1766                    else {
1767                            if (result instanceof List<?>) {
1768                                    return null;
1769                            }
1770                            else {
1771                                    return (BlogsEntry)result;
1772                            }
1773                    }
1774            }
1775    
1776            /**
1777             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
1778             *
1779             * @param uuid the uuid
1780             * @param companyId the company ID
1781             * @return the matching blogs entries
1782             * @throws SystemException if a system exception occurred
1783             */
1784            public List<BlogsEntry> findByUuid_C(String uuid, long companyId)
1785                    throws SystemException {
1786                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1787                            QueryUtil.ALL_POS, null);
1788            }
1789    
1790            /**
1791             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
1792             *
1793             * <p>
1794             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1795             * </p>
1796             *
1797             * @param uuid the uuid
1798             * @param companyId the company ID
1799             * @param start the lower bound of the range of blogs entries
1800             * @param end the upper bound of the range of blogs entries (not inclusive)
1801             * @return the range of matching blogs entries
1802             * @throws SystemException if a system exception occurred
1803             */
1804            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
1805                    int start, int end) throws SystemException {
1806                    return findByUuid_C(uuid, companyId, start, end, null);
1807            }
1808    
1809            /**
1810             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
1811             *
1812             * <p>
1813             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1814             * </p>
1815             *
1816             * @param uuid the uuid
1817             * @param companyId the company ID
1818             * @param start the lower bound of the range of blogs entries
1819             * @param end the upper bound of the range of blogs entries (not inclusive)
1820             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1821             * @return the ordered range of matching blogs entries
1822             * @throws SystemException if a system exception occurred
1823             */
1824            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
1825                    int start, int end, OrderByComparator orderByComparator)
1826                    throws SystemException {
1827                    FinderPath finderPath = null;
1828                    Object[] finderArgs = null;
1829    
1830                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1831                                    (orderByComparator == null)) {
1832                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1833                            finderArgs = new Object[] { uuid, companyId };
1834                    }
1835                    else {
1836                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1837                            finderArgs = new Object[] {
1838                                            uuid, companyId,
1839                                            
1840                                            start, end, orderByComparator
1841                                    };
1842                    }
1843    
1844                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1845                                    finderArgs, this);
1846    
1847                    if ((list != null) && !list.isEmpty()) {
1848                            for (BlogsEntry blogsEntry : list) {
1849                                    if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1850                                                    (companyId != blogsEntry.getCompanyId())) {
1851                                            list = null;
1852    
1853                                            break;
1854                                    }
1855                            }
1856                    }
1857    
1858                    if (list == null) {
1859                            StringBundler query = null;
1860    
1861                            if (orderByComparator != null) {
1862                                    query = new StringBundler(4 +
1863                                                    (orderByComparator.getOrderByFields().length * 3));
1864                            }
1865                            else {
1866                                    query = new StringBundler(4);
1867                            }
1868    
1869                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1870    
1871                            if (uuid == null) {
1872                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1873                            }
1874                            else {
1875                                    if (uuid.equals(StringPool.BLANK)) {
1876                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1877                                    }
1878                                    else {
1879                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1880                                    }
1881                            }
1882    
1883                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1884    
1885                            if (orderByComparator != null) {
1886                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1887                                            orderByComparator);
1888                            }
1889    
1890                            else {
1891                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1892                            }
1893    
1894                            String sql = query.toString();
1895    
1896                            Session session = null;
1897    
1898                            try {
1899                                    session = openSession();
1900    
1901                                    Query q = session.createQuery(sql);
1902    
1903                                    QueryPos qPos = QueryPos.getInstance(q);
1904    
1905                                    if (uuid != null) {
1906                                            qPos.add(uuid);
1907                                    }
1908    
1909                                    qPos.add(companyId);
1910    
1911                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
1912                                                    end);
1913                            }
1914                            catch (Exception e) {
1915                                    throw processException(e);
1916                            }
1917                            finally {
1918                                    if (list == null) {
1919                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1920                                    }
1921                                    else {
1922                                            cacheResult(list);
1923    
1924                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1925                                    }
1926    
1927                                    closeSession(session);
1928                            }
1929                    }
1930    
1931                    return list;
1932            }
1933    
1934            /**
1935             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1936             *
1937             * @param uuid the uuid
1938             * @param companyId the company ID
1939             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1940             * @return the first matching blogs entry
1941             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1942             * @throws SystemException if a system exception occurred
1943             */
1944            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1945                    OrderByComparator orderByComparator)
1946                    throws NoSuchEntryException, SystemException {
1947                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1948                                    orderByComparator);
1949    
1950                    if (blogsEntry != null) {
1951                            return blogsEntry;
1952                    }
1953    
1954                    StringBundler msg = new StringBundler(6);
1955    
1956                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1957    
1958                    msg.append("uuid=");
1959                    msg.append(uuid);
1960    
1961                    msg.append(", companyId=");
1962                    msg.append(companyId);
1963    
1964                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1965    
1966                    throw new NoSuchEntryException(msg.toString());
1967            }
1968    
1969            /**
1970             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1971             *
1972             * @param uuid the uuid
1973             * @param companyId the company ID
1974             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1975             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1976             * @throws SystemException if a system exception occurred
1977             */
1978            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1979                    OrderByComparator orderByComparator) throws SystemException {
1980                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1981                                    orderByComparator);
1982    
1983                    if (!list.isEmpty()) {
1984                            return list.get(0);
1985                    }
1986    
1987                    return null;
1988            }
1989    
1990            /**
1991             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1992             *
1993             * @param uuid the uuid
1994             * @param companyId the company ID
1995             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1996             * @return the last matching blogs entry
1997             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1998             * @throws SystemException if a system exception occurred
1999             */
2000            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
2001                    OrderByComparator orderByComparator)
2002                    throws NoSuchEntryException, SystemException {
2003                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
2004                                    orderByComparator);
2005    
2006                    if (blogsEntry != null) {
2007                            return blogsEntry;
2008                    }
2009    
2010                    StringBundler msg = new StringBundler(6);
2011    
2012                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2013    
2014                    msg.append("uuid=");
2015                    msg.append(uuid);
2016    
2017                    msg.append(", companyId=");
2018                    msg.append(companyId);
2019    
2020                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2021    
2022                    throw new NoSuchEntryException(msg.toString());
2023            }
2024    
2025            /**
2026             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
2027             *
2028             * @param uuid the uuid
2029             * @param companyId the company ID
2030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2031             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2032             * @throws SystemException if a system exception occurred
2033             */
2034            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
2035                    OrderByComparator orderByComparator) throws SystemException {
2036                    int count = countByUuid_C(uuid, companyId);
2037    
2038                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
2039                                    orderByComparator);
2040    
2041                    if (!list.isEmpty()) {
2042                            return list.get(0);
2043                    }
2044    
2045                    return null;
2046            }
2047    
2048            /**
2049             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
2050             *
2051             * @param entryId the primary key of the current blogs entry
2052             * @param uuid the uuid
2053             * @param companyId the company ID
2054             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2055             * @return the previous, current, and next blogs entry
2056             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2057             * @throws SystemException if a system exception occurred
2058             */
2059            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
2060                    long companyId, OrderByComparator orderByComparator)
2061                    throws NoSuchEntryException, SystemException {
2062                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2063    
2064                    Session session = null;
2065    
2066                    try {
2067                            session = openSession();
2068    
2069                            BlogsEntry[] array = new BlogsEntryImpl[3];
2070    
2071                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
2072                                            companyId, orderByComparator, true);
2073    
2074                            array[1] = blogsEntry;
2075    
2076                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
2077                                            companyId, orderByComparator, false);
2078    
2079                            return array;
2080                    }
2081                    catch (Exception e) {
2082                            throw processException(e);
2083                    }
2084                    finally {
2085                            closeSession(session);
2086                    }
2087            }
2088    
2089            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
2090                    BlogsEntry blogsEntry, String uuid, long companyId,
2091                    OrderByComparator orderByComparator, boolean previous) {
2092                    StringBundler query = null;
2093    
2094                    if (orderByComparator != null) {
2095                            query = new StringBundler(6 +
2096                                            (orderByComparator.getOrderByFields().length * 6));
2097                    }
2098                    else {
2099                            query = new StringBundler(3);
2100                    }
2101    
2102                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2103    
2104                    if (uuid == null) {
2105                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2106                    }
2107                    else {
2108                            if (uuid.equals(StringPool.BLANK)) {
2109                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2110                            }
2111                            else {
2112                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2113                            }
2114                    }
2115    
2116                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2117    
2118                    if (orderByComparator != null) {
2119                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2120    
2121                            if (orderByConditionFields.length > 0) {
2122                                    query.append(WHERE_AND);
2123                            }
2124    
2125                            for (int i = 0; i < orderByConditionFields.length; i++) {
2126                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2127                                    query.append(orderByConditionFields[i]);
2128    
2129                                    if ((i + 1) < orderByConditionFields.length) {
2130                                            if (orderByComparator.isAscending() ^ previous) {
2131                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2132                                            }
2133                                            else {
2134                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2135                                            }
2136                                    }
2137                                    else {
2138                                            if (orderByComparator.isAscending() ^ previous) {
2139                                                    query.append(WHERE_GREATER_THAN);
2140                                            }
2141                                            else {
2142                                                    query.append(WHERE_LESSER_THAN);
2143                                            }
2144                                    }
2145                            }
2146    
2147                            query.append(ORDER_BY_CLAUSE);
2148    
2149                            String[] orderByFields = orderByComparator.getOrderByFields();
2150    
2151                            for (int i = 0; i < orderByFields.length; i++) {
2152                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2153                                    query.append(orderByFields[i]);
2154    
2155                                    if ((i + 1) < orderByFields.length) {
2156                                            if (orderByComparator.isAscending() ^ previous) {
2157                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2158                                            }
2159                                            else {
2160                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2161                                            }
2162                                    }
2163                                    else {
2164                                            if (orderByComparator.isAscending() ^ previous) {
2165                                                    query.append(ORDER_BY_ASC);
2166                                            }
2167                                            else {
2168                                                    query.append(ORDER_BY_DESC);
2169                                            }
2170                                    }
2171                            }
2172                    }
2173    
2174                    else {
2175                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2176                    }
2177    
2178                    String sql = query.toString();
2179    
2180                    Query q = session.createQuery(sql);
2181    
2182                    q.setFirstResult(0);
2183                    q.setMaxResults(2);
2184    
2185                    QueryPos qPos = QueryPos.getInstance(q);
2186    
2187                    if (uuid != null) {
2188                            qPos.add(uuid);
2189                    }
2190    
2191                    qPos.add(companyId);
2192    
2193                    if (orderByComparator != null) {
2194                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2195    
2196                            for (Object value : values) {
2197                                    qPos.add(value);
2198                            }
2199                    }
2200    
2201                    List<BlogsEntry> list = q.list();
2202    
2203                    if (list.size() == 2) {
2204                            return list.get(1);
2205                    }
2206                    else {
2207                            return null;
2208                    }
2209            }
2210    
2211            /**
2212             * Returns all the blogs entries where groupId = &#63;.
2213             *
2214             * @param groupId the group ID
2215             * @return the matching blogs entries
2216             * @throws SystemException if a system exception occurred
2217             */
2218            public List<BlogsEntry> findByGroupId(long groupId)
2219                    throws SystemException {
2220                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2221            }
2222    
2223            /**
2224             * Returns a range of all the blogs entries where groupId = &#63;.
2225             *
2226             * <p>
2227             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2228             * </p>
2229             *
2230             * @param groupId the group ID
2231             * @param start the lower bound of the range of blogs entries
2232             * @param end the upper bound of the range of blogs entries (not inclusive)
2233             * @return the range of matching blogs entries
2234             * @throws SystemException if a system exception occurred
2235             */
2236            public List<BlogsEntry> findByGroupId(long groupId, int start, int end)
2237                    throws SystemException {
2238                    return findByGroupId(groupId, start, end, null);
2239            }
2240    
2241            /**
2242             * Returns an ordered range of all the blogs entries where groupId = &#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 groupId the group ID
2249             * @param start the lower bound of the range of blogs entries
2250             * @param end the upper bound of the range of blogs entries (not inclusive)
2251             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2252             * @return the ordered range of matching blogs entries
2253             * @throws SystemException if a system exception occurred
2254             */
2255            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
2256                    OrderByComparator orderByComparator) throws SystemException {
2257                    FinderPath finderPath = null;
2258                    Object[] finderArgs = null;
2259    
2260                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2261                                    (orderByComparator == null)) {
2262                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
2263                            finderArgs = new Object[] { groupId };
2264                    }
2265                    else {
2266                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
2267                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
2268                    }
2269    
2270                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2271                                    finderArgs, this);
2272    
2273                    if ((list != null) && !list.isEmpty()) {
2274                            for (BlogsEntry blogsEntry : list) {
2275                                    if ((groupId != blogsEntry.getGroupId())) {
2276                                            list = null;
2277    
2278                                            break;
2279                                    }
2280                            }
2281                    }
2282    
2283                    if (list == null) {
2284                            StringBundler query = null;
2285    
2286                            if (orderByComparator != null) {
2287                                    query = new StringBundler(3 +
2288                                                    (orderByComparator.getOrderByFields().length * 3));
2289                            }
2290                            else {
2291                                    query = new StringBundler(3);
2292                            }
2293    
2294                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2295    
2296                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2297    
2298                            if (orderByComparator != null) {
2299                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2300                                            orderByComparator);
2301                            }
2302    
2303                            else {
2304                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2305                            }
2306    
2307                            String sql = query.toString();
2308    
2309                            Session session = null;
2310    
2311                            try {
2312                                    session = openSession();
2313    
2314                                    Query q = session.createQuery(sql);
2315    
2316                                    QueryPos qPos = QueryPos.getInstance(q);
2317    
2318                                    qPos.add(groupId);
2319    
2320                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
2321                                                    end);
2322                            }
2323                            catch (Exception e) {
2324                                    throw processException(e);
2325                            }
2326                            finally {
2327                                    if (list == null) {
2328                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2329                                    }
2330                                    else {
2331                                            cacheResult(list);
2332    
2333                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2334                                    }
2335    
2336                                    closeSession(session);
2337                            }
2338                    }
2339    
2340                    return list;
2341            }
2342    
2343            /**
2344             * Returns the first blogs entry in the ordered set where groupId = &#63;.
2345             *
2346             * @param groupId the group ID
2347             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2348             * @return the first matching blogs entry
2349             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2350             * @throws SystemException if a system exception occurred
2351             */
2352            public BlogsEntry findByGroupId_First(long groupId,
2353                    OrderByComparator orderByComparator)
2354                    throws NoSuchEntryException, SystemException {
2355                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
2356    
2357                    if (blogsEntry != null) {
2358                            return blogsEntry;
2359                    }
2360    
2361                    StringBundler msg = new StringBundler(4);
2362    
2363                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2364    
2365                    msg.append("groupId=");
2366                    msg.append(groupId);
2367    
2368                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2369    
2370                    throw new NoSuchEntryException(msg.toString());
2371            }
2372    
2373            /**
2374             * Returns the first blogs entry in the ordered set where groupId = &#63;.
2375             *
2376             * @param groupId the group ID
2377             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2378             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2379             * @throws SystemException if a system exception occurred
2380             */
2381            public BlogsEntry fetchByGroupId_First(long groupId,
2382                    OrderByComparator orderByComparator) throws SystemException {
2383                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
2384    
2385                    if (!list.isEmpty()) {
2386                            return list.get(0);
2387                    }
2388    
2389                    return null;
2390            }
2391    
2392            /**
2393             * Returns the last blogs entry in the ordered set where groupId = &#63;.
2394             *
2395             * @param groupId the group ID
2396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2397             * @return the last matching blogs entry
2398             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2399             * @throws SystemException if a system exception occurred
2400             */
2401            public BlogsEntry findByGroupId_Last(long groupId,
2402                    OrderByComparator orderByComparator)
2403                    throws NoSuchEntryException, SystemException {
2404                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
2405    
2406                    if (blogsEntry != null) {
2407                            return blogsEntry;
2408                    }
2409    
2410                    StringBundler msg = new StringBundler(4);
2411    
2412                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2413    
2414                    msg.append("groupId=");
2415                    msg.append(groupId);
2416    
2417                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2418    
2419                    throw new NoSuchEntryException(msg.toString());
2420            }
2421    
2422            /**
2423             * Returns the last blogs entry in the ordered set where groupId = &#63;.
2424             *
2425             * @param groupId the group ID
2426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2427             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2428             * @throws SystemException if a system exception occurred
2429             */
2430            public BlogsEntry fetchByGroupId_Last(long groupId,
2431                    OrderByComparator orderByComparator) throws SystemException {
2432                    int count = countByGroupId(groupId);
2433    
2434                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
2435                                    orderByComparator);
2436    
2437                    if (!list.isEmpty()) {
2438                            return list.get(0);
2439                    }
2440    
2441                    return null;
2442            }
2443    
2444            /**
2445             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
2446             *
2447             * @param entryId the primary key of the current blogs entry
2448             * @param groupId the group ID
2449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2450             * @return the previous, current, and next blogs entry
2451             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2452             * @throws SystemException if a system exception occurred
2453             */
2454            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
2455                    OrderByComparator orderByComparator)
2456                    throws NoSuchEntryException, SystemException {
2457                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2458    
2459                    Session session = null;
2460    
2461                    try {
2462                            session = openSession();
2463    
2464                            BlogsEntry[] array = new BlogsEntryImpl[3];
2465    
2466                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
2467                                            orderByComparator, true);
2468    
2469                            array[1] = blogsEntry;
2470    
2471                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
2472                                            orderByComparator, false);
2473    
2474                            return array;
2475                    }
2476                    catch (Exception e) {
2477                            throw processException(e);
2478                    }
2479                    finally {
2480                            closeSession(session);
2481                    }
2482            }
2483    
2484            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
2485                    BlogsEntry blogsEntry, long groupId,
2486                    OrderByComparator orderByComparator, boolean previous) {
2487                    StringBundler query = null;
2488    
2489                    if (orderByComparator != null) {
2490                            query = new StringBundler(6 +
2491                                            (orderByComparator.getOrderByFields().length * 6));
2492                    }
2493                    else {
2494                            query = new StringBundler(3);
2495                    }
2496    
2497                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2498    
2499                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2500    
2501                    if (orderByComparator != null) {
2502                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2503    
2504                            if (orderByConditionFields.length > 0) {
2505                                    query.append(WHERE_AND);
2506                            }
2507    
2508                            for (int i = 0; i < orderByConditionFields.length; i++) {
2509                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2510                                    query.append(orderByConditionFields[i]);
2511    
2512                                    if ((i + 1) < orderByConditionFields.length) {
2513                                            if (orderByComparator.isAscending() ^ previous) {
2514                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2515                                            }
2516                                            else {
2517                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2518                                            }
2519                                    }
2520                                    else {
2521                                            if (orderByComparator.isAscending() ^ previous) {
2522                                                    query.append(WHERE_GREATER_THAN);
2523                                            }
2524                                            else {
2525                                                    query.append(WHERE_LESSER_THAN);
2526                                            }
2527                                    }
2528                            }
2529    
2530                            query.append(ORDER_BY_CLAUSE);
2531    
2532                            String[] orderByFields = orderByComparator.getOrderByFields();
2533    
2534                            for (int i = 0; i < orderByFields.length; i++) {
2535                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2536                                    query.append(orderByFields[i]);
2537    
2538                                    if ((i + 1) < orderByFields.length) {
2539                                            if (orderByComparator.isAscending() ^ previous) {
2540                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2541                                            }
2542                                            else {
2543                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2544                                            }
2545                                    }
2546                                    else {
2547                                            if (orderByComparator.isAscending() ^ previous) {
2548                                                    query.append(ORDER_BY_ASC);
2549                                            }
2550                                            else {
2551                                                    query.append(ORDER_BY_DESC);
2552                                            }
2553                                    }
2554                            }
2555                    }
2556    
2557                    else {
2558                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2559                    }
2560    
2561                    String sql = query.toString();
2562    
2563                    Query q = session.createQuery(sql);
2564    
2565                    q.setFirstResult(0);
2566                    q.setMaxResults(2);
2567    
2568                    QueryPos qPos = QueryPos.getInstance(q);
2569    
2570                    qPos.add(groupId);
2571    
2572                    if (orderByComparator != null) {
2573                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2574    
2575                            for (Object value : values) {
2576                                    qPos.add(value);
2577                            }
2578                    }
2579    
2580                    List<BlogsEntry> list = q.list();
2581    
2582                    if (list.size() == 2) {
2583                            return list.get(1);
2584                    }
2585                    else {
2586                            return null;
2587                    }
2588            }
2589    
2590            /**
2591             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
2592             *
2593             * @param groupId the group ID
2594             * @return the matching blogs entries that the user has permission to view
2595             * @throws SystemException if a system exception occurred
2596             */
2597            public List<BlogsEntry> filterFindByGroupId(long groupId)
2598                    throws SystemException {
2599                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2600                            QueryUtil.ALL_POS, null);
2601            }
2602    
2603            /**
2604             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
2605             *
2606             * <p>
2607             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2608             * </p>
2609             *
2610             * @param groupId the group ID
2611             * @param start the lower bound of the range of blogs entries
2612             * @param end the upper bound of the range of blogs entries (not inclusive)
2613             * @return the range of matching blogs entries that the user has permission to view
2614             * @throws SystemException if a system exception occurred
2615             */
2616            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end)
2617                    throws SystemException {
2618                    return filterFindByGroupId(groupId, start, end, null);
2619            }
2620    
2621            /**
2622             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
2623             *
2624             * <p>
2625             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2626             * </p>
2627             *
2628             * @param groupId the group ID
2629             * @param start the lower bound of the range of blogs entries
2630             * @param end the upper bound of the range of blogs entries (not inclusive)
2631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2632             * @return the ordered range of matching blogs entries that the user has permission to view
2633             * @throws SystemException if a system exception occurred
2634             */
2635            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
2636                    int end, OrderByComparator orderByComparator) throws SystemException {
2637                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2638                            return findByGroupId(groupId, start, end, orderByComparator);
2639                    }
2640    
2641                    StringBundler query = null;
2642    
2643                    if (orderByComparator != null) {
2644                            query = new StringBundler(3 +
2645                                            (orderByComparator.getOrderByFields().length * 3));
2646                    }
2647                    else {
2648                            query = new StringBundler(3);
2649                    }
2650    
2651                    if (getDB().isSupportsInlineDistinct()) {
2652                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2653                    }
2654                    else {
2655                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2656                    }
2657    
2658                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2659    
2660                    if (!getDB().isSupportsInlineDistinct()) {
2661                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2662                    }
2663    
2664                    if (orderByComparator != null) {
2665                            if (getDB().isSupportsInlineDistinct()) {
2666                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2667                                            orderByComparator);
2668                            }
2669                            else {
2670                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2671                                            orderByComparator);
2672                            }
2673                    }
2674    
2675                    else {
2676                            if (getDB().isSupportsInlineDistinct()) {
2677                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2678                            }
2679                            else {
2680                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2681                            }
2682                    }
2683    
2684                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2685                                    BlogsEntry.class.getName(),
2686                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2687    
2688                    Session session = null;
2689    
2690                    try {
2691                            session = openSession();
2692    
2693                            SQLQuery q = session.createSQLQuery(sql);
2694    
2695                            if (getDB().isSupportsInlineDistinct()) {
2696                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2697                            }
2698                            else {
2699                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2700                            }
2701    
2702                            QueryPos qPos = QueryPos.getInstance(q);
2703    
2704                            qPos.add(groupId);
2705    
2706                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2707                    }
2708                    catch (Exception e) {
2709                            throw processException(e);
2710                    }
2711                    finally {
2712                            closeSession(session);
2713                    }
2714            }
2715    
2716            /**
2717             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63;.
2718             *
2719             * @param entryId the primary key of the current blogs entry
2720             * @param groupId the group ID
2721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2722             * @return the previous, current, and next blogs entry
2723             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2724             * @throws SystemException if a system exception occurred
2725             */
2726            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2727                    long groupId, OrderByComparator orderByComparator)
2728                    throws NoSuchEntryException, SystemException {
2729                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2730                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2731                    }
2732    
2733                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2734    
2735                    Session session = null;
2736    
2737                    try {
2738                            session = openSession();
2739    
2740                            BlogsEntry[] array = new BlogsEntryImpl[3];
2741    
2742                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2743                                            groupId, orderByComparator, true);
2744    
2745                            array[1] = blogsEntry;
2746    
2747                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2748                                            groupId, orderByComparator, false);
2749    
2750                            return array;
2751                    }
2752                    catch (Exception e) {
2753                            throw processException(e);
2754                    }
2755                    finally {
2756                            closeSession(session);
2757                    }
2758            }
2759    
2760            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2761                    BlogsEntry blogsEntry, long groupId,
2762                    OrderByComparator orderByComparator, boolean previous) {
2763                    StringBundler query = null;
2764    
2765                    if (orderByComparator != null) {
2766                            query = new StringBundler(6 +
2767                                            (orderByComparator.getOrderByFields().length * 6));
2768                    }
2769                    else {
2770                            query = new StringBundler(3);
2771                    }
2772    
2773                    if (getDB().isSupportsInlineDistinct()) {
2774                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2775                    }
2776                    else {
2777                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2778                    }
2779    
2780                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2781    
2782                    if (!getDB().isSupportsInlineDistinct()) {
2783                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2784                    }
2785    
2786                    if (orderByComparator != null) {
2787                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2788    
2789                            if (orderByConditionFields.length > 0) {
2790                                    query.append(WHERE_AND);
2791                            }
2792    
2793                            for (int i = 0; i < orderByConditionFields.length; i++) {
2794                                    if (getDB().isSupportsInlineDistinct()) {
2795                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2796                                    }
2797                                    else {
2798                                            query.append(_ORDER_BY_ENTITY_TABLE);
2799                                    }
2800    
2801                                    query.append(orderByConditionFields[i]);
2802    
2803                                    if ((i + 1) < orderByConditionFields.length) {
2804                                            if (orderByComparator.isAscending() ^ previous) {
2805                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2806                                            }
2807                                            else {
2808                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2809                                            }
2810                                    }
2811                                    else {
2812                                            if (orderByComparator.isAscending() ^ previous) {
2813                                                    query.append(WHERE_GREATER_THAN);
2814                                            }
2815                                            else {
2816                                                    query.append(WHERE_LESSER_THAN);
2817                                            }
2818                                    }
2819                            }
2820    
2821                            query.append(ORDER_BY_CLAUSE);
2822    
2823                            String[] orderByFields = orderByComparator.getOrderByFields();
2824    
2825                            for (int i = 0; i < orderByFields.length; i++) {
2826                                    if (getDB().isSupportsInlineDistinct()) {
2827                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2828                                    }
2829                                    else {
2830                                            query.append(_ORDER_BY_ENTITY_TABLE);
2831                                    }
2832    
2833                                    query.append(orderByFields[i]);
2834    
2835                                    if ((i + 1) < orderByFields.length) {
2836                                            if (orderByComparator.isAscending() ^ previous) {
2837                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2838                                            }
2839                                            else {
2840                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2841                                            }
2842                                    }
2843                                    else {
2844                                            if (orderByComparator.isAscending() ^ previous) {
2845                                                    query.append(ORDER_BY_ASC);
2846                                            }
2847                                            else {
2848                                                    query.append(ORDER_BY_DESC);
2849                                            }
2850                                    }
2851                            }
2852                    }
2853    
2854                    else {
2855                            if (getDB().isSupportsInlineDistinct()) {
2856                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2857                            }
2858                            else {
2859                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2860                            }
2861                    }
2862    
2863                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2864                                    BlogsEntry.class.getName(),
2865                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2866    
2867                    SQLQuery q = session.createSQLQuery(sql);
2868    
2869                    q.setFirstResult(0);
2870                    q.setMaxResults(2);
2871    
2872                    if (getDB().isSupportsInlineDistinct()) {
2873                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2874                    }
2875                    else {
2876                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2877                    }
2878    
2879                    QueryPos qPos = QueryPos.getInstance(q);
2880    
2881                    qPos.add(groupId);
2882    
2883                    if (orderByComparator != null) {
2884                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2885    
2886                            for (Object value : values) {
2887                                    qPos.add(value);
2888                            }
2889                    }
2890    
2891                    List<BlogsEntry> list = q.list();
2892    
2893                    if (list.size() == 2) {
2894                            return list.get(1);
2895                    }
2896                    else {
2897                            return null;
2898                    }
2899            }
2900    
2901            /**
2902             * Returns all the blogs entries where companyId = &#63;.
2903             *
2904             * @param companyId the company ID
2905             * @return the matching blogs entries
2906             * @throws SystemException if a system exception occurred
2907             */
2908            public List<BlogsEntry> findByCompanyId(long companyId)
2909                    throws SystemException {
2910                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2911                            null);
2912            }
2913    
2914            /**
2915             * Returns a range of all the blogs entries where companyId = &#63;.
2916             *
2917             * <p>
2918             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2919             * </p>
2920             *
2921             * @param companyId the company ID
2922             * @param start the lower bound of the range of blogs entries
2923             * @param end the upper bound of the range of blogs entries (not inclusive)
2924             * @return the range of matching blogs entries
2925             * @throws SystemException if a system exception occurred
2926             */
2927            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end)
2928                    throws SystemException {
2929                    return findByCompanyId(companyId, start, end, null);
2930            }
2931    
2932            /**
2933             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2934             *
2935             * <p>
2936             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2937             * </p>
2938             *
2939             * @param companyId the company ID
2940             * @param start the lower bound of the range of blogs entries
2941             * @param end the upper bound of the range of blogs entries (not inclusive)
2942             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2943             * @return the ordered range of matching blogs entries
2944             * @throws SystemException if a system exception occurred
2945             */
2946            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2947                    OrderByComparator orderByComparator) throws SystemException {
2948                    FinderPath finderPath = null;
2949                    Object[] finderArgs = null;
2950    
2951                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2952                                    (orderByComparator == null)) {
2953                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2954                            finderArgs = new Object[] { companyId };
2955                    }
2956                    else {
2957                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2958                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2959                    }
2960    
2961                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2962                                    finderArgs, this);
2963    
2964                    if ((list != null) && !list.isEmpty()) {
2965                            for (BlogsEntry blogsEntry : list) {
2966                                    if ((companyId != blogsEntry.getCompanyId())) {
2967                                            list = null;
2968    
2969                                            break;
2970                                    }
2971                            }
2972                    }
2973    
2974                    if (list == null) {
2975                            StringBundler query = null;
2976    
2977                            if (orderByComparator != null) {
2978                                    query = new StringBundler(3 +
2979                                                    (orderByComparator.getOrderByFields().length * 3));
2980                            }
2981                            else {
2982                                    query = new StringBundler(3);
2983                            }
2984    
2985                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2986    
2987                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2988    
2989                            if (orderByComparator != null) {
2990                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2991                                            orderByComparator);
2992                            }
2993    
2994                            else {
2995                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2996                            }
2997    
2998                            String sql = query.toString();
2999    
3000                            Session session = null;
3001    
3002                            try {
3003                                    session = openSession();
3004    
3005                                    Query q = session.createQuery(sql);
3006    
3007                                    QueryPos qPos = QueryPos.getInstance(q);
3008    
3009                                    qPos.add(companyId);
3010    
3011                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
3012                                                    end);
3013                            }
3014                            catch (Exception e) {
3015                                    throw processException(e);
3016                            }
3017                            finally {
3018                                    if (list == null) {
3019                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3020                                    }
3021                                    else {
3022                                            cacheResult(list);
3023    
3024                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3025                                    }
3026    
3027                                    closeSession(session);
3028                            }
3029                    }
3030    
3031                    return list;
3032            }
3033    
3034            /**
3035             * Returns the first blogs entry in the ordered set where companyId = &#63;.
3036             *
3037             * @param companyId the company ID
3038             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3039             * @return the first matching blogs entry
3040             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3041             * @throws SystemException if a system exception occurred
3042             */
3043            public BlogsEntry findByCompanyId_First(long companyId,
3044                    OrderByComparator orderByComparator)
3045                    throws NoSuchEntryException, SystemException {
3046                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
3047                                    orderByComparator);
3048    
3049                    if (blogsEntry != null) {
3050                            return blogsEntry;
3051                    }
3052    
3053                    StringBundler msg = new StringBundler(4);
3054    
3055                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3056    
3057                    msg.append("companyId=");
3058                    msg.append(companyId);
3059    
3060                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3061    
3062                    throw new NoSuchEntryException(msg.toString());
3063            }
3064    
3065            /**
3066             * Returns the first blogs entry in the ordered set where companyId = &#63;.
3067             *
3068             * @param companyId the company ID
3069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3070             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3071             * @throws SystemException if a system exception occurred
3072             */
3073            public BlogsEntry fetchByCompanyId_First(long companyId,
3074                    OrderByComparator orderByComparator) throws SystemException {
3075                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
3076                                    orderByComparator);
3077    
3078                    if (!list.isEmpty()) {
3079                            return list.get(0);
3080                    }
3081    
3082                    return null;
3083            }
3084    
3085            /**
3086             * Returns the last blogs entry in the ordered set where companyId = &#63;.
3087             *
3088             * @param companyId the company ID
3089             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3090             * @return the last matching blogs entry
3091             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3092             * @throws SystemException if a system exception occurred
3093             */
3094            public BlogsEntry findByCompanyId_Last(long companyId,
3095                    OrderByComparator orderByComparator)
3096                    throws NoSuchEntryException, SystemException {
3097                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
3098                                    orderByComparator);
3099    
3100                    if (blogsEntry != null) {
3101                            return blogsEntry;
3102                    }
3103    
3104                    StringBundler msg = new StringBundler(4);
3105    
3106                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3107    
3108                    msg.append("companyId=");
3109                    msg.append(companyId);
3110    
3111                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3112    
3113                    throw new NoSuchEntryException(msg.toString());
3114            }
3115    
3116            /**
3117             * Returns the last blogs entry in the ordered set where companyId = &#63;.
3118             *
3119             * @param companyId the company ID
3120             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3121             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3122             * @throws SystemException if a system exception occurred
3123             */
3124            public BlogsEntry fetchByCompanyId_Last(long companyId,
3125                    OrderByComparator orderByComparator) throws SystemException {
3126                    int count = countByCompanyId(companyId);
3127    
3128                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
3129                                    orderByComparator);
3130    
3131                    if (!list.isEmpty()) {
3132                            return list.get(0);
3133                    }
3134    
3135                    return null;
3136            }
3137    
3138            /**
3139             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
3140             *
3141             * @param entryId the primary key of the current blogs entry
3142             * @param companyId the company ID
3143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3144             * @return the previous, current, and next blogs entry
3145             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3146             * @throws SystemException if a system exception occurred
3147             */
3148            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
3149                    long companyId, OrderByComparator orderByComparator)
3150                    throws NoSuchEntryException, SystemException {
3151                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3152    
3153                    Session session = null;
3154    
3155                    try {
3156                            session = openSession();
3157    
3158                            BlogsEntry[] array = new BlogsEntryImpl[3];
3159    
3160                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
3161                                            companyId, orderByComparator, true);
3162    
3163                            array[1] = blogsEntry;
3164    
3165                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
3166                                            companyId, orderByComparator, false);
3167    
3168                            return array;
3169                    }
3170                    catch (Exception e) {
3171                            throw processException(e);
3172                    }
3173                    finally {
3174                            closeSession(session);
3175                    }
3176            }
3177    
3178            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
3179                    BlogsEntry blogsEntry, long companyId,
3180                    OrderByComparator orderByComparator, boolean previous) {
3181                    StringBundler query = null;
3182    
3183                    if (orderByComparator != null) {
3184                            query = new StringBundler(6 +
3185                                            (orderByComparator.getOrderByFields().length * 6));
3186                    }
3187                    else {
3188                            query = new StringBundler(3);
3189                    }
3190    
3191                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3192    
3193                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3194    
3195                    if (orderByComparator != null) {
3196                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3197    
3198                            if (orderByConditionFields.length > 0) {
3199                                    query.append(WHERE_AND);
3200                            }
3201    
3202                            for (int i = 0; i < orderByConditionFields.length; i++) {
3203                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3204                                    query.append(orderByConditionFields[i]);
3205    
3206                                    if ((i + 1) < orderByConditionFields.length) {
3207                                            if (orderByComparator.isAscending() ^ previous) {
3208                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3209                                            }
3210                                            else {
3211                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3212                                            }
3213                                    }
3214                                    else {
3215                                            if (orderByComparator.isAscending() ^ previous) {
3216                                                    query.append(WHERE_GREATER_THAN);
3217                                            }
3218                                            else {
3219                                                    query.append(WHERE_LESSER_THAN);
3220                                            }
3221                                    }
3222                            }
3223    
3224                            query.append(ORDER_BY_CLAUSE);
3225    
3226                            String[] orderByFields = orderByComparator.getOrderByFields();
3227    
3228                            for (int i = 0; i < orderByFields.length; i++) {
3229                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3230                                    query.append(orderByFields[i]);
3231    
3232                                    if ((i + 1) < orderByFields.length) {
3233                                            if (orderByComparator.isAscending() ^ previous) {
3234                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3235                                            }
3236                                            else {
3237                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3238                                            }
3239                                    }
3240                                    else {
3241                                            if (orderByComparator.isAscending() ^ previous) {
3242                                                    query.append(ORDER_BY_ASC);
3243                                            }
3244                                            else {
3245                                                    query.append(ORDER_BY_DESC);
3246                                            }
3247                                    }
3248                            }
3249                    }
3250    
3251                    else {
3252                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3253                    }
3254    
3255                    String sql = query.toString();
3256    
3257                    Query q = session.createQuery(sql);
3258    
3259                    q.setFirstResult(0);
3260                    q.setMaxResults(2);
3261    
3262                    QueryPos qPos = QueryPos.getInstance(q);
3263    
3264                    qPos.add(companyId);
3265    
3266                    if (orderByComparator != null) {
3267                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3268    
3269                            for (Object value : values) {
3270                                    qPos.add(value);
3271                            }
3272                    }
3273    
3274                    List<BlogsEntry> list = q.list();
3275    
3276                    if (list.size() == 2) {
3277                            return list.get(1);
3278                    }
3279                    else {
3280                            return null;
3281                    }
3282            }
3283    
3284            /**
3285             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
3286             *
3287             * @param companyId the company ID
3288             * @param userId the user ID
3289             * @return the matching blogs entries
3290             * @throws SystemException if a system exception occurred
3291             */
3292            public List<BlogsEntry> findByC_U(long companyId, long userId)
3293                    throws SystemException {
3294                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
3295                            QueryUtil.ALL_POS, null);
3296            }
3297    
3298            /**
3299             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
3300             *
3301             * <p>
3302             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3303             * </p>
3304             *
3305             * @param companyId the company ID
3306             * @param userId the user ID
3307             * @param start the lower bound of the range of blogs entries
3308             * @param end the upper bound of the range of blogs entries (not inclusive)
3309             * @return the range of matching blogs entries
3310             * @throws SystemException if a system exception occurred
3311             */
3312            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
3313                    int end) throws SystemException {
3314                    return findByC_U(companyId, userId, start, end, null);
3315            }
3316    
3317            /**
3318             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
3319             *
3320             * <p>
3321             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3322             * </p>
3323             *
3324             * @param companyId the company ID
3325             * @param userId the user ID
3326             * @param start the lower bound of the range of blogs entries
3327             * @param end the upper bound of the range of blogs entries (not inclusive)
3328             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3329             * @return the ordered range of matching blogs entries
3330             * @throws SystemException if a system exception occurred
3331             */
3332            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
3333                    int end, OrderByComparator orderByComparator) throws SystemException {
3334                    FinderPath finderPath = null;
3335                    Object[] finderArgs = null;
3336    
3337                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3338                                    (orderByComparator == null)) {
3339                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
3340                            finderArgs = new Object[] { companyId, userId };
3341                    }
3342                    else {
3343                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
3344                            finderArgs = new Object[] {
3345                                            companyId, userId,
3346                                            
3347                                            start, end, orderByComparator
3348                                    };
3349                    }
3350    
3351                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3352                                    finderArgs, this);
3353    
3354                    if ((list != null) && !list.isEmpty()) {
3355                            for (BlogsEntry blogsEntry : list) {
3356                                    if ((companyId != blogsEntry.getCompanyId()) ||
3357                                                    (userId != blogsEntry.getUserId())) {
3358                                            list = null;
3359    
3360                                            break;
3361                                    }
3362                            }
3363                    }
3364    
3365                    if (list == null) {
3366                            StringBundler query = null;
3367    
3368                            if (orderByComparator != null) {
3369                                    query = new StringBundler(4 +
3370                                                    (orderByComparator.getOrderByFields().length * 3));
3371                            }
3372                            else {
3373                                    query = new StringBundler(4);
3374                            }
3375    
3376                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3377    
3378                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3379    
3380                            query.append(_FINDER_COLUMN_C_U_USERID_2);
3381    
3382                            if (orderByComparator != null) {
3383                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3384                                            orderByComparator);
3385                            }
3386    
3387                            else {
3388                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3389                            }
3390    
3391                            String sql = query.toString();
3392    
3393                            Session session = null;
3394    
3395                            try {
3396                                    session = openSession();
3397    
3398                                    Query q = session.createQuery(sql);
3399    
3400                                    QueryPos qPos = QueryPos.getInstance(q);
3401    
3402                                    qPos.add(companyId);
3403    
3404                                    qPos.add(userId);
3405    
3406                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
3407                                                    end);
3408                            }
3409                            catch (Exception e) {
3410                                    throw processException(e);
3411                            }
3412                            finally {
3413                                    if (list == null) {
3414                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3415                                    }
3416                                    else {
3417                                            cacheResult(list);
3418    
3419                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3420                                    }
3421    
3422                                    closeSession(session);
3423                            }
3424                    }
3425    
3426                    return list;
3427            }
3428    
3429            /**
3430             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3431             *
3432             * @param companyId the company ID
3433             * @param userId the user ID
3434             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3435             * @return the first matching blogs entry
3436             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3437             * @throws SystemException if a system exception occurred
3438             */
3439            public BlogsEntry findByC_U_First(long companyId, long userId,
3440                    OrderByComparator orderByComparator)
3441                    throws NoSuchEntryException, SystemException {
3442                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
3443                                    orderByComparator);
3444    
3445                    if (blogsEntry != null) {
3446                            return blogsEntry;
3447                    }
3448    
3449                    StringBundler msg = new StringBundler(6);
3450    
3451                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3452    
3453                    msg.append("companyId=");
3454                    msg.append(companyId);
3455    
3456                    msg.append(", userId=");
3457                    msg.append(userId);
3458    
3459                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3460    
3461                    throw new NoSuchEntryException(msg.toString());
3462            }
3463    
3464            /**
3465             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3466             *
3467             * @param companyId the company ID
3468             * @param userId the user ID
3469             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3470             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3471             * @throws SystemException if a system exception occurred
3472             */
3473            public BlogsEntry fetchByC_U_First(long companyId, long userId,
3474                    OrderByComparator orderByComparator) throws SystemException {
3475                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
3476                                    orderByComparator);
3477    
3478                    if (!list.isEmpty()) {
3479                            return list.get(0);
3480                    }
3481    
3482                    return null;
3483            }
3484    
3485            /**
3486             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3487             *
3488             * @param companyId the company ID
3489             * @param userId the user ID
3490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3491             * @return the last matching blogs entry
3492             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3493             * @throws SystemException if a system exception occurred
3494             */
3495            public BlogsEntry findByC_U_Last(long companyId, long userId,
3496                    OrderByComparator orderByComparator)
3497                    throws NoSuchEntryException, SystemException {
3498                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
3499                                    orderByComparator);
3500    
3501                    if (blogsEntry != null) {
3502                            return blogsEntry;
3503                    }
3504    
3505                    StringBundler msg = new StringBundler(6);
3506    
3507                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3508    
3509                    msg.append("companyId=");
3510                    msg.append(companyId);
3511    
3512                    msg.append(", userId=");
3513                    msg.append(userId);
3514    
3515                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3516    
3517                    throw new NoSuchEntryException(msg.toString());
3518            }
3519    
3520            /**
3521             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3522             *
3523             * @param companyId the company ID
3524             * @param userId the user ID
3525             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3526             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3527             * @throws SystemException if a system exception occurred
3528             */
3529            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
3530                    OrderByComparator orderByComparator) throws SystemException {
3531                    int count = countByC_U(companyId, userId);
3532    
3533                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
3534                                    orderByComparator);
3535    
3536                    if (!list.isEmpty()) {
3537                            return list.get(0);
3538                    }
3539    
3540                    return null;
3541            }
3542    
3543            /**
3544             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3545             *
3546             * @param entryId the primary key of the current blogs entry
3547             * @param companyId the company ID
3548             * @param userId the user ID
3549             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3550             * @return the previous, current, and next blogs entry
3551             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3552             * @throws SystemException if a system exception occurred
3553             */
3554            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
3555                    long userId, OrderByComparator orderByComparator)
3556                    throws NoSuchEntryException, SystemException {
3557                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3558    
3559                    Session session = null;
3560    
3561                    try {
3562                            session = openSession();
3563    
3564                            BlogsEntry[] array = new BlogsEntryImpl[3];
3565    
3566                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3567                                            userId, orderByComparator, true);
3568    
3569                            array[1] = blogsEntry;
3570    
3571                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3572                                            userId, orderByComparator, false);
3573    
3574                            return array;
3575                    }
3576                    catch (Exception e) {
3577                            throw processException(e);
3578                    }
3579                    finally {
3580                            closeSession(session);
3581                    }
3582            }
3583    
3584            protected BlogsEntry getByC_U_PrevAndNext(Session session,
3585                    BlogsEntry blogsEntry, long companyId, long userId,
3586                    OrderByComparator orderByComparator, boolean previous) {
3587                    StringBundler query = null;
3588    
3589                    if (orderByComparator != null) {
3590                            query = new StringBundler(6 +
3591                                            (orderByComparator.getOrderByFields().length * 6));
3592                    }
3593                    else {
3594                            query = new StringBundler(3);
3595                    }
3596    
3597                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3598    
3599                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3600    
3601                    query.append(_FINDER_COLUMN_C_U_USERID_2);
3602    
3603                    if (orderByComparator != null) {
3604                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3605    
3606                            if (orderByConditionFields.length > 0) {
3607                                    query.append(WHERE_AND);
3608                            }
3609    
3610                            for (int i = 0; i < orderByConditionFields.length; i++) {
3611                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3612                                    query.append(orderByConditionFields[i]);
3613    
3614                                    if ((i + 1) < orderByConditionFields.length) {
3615                                            if (orderByComparator.isAscending() ^ previous) {
3616                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3617                                            }
3618                                            else {
3619                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3620                                            }
3621                                    }
3622                                    else {
3623                                            if (orderByComparator.isAscending() ^ previous) {
3624                                                    query.append(WHERE_GREATER_THAN);
3625                                            }
3626                                            else {
3627                                                    query.append(WHERE_LESSER_THAN);
3628                                            }
3629                                    }
3630                            }
3631    
3632                            query.append(ORDER_BY_CLAUSE);
3633    
3634                            String[] orderByFields = orderByComparator.getOrderByFields();
3635    
3636                            for (int i = 0; i < orderByFields.length; i++) {
3637                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3638                                    query.append(orderByFields[i]);
3639    
3640                                    if ((i + 1) < orderByFields.length) {
3641                                            if (orderByComparator.isAscending() ^ previous) {
3642                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3643                                            }
3644                                            else {
3645                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3646                                            }
3647                                    }
3648                                    else {
3649                                            if (orderByComparator.isAscending() ^ previous) {
3650                                                    query.append(ORDER_BY_ASC);
3651                                            }
3652                                            else {
3653                                                    query.append(ORDER_BY_DESC);
3654                                            }
3655                                    }
3656                            }
3657                    }
3658    
3659                    else {
3660                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3661                    }
3662    
3663                    String sql = query.toString();
3664    
3665                    Query q = session.createQuery(sql);
3666    
3667                    q.setFirstResult(0);
3668                    q.setMaxResults(2);
3669    
3670                    QueryPos qPos = QueryPos.getInstance(q);
3671    
3672                    qPos.add(companyId);
3673    
3674                    qPos.add(userId);
3675    
3676                    if (orderByComparator != null) {
3677                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3678    
3679                            for (Object value : values) {
3680                                    qPos.add(value);
3681                            }
3682                    }
3683    
3684                    List<BlogsEntry> list = q.list();
3685    
3686                    if (list.size() == 2) {
3687                            return list.get(1);
3688                    }
3689                    else {
3690                            return null;
3691                    }
3692            }
3693    
3694            /**
3695             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3696             *
3697             * @param companyId the company ID
3698             * @param displayDate the display date
3699             * @return the matching blogs entries
3700             * @throws SystemException if a system exception occurred
3701             */
3702            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate)
3703                    throws SystemException {
3704                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
3705                            QueryUtil.ALL_POS, null);
3706            }
3707    
3708            /**
3709             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3710             *
3711             * <p>
3712             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3713             * </p>
3714             *
3715             * @param companyId the company ID
3716             * @param displayDate the display date
3717             * @param start the lower bound of the range of blogs entries
3718             * @param end the upper bound of the range of blogs entries (not inclusive)
3719             * @return the range of matching blogs entries
3720             * @throws SystemException if a system exception occurred
3721             */
3722            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3723                    int start, int end) throws SystemException {
3724                    return findByC_LtD(companyId, displayDate, start, end, null);
3725            }
3726    
3727            /**
3728             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3729             *
3730             * <p>
3731             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3732             * </p>
3733             *
3734             * @param companyId the company ID
3735             * @param displayDate the display date
3736             * @param start the lower bound of the range of blogs entries
3737             * @param end the upper bound of the range of blogs entries (not inclusive)
3738             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3739             * @return the ordered range of matching blogs entries
3740             * @throws SystemException if a system exception occurred
3741             */
3742            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3743                    int start, int end, OrderByComparator orderByComparator)
3744                    throws SystemException {
3745                    FinderPath finderPath = null;
3746                    Object[] finderArgs = null;
3747    
3748                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
3749                    finderArgs = new Object[] {
3750                                    companyId, displayDate,
3751                                    
3752                                    start, end, orderByComparator
3753                            };
3754    
3755                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3756                                    finderArgs, this);
3757    
3758                    if ((list != null) && !list.isEmpty()) {
3759                            for (BlogsEntry blogsEntry : list) {
3760                                    if ((companyId != blogsEntry.getCompanyId()) ||
3761                                                    !Validator.equals(displayDate,
3762                                                            blogsEntry.getDisplayDate())) {
3763                                            list = null;
3764    
3765                                            break;
3766                                    }
3767                            }
3768                    }
3769    
3770                    if (list == null) {
3771                            StringBundler query = null;
3772    
3773                            if (orderByComparator != null) {
3774                                    query = new StringBundler(4 +
3775                                                    (orderByComparator.getOrderByFields().length * 3));
3776                            }
3777                            else {
3778                                    query = new StringBundler(4);
3779                            }
3780    
3781                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3782    
3783                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3784    
3785                            if (displayDate == null) {
3786                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3787                            }
3788                            else {
3789                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3790                            }
3791    
3792                            if (orderByComparator != null) {
3793                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3794                                            orderByComparator);
3795                            }
3796    
3797                            else {
3798                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3799                            }
3800    
3801                            String sql = query.toString();
3802    
3803                            Session session = null;
3804    
3805                            try {
3806                                    session = openSession();
3807    
3808                                    Query q = session.createQuery(sql);
3809    
3810                                    QueryPos qPos = QueryPos.getInstance(q);
3811    
3812                                    qPos.add(companyId);
3813    
3814                                    if (displayDate != null) {
3815                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3816                                    }
3817    
3818                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
3819                                                    end);
3820                            }
3821                            catch (Exception e) {
3822                                    throw processException(e);
3823                            }
3824                            finally {
3825                                    if (list == null) {
3826                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3827                                    }
3828                                    else {
3829                                            cacheResult(list);
3830    
3831                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3832                                    }
3833    
3834                                    closeSession(session);
3835                            }
3836                    }
3837    
3838                    return list;
3839            }
3840    
3841            /**
3842             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3843             *
3844             * @param companyId the company ID
3845             * @param displayDate the display date
3846             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3847             * @return the first matching blogs entry
3848             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3849             * @throws SystemException if a system exception occurred
3850             */
3851            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
3852                    OrderByComparator orderByComparator)
3853                    throws NoSuchEntryException, SystemException {
3854                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
3855                                    orderByComparator);
3856    
3857                    if (blogsEntry != null) {
3858                            return blogsEntry;
3859                    }
3860    
3861                    StringBundler msg = new StringBundler(6);
3862    
3863                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3864    
3865                    msg.append("companyId=");
3866                    msg.append(companyId);
3867    
3868                    msg.append(", displayDate=");
3869                    msg.append(displayDate);
3870    
3871                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3872    
3873                    throw new NoSuchEntryException(msg.toString());
3874            }
3875    
3876            /**
3877             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3878             *
3879             * @param companyId the company ID
3880             * @param displayDate the display date
3881             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3882             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3883             * @throws SystemException if a system exception occurred
3884             */
3885            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
3886                    OrderByComparator orderByComparator) throws SystemException {
3887                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
3888                                    orderByComparator);
3889    
3890                    if (!list.isEmpty()) {
3891                            return list.get(0);
3892                    }
3893    
3894                    return null;
3895            }
3896    
3897            /**
3898             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3899             *
3900             * @param companyId the company ID
3901             * @param displayDate the display date
3902             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3903             * @return the last matching blogs entry
3904             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3905             * @throws SystemException if a system exception occurred
3906             */
3907            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
3908                    OrderByComparator orderByComparator)
3909                    throws NoSuchEntryException, SystemException {
3910                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
3911                                    orderByComparator);
3912    
3913                    if (blogsEntry != null) {
3914                            return blogsEntry;
3915                    }
3916    
3917                    StringBundler msg = new StringBundler(6);
3918    
3919                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3920    
3921                    msg.append("companyId=");
3922                    msg.append(companyId);
3923    
3924                    msg.append(", displayDate=");
3925                    msg.append(displayDate);
3926    
3927                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3928    
3929                    throw new NoSuchEntryException(msg.toString());
3930            }
3931    
3932            /**
3933             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3934             *
3935             * @param companyId the company ID
3936             * @param displayDate the display date
3937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3938             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3939             * @throws SystemException if a system exception occurred
3940             */
3941            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
3942                    OrderByComparator orderByComparator) throws SystemException {
3943                    int count = countByC_LtD(companyId, displayDate);
3944    
3945                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
3946                                    count, orderByComparator);
3947    
3948                    if (!list.isEmpty()) {
3949                            return list.get(0);
3950                    }
3951    
3952                    return null;
3953            }
3954    
3955            /**
3956             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3957             *
3958             * @param entryId the primary key of the current blogs entry
3959             * @param companyId the company ID
3960             * @param displayDate the display date
3961             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3962             * @return the previous, current, and next blogs entry
3963             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3964             * @throws SystemException if a system exception occurred
3965             */
3966            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
3967                    Date displayDate, OrderByComparator orderByComparator)
3968                    throws NoSuchEntryException, SystemException {
3969                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3970    
3971                    Session session = null;
3972    
3973                    try {
3974                            session = openSession();
3975    
3976                            BlogsEntry[] array = new BlogsEntryImpl[3];
3977    
3978                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3979                                            displayDate, orderByComparator, true);
3980    
3981                            array[1] = blogsEntry;
3982    
3983                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3984                                            displayDate, orderByComparator, false);
3985    
3986                            return array;
3987                    }
3988                    catch (Exception e) {
3989                            throw processException(e);
3990                    }
3991                    finally {
3992                            closeSession(session);
3993                    }
3994            }
3995    
3996            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
3997                    BlogsEntry blogsEntry, long companyId, Date displayDate,
3998                    OrderByComparator orderByComparator, boolean previous) {
3999                    StringBundler query = null;
4000    
4001                    if (orderByComparator != null) {
4002                            query = new StringBundler(6 +
4003                                            (orderByComparator.getOrderByFields().length * 6));
4004                    }
4005                    else {
4006                            query = new StringBundler(3);
4007                    }
4008    
4009                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4010    
4011                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
4012    
4013                    if (displayDate == null) {
4014                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
4015                    }
4016                    else {
4017                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
4018                    }
4019    
4020                    if (orderByComparator != null) {
4021                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4022    
4023                            if (orderByConditionFields.length > 0) {
4024                                    query.append(WHERE_AND);
4025                            }
4026    
4027                            for (int i = 0; i < orderByConditionFields.length; i++) {
4028                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4029                                    query.append(orderByConditionFields[i]);
4030    
4031                                    if ((i + 1) < orderByConditionFields.length) {
4032                                            if (orderByComparator.isAscending() ^ previous) {
4033                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4034                                            }
4035                                            else {
4036                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4037                                            }
4038                                    }
4039                                    else {
4040                                            if (orderByComparator.isAscending() ^ previous) {
4041                                                    query.append(WHERE_GREATER_THAN);
4042                                            }
4043                                            else {
4044                                                    query.append(WHERE_LESSER_THAN);
4045                                            }
4046                                    }
4047                            }
4048    
4049                            query.append(ORDER_BY_CLAUSE);
4050    
4051                            String[] orderByFields = orderByComparator.getOrderByFields();
4052    
4053                            for (int i = 0; i < orderByFields.length; i++) {
4054                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4055                                    query.append(orderByFields[i]);
4056    
4057                                    if ((i + 1) < orderByFields.length) {
4058                                            if (orderByComparator.isAscending() ^ previous) {
4059                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4060                                            }
4061                                            else {
4062                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4063                                            }
4064                                    }
4065                                    else {
4066                                            if (orderByComparator.isAscending() ^ previous) {
4067                                                    query.append(ORDER_BY_ASC);
4068                                            }
4069                                            else {
4070                                                    query.append(ORDER_BY_DESC);
4071                                            }
4072                                    }
4073                            }
4074                    }
4075    
4076                    else {
4077                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4078                    }
4079    
4080                    String sql = query.toString();
4081    
4082                    Query q = session.createQuery(sql);
4083    
4084                    q.setFirstResult(0);
4085                    q.setMaxResults(2);
4086    
4087                    QueryPos qPos = QueryPos.getInstance(q);
4088    
4089                    qPos.add(companyId);
4090    
4091                    if (displayDate != null) {
4092                            qPos.add(CalendarUtil.getTimestamp(displayDate));
4093                    }
4094    
4095                    if (orderByComparator != null) {
4096                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4097    
4098                            for (Object value : values) {
4099                                    qPos.add(value);
4100                            }
4101                    }
4102    
4103                    List<BlogsEntry> list = q.list();
4104    
4105                    if (list.size() == 2) {
4106                            return list.get(1);
4107                    }
4108                    else {
4109                            return null;
4110                    }
4111            }
4112    
4113            /**
4114             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
4115             *
4116             * @param companyId the company ID
4117             * @param status the status
4118             * @return the matching blogs entries
4119             * @throws SystemException if a system exception occurred
4120             */
4121            public List<BlogsEntry> findByC_NeS(long companyId, int status)
4122                    throws SystemException {
4123                    return findByC_NeS(companyId, status, QueryUtil.ALL_POS,
4124                            QueryUtil.ALL_POS, null);
4125            }
4126    
4127            /**
4128             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
4129             *
4130             * <p>
4131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4132             * </p>
4133             *
4134             * @param companyId the company ID
4135             * @param status the status
4136             * @param start the lower bound of the range of blogs entries
4137             * @param end the upper bound of the range of blogs entries (not inclusive)
4138             * @return the range of matching blogs entries
4139             * @throws SystemException if a system exception occurred
4140             */
4141            public List<BlogsEntry> findByC_NeS(long companyId, int status, int start,
4142                    int end) throws SystemException {
4143                    return findByC_NeS(companyId, status, start, end, null);
4144            }
4145    
4146            /**
4147             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
4148             *
4149             * <p>
4150             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4151             * </p>
4152             *
4153             * @param companyId the company ID
4154             * @param status the status
4155             * @param start the lower bound of the range of blogs entries
4156             * @param end the upper bound of the range of blogs entries (not inclusive)
4157             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4158             * @return the ordered range of matching blogs entries
4159             * @throws SystemException if a system exception occurred
4160             */
4161            public List<BlogsEntry> findByC_NeS(long companyId, int status, int start,
4162                    int end, OrderByComparator orderByComparator) throws SystemException {
4163                    FinderPath finderPath = null;
4164                    Object[] finderArgs = null;
4165    
4166                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NES;
4167                    finderArgs = new Object[] {
4168                                    companyId, status,
4169                                    
4170                                    start, end, orderByComparator
4171                            };
4172    
4173                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4174                                    finderArgs, this);
4175    
4176                    if ((list != null) && !list.isEmpty()) {
4177                            for (BlogsEntry blogsEntry : list) {
4178                                    if ((companyId != blogsEntry.getCompanyId()) ||
4179                                                    (status != blogsEntry.getStatus())) {
4180                                            list = null;
4181    
4182                                            break;
4183                                    }
4184                            }
4185                    }
4186    
4187                    if (list == null) {
4188                            StringBundler query = null;
4189    
4190                            if (orderByComparator != null) {
4191                                    query = new StringBundler(4 +
4192                                                    (orderByComparator.getOrderByFields().length * 3));
4193                            }
4194                            else {
4195                                    query = new StringBundler(4);
4196                            }
4197    
4198                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4199    
4200                            query.append(_FINDER_COLUMN_C_NES_COMPANYID_2);
4201    
4202                            query.append(_FINDER_COLUMN_C_NES_STATUS_2);
4203    
4204                            if (orderByComparator != null) {
4205                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4206                                            orderByComparator);
4207                            }
4208    
4209                            else {
4210                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4211                            }
4212    
4213                            String sql = query.toString();
4214    
4215                            Session session = null;
4216    
4217                            try {
4218                                    session = openSession();
4219    
4220                                    Query q = session.createQuery(sql);
4221    
4222                                    QueryPos qPos = QueryPos.getInstance(q);
4223    
4224                                    qPos.add(companyId);
4225    
4226                                    qPos.add(status);
4227    
4228                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
4229                                                    end);
4230                            }
4231                            catch (Exception e) {
4232                                    throw processException(e);
4233                            }
4234                            finally {
4235                                    if (list == null) {
4236                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4237                                    }
4238                                    else {
4239                                            cacheResult(list);
4240    
4241                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4242                                    }
4243    
4244                                    closeSession(session);
4245                            }
4246                    }
4247    
4248                    return list;
4249            }
4250    
4251            /**
4252             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4253             *
4254             * @param companyId the company ID
4255             * @param status the status
4256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4257             * @return the first matching blogs entry
4258             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4259             * @throws SystemException if a system exception occurred
4260             */
4261            public BlogsEntry findByC_NeS_First(long companyId, int status,
4262                    OrderByComparator orderByComparator)
4263                    throws NoSuchEntryException, SystemException {
4264                    BlogsEntry blogsEntry = fetchByC_NeS_First(companyId, status,
4265                                    orderByComparator);
4266    
4267                    if (blogsEntry != null) {
4268                            return blogsEntry;
4269                    }
4270    
4271                    StringBundler msg = new StringBundler(6);
4272    
4273                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4274    
4275                    msg.append("companyId=");
4276                    msg.append(companyId);
4277    
4278                    msg.append(", status=");
4279                    msg.append(status);
4280    
4281                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4282    
4283                    throw new NoSuchEntryException(msg.toString());
4284            }
4285    
4286            /**
4287             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4288             *
4289             * @param companyId the company ID
4290             * @param status the status
4291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4292             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4293             * @throws SystemException if a system exception occurred
4294             */
4295            public BlogsEntry fetchByC_NeS_First(long companyId, int status,
4296                    OrderByComparator orderByComparator) throws SystemException {
4297                    List<BlogsEntry> list = findByC_NeS(companyId, status, 0, 1,
4298                                    orderByComparator);
4299    
4300                    if (!list.isEmpty()) {
4301                            return list.get(0);
4302                    }
4303    
4304                    return null;
4305            }
4306    
4307            /**
4308             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4309             *
4310             * @param companyId the company ID
4311             * @param status the status
4312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4313             * @return the last matching blogs entry
4314             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4315             * @throws SystemException if a system exception occurred
4316             */
4317            public BlogsEntry findByC_NeS_Last(long companyId, int status,
4318                    OrderByComparator orderByComparator)
4319                    throws NoSuchEntryException, SystemException {
4320                    BlogsEntry blogsEntry = fetchByC_NeS_Last(companyId, status,
4321                                    orderByComparator);
4322    
4323                    if (blogsEntry != null) {
4324                            return blogsEntry;
4325                    }
4326    
4327                    StringBundler msg = new StringBundler(6);
4328    
4329                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4330    
4331                    msg.append("companyId=");
4332                    msg.append(companyId);
4333    
4334                    msg.append(", status=");
4335                    msg.append(status);
4336    
4337                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4338    
4339                    throw new NoSuchEntryException(msg.toString());
4340            }
4341    
4342            /**
4343             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4344             *
4345             * @param companyId the company ID
4346             * @param status the status
4347             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4348             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4349             * @throws SystemException if a system exception occurred
4350             */
4351            public BlogsEntry fetchByC_NeS_Last(long companyId, int status,
4352                    OrderByComparator orderByComparator) throws SystemException {
4353                    int count = countByC_NeS(companyId, status);
4354    
4355                    List<BlogsEntry> list = findByC_NeS(companyId, status, count - 1,
4356                                    count, orderByComparator);
4357    
4358                    if (!list.isEmpty()) {
4359                            return list.get(0);
4360                    }
4361    
4362                    return null;
4363            }
4364    
4365            /**
4366             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4367             *
4368             * @param entryId the primary key of the current blogs entry
4369             * @param companyId the company ID
4370             * @param status the status
4371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4372             * @return the previous, current, and next blogs entry
4373             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4374             * @throws SystemException if a system exception occurred
4375             */
4376            public BlogsEntry[] findByC_NeS_PrevAndNext(long entryId, long companyId,
4377                    int status, OrderByComparator orderByComparator)
4378                    throws NoSuchEntryException, SystemException {
4379                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4380    
4381                    Session session = null;
4382    
4383                    try {
4384                            session = openSession();
4385    
4386                            BlogsEntry[] array = new BlogsEntryImpl[3];
4387    
4388                            array[0] = getByC_NeS_PrevAndNext(session, blogsEntry, companyId,
4389                                            status, orderByComparator, true);
4390    
4391                            array[1] = blogsEntry;
4392    
4393                            array[2] = getByC_NeS_PrevAndNext(session, blogsEntry, companyId,
4394                                            status, orderByComparator, false);
4395    
4396                            return array;
4397                    }
4398                    catch (Exception e) {
4399                            throw processException(e);
4400                    }
4401                    finally {
4402                            closeSession(session);
4403                    }
4404            }
4405    
4406            protected BlogsEntry getByC_NeS_PrevAndNext(Session session,
4407                    BlogsEntry blogsEntry, long companyId, int status,
4408                    OrderByComparator orderByComparator, boolean previous) {
4409                    StringBundler query = null;
4410    
4411                    if (orderByComparator != null) {
4412                            query = new StringBundler(6 +
4413                                            (orderByComparator.getOrderByFields().length * 6));
4414                    }
4415                    else {
4416                            query = new StringBundler(3);
4417                    }
4418    
4419                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4420    
4421                    query.append(_FINDER_COLUMN_C_NES_COMPANYID_2);
4422    
4423                    query.append(_FINDER_COLUMN_C_NES_STATUS_2);
4424    
4425                    if (orderByComparator != null) {
4426                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4427    
4428                            if (orderByConditionFields.length > 0) {
4429                                    query.append(WHERE_AND);
4430                            }
4431    
4432                            for (int i = 0; i < orderByConditionFields.length; i++) {
4433                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4434                                    query.append(orderByConditionFields[i]);
4435    
4436                                    if ((i + 1) < orderByConditionFields.length) {
4437                                            if (orderByComparator.isAscending() ^ previous) {
4438                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4439                                            }
4440                                            else {
4441                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4442                                            }
4443                                    }
4444                                    else {
4445                                            if (orderByComparator.isAscending() ^ previous) {
4446                                                    query.append(WHERE_GREATER_THAN);
4447                                            }
4448                                            else {
4449                                                    query.append(WHERE_LESSER_THAN);
4450                                            }
4451                                    }
4452                            }
4453    
4454                            query.append(ORDER_BY_CLAUSE);
4455    
4456                            String[] orderByFields = orderByComparator.getOrderByFields();
4457    
4458                            for (int i = 0; i < orderByFields.length; i++) {
4459                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4460                                    query.append(orderByFields[i]);
4461    
4462                                    if ((i + 1) < orderByFields.length) {
4463                                            if (orderByComparator.isAscending() ^ previous) {
4464                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4465                                            }
4466                                            else {
4467                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4468                                            }
4469                                    }
4470                                    else {
4471                                            if (orderByComparator.isAscending() ^ previous) {
4472                                                    query.append(ORDER_BY_ASC);
4473                                            }
4474                                            else {
4475                                                    query.append(ORDER_BY_DESC);
4476                                            }
4477                                    }
4478                            }
4479                    }
4480    
4481                    else {
4482                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4483                    }
4484    
4485                    String sql = query.toString();
4486    
4487                    Query q = session.createQuery(sql);
4488    
4489                    q.setFirstResult(0);
4490                    q.setMaxResults(2);
4491    
4492                    QueryPos qPos = QueryPos.getInstance(q);
4493    
4494                    qPos.add(companyId);
4495    
4496                    qPos.add(status);
4497    
4498                    if (orderByComparator != null) {
4499                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4500    
4501                            for (Object value : values) {
4502                                    qPos.add(value);
4503                            }
4504                    }
4505    
4506                    List<BlogsEntry> list = q.list();
4507    
4508                    if (list.size() == 2) {
4509                            return list.get(1);
4510                    }
4511                    else {
4512                            return null;
4513                    }
4514            }
4515    
4516            /**
4517             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
4518             *
4519             * @param companyId the company ID
4520             * @param status the status
4521             * @return the matching blogs entries
4522             * @throws SystemException if a system exception occurred
4523             */
4524            public List<BlogsEntry> findByC_S(long companyId, int status)
4525                    throws SystemException {
4526                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
4527                            QueryUtil.ALL_POS, null);
4528            }
4529    
4530            /**
4531             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
4532             *
4533             * <p>
4534             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4535             * </p>
4536             *
4537             * @param companyId the company ID
4538             * @param status the status
4539             * @param start the lower bound of the range of blogs entries
4540             * @param end the upper bound of the range of blogs entries (not inclusive)
4541             * @return the range of matching blogs entries
4542             * @throws SystemException if a system exception occurred
4543             */
4544            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4545                    int end) throws SystemException {
4546                    return findByC_S(companyId, status, start, end, null);
4547            }
4548    
4549            /**
4550             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
4551             *
4552             * <p>
4553             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4554             * </p>
4555             *
4556             * @param companyId the company ID
4557             * @param status the status
4558             * @param start the lower bound of the range of blogs entries
4559             * @param end the upper bound of the range of blogs entries (not inclusive)
4560             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4561             * @return the ordered range of matching blogs entries
4562             * @throws SystemException if a system exception occurred
4563             */
4564            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4565                    int end, OrderByComparator orderByComparator) throws SystemException {
4566                    FinderPath finderPath = null;
4567                    Object[] finderArgs = null;
4568    
4569                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4570                                    (orderByComparator == null)) {
4571                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
4572                            finderArgs = new Object[] { companyId, status };
4573                    }
4574                    else {
4575                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
4576                            finderArgs = new Object[] {
4577                                            companyId, status,
4578                                            
4579                                            start, end, orderByComparator
4580                                    };
4581                    }
4582    
4583                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4584                                    finderArgs, this);
4585    
4586                    if ((list != null) && !list.isEmpty()) {
4587                            for (BlogsEntry blogsEntry : list) {
4588                                    if ((companyId != blogsEntry.getCompanyId()) ||
4589                                                    (status != blogsEntry.getStatus())) {
4590                                            list = null;
4591    
4592                                            break;
4593                                    }
4594                            }
4595                    }
4596    
4597                    if (list == null) {
4598                            StringBundler query = null;
4599    
4600                            if (orderByComparator != null) {
4601                                    query = new StringBundler(4 +
4602                                                    (orderByComparator.getOrderByFields().length * 3));
4603                            }
4604                            else {
4605                                    query = new StringBundler(4);
4606                            }
4607    
4608                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4609    
4610                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4611    
4612                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
4613    
4614                            if (orderByComparator != null) {
4615                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4616                                            orderByComparator);
4617                            }
4618    
4619                            else {
4620                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4621                            }
4622    
4623                            String sql = query.toString();
4624    
4625                            Session session = null;
4626    
4627                            try {
4628                                    session = openSession();
4629    
4630                                    Query q = session.createQuery(sql);
4631    
4632                                    QueryPos qPos = QueryPos.getInstance(q);
4633    
4634                                    qPos.add(companyId);
4635    
4636                                    qPos.add(status);
4637    
4638                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
4639                                                    end);
4640                            }
4641                            catch (Exception e) {
4642                                    throw processException(e);
4643                            }
4644                            finally {
4645                                    if (list == null) {
4646                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4647                                    }
4648                                    else {
4649                                            cacheResult(list);
4650    
4651                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4652                                    }
4653    
4654                                    closeSession(session);
4655                            }
4656                    }
4657    
4658                    return list;
4659            }
4660    
4661            /**
4662             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4663             *
4664             * @param companyId the company ID
4665             * @param status the status
4666             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4667             * @return the first matching blogs entry
4668             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4669             * @throws SystemException if a system exception occurred
4670             */
4671            public BlogsEntry findByC_S_First(long companyId, int status,
4672                    OrderByComparator orderByComparator)
4673                    throws NoSuchEntryException, SystemException {
4674                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
4675                                    orderByComparator);
4676    
4677                    if (blogsEntry != null) {
4678                            return blogsEntry;
4679                    }
4680    
4681                    StringBundler msg = new StringBundler(6);
4682    
4683                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4684    
4685                    msg.append("companyId=");
4686                    msg.append(companyId);
4687    
4688                    msg.append(", status=");
4689                    msg.append(status);
4690    
4691                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4692    
4693                    throw new NoSuchEntryException(msg.toString());
4694            }
4695    
4696            /**
4697             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4698             *
4699             * @param companyId the company ID
4700             * @param status the status
4701             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4702             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4703             * @throws SystemException if a system exception occurred
4704             */
4705            public BlogsEntry fetchByC_S_First(long companyId, int status,
4706                    OrderByComparator orderByComparator) throws SystemException {
4707                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
4708                                    orderByComparator);
4709    
4710                    if (!list.isEmpty()) {
4711                            return list.get(0);
4712                    }
4713    
4714                    return null;
4715            }
4716    
4717            /**
4718             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4719             *
4720             * @param companyId the company ID
4721             * @param status the status
4722             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4723             * @return the last matching blogs entry
4724             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4725             * @throws SystemException if a system exception occurred
4726             */
4727            public BlogsEntry findByC_S_Last(long companyId, int status,
4728                    OrderByComparator orderByComparator)
4729                    throws NoSuchEntryException, SystemException {
4730                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
4731                                    orderByComparator);
4732    
4733                    if (blogsEntry != null) {
4734                            return blogsEntry;
4735                    }
4736    
4737                    StringBundler msg = new StringBundler(6);
4738    
4739                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4740    
4741                    msg.append("companyId=");
4742                    msg.append(companyId);
4743    
4744                    msg.append(", status=");
4745                    msg.append(status);
4746    
4747                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4748    
4749                    throw new NoSuchEntryException(msg.toString());
4750            }
4751    
4752            /**
4753             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4754             *
4755             * @param companyId the company ID
4756             * @param status the status
4757             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4758             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4759             * @throws SystemException if a system exception occurred
4760             */
4761            public BlogsEntry fetchByC_S_Last(long companyId, int status,
4762                    OrderByComparator orderByComparator) throws SystemException {
4763                    int count = countByC_S(companyId, status);
4764    
4765                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
4766                                    orderByComparator);
4767    
4768                    if (!list.isEmpty()) {
4769                            return list.get(0);
4770                    }
4771    
4772                    return null;
4773            }
4774    
4775            /**
4776             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4777             *
4778             * @param entryId the primary key of the current blogs entry
4779             * @param companyId the company ID
4780             * @param status the status
4781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4782             * @return the previous, current, and next blogs entry
4783             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4784             * @throws SystemException if a system exception occurred
4785             */
4786            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
4787                    int status, OrderByComparator orderByComparator)
4788                    throws NoSuchEntryException, SystemException {
4789                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4790    
4791                    Session session = null;
4792    
4793                    try {
4794                            session = openSession();
4795    
4796                            BlogsEntry[] array = new BlogsEntryImpl[3];
4797    
4798                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4799                                            status, orderByComparator, true);
4800    
4801                            array[1] = blogsEntry;
4802    
4803                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4804                                            status, orderByComparator, false);
4805    
4806                            return array;
4807                    }
4808                    catch (Exception e) {
4809                            throw processException(e);
4810                    }
4811                    finally {
4812                            closeSession(session);
4813                    }
4814            }
4815    
4816            protected BlogsEntry getByC_S_PrevAndNext(Session session,
4817                    BlogsEntry blogsEntry, long companyId, int status,
4818                    OrderByComparator orderByComparator, boolean previous) {
4819                    StringBundler query = null;
4820    
4821                    if (orderByComparator != null) {
4822                            query = new StringBundler(6 +
4823                                            (orderByComparator.getOrderByFields().length * 6));
4824                    }
4825                    else {
4826                            query = new StringBundler(3);
4827                    }
4828    
4829                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4830    
4831                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4832    
4833                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
4834    
4835                    if (orderByComparator != null) {
4836                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4837    
4838                            if (orderByConditionFields.length > 0) {
4839                                    query.append(WHERE_AND);
4840                            }
4841    
4842                            for (int i = 0; i < orderByConditionFields.length; i++) {
4843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4844                                    query.append(orderByConditionFields[i]);
4845    
4846                                    if ((i + 1) < orderByConditionFields.length) {
4847                                            if (orderByComparator.isAscending() ^ previous) {
4848                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4849                                            }
4850                                            else {
4851                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4852                                            }
4853                                    }
4854                                    else {
4855                                            if (orderByComparator.isAscending() ^ previous) {
4856                                                    query.append(WHERE_GREATER_THAN);
4857                                            }
4858                                            else {
4859                                                    query.append(WHERE_LESSER_THAN);
4860                                            }
4861                                    }
4862                            }
4863    
4864                            query.append(ORDER_BY_CLAUSE);
4865    
4866                            String[] orderByFields = orderByComparator.getOrderByFields();
4867    
4868                            for (int i = 0; i < orderByFields.length; i++) {
4869                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4870                                    query.append(orderByFields[i]);
4871    
4872                                    if ((i + 1) < orderByFields.length) {
4873                                            if (orderByComparator.isAscending() ^ previous) {
4874                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4875                                            }
4876                                            else {
4877                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4878                                            }
4879                                    }
4880                                    else {
4881                                            if (orderByComparator.isAscending() ^ previous) {
4882                                                    query.append(ORDER_BY_ASC);
4883                                            }
4884                                            else {
4885                                                    query.append(ORDER_BY_DESC);
4886                                            }
4887                                    }
4888                            }
4889                    }
4890    
4891                    else {
4892                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4893                    }
4894    
4895                    String sql = query.toString();
4896    
4897                    Query q = session.createQuery(sql);
4898    
4899                    q.setFirstResult(0);
4900                    q.setMaxResults(2);
4901    
4902                    QueryPos qPos = QueryPos.getInstance(q);
4903    
4904                    qPos.add(companyId);
4905    
4906                    qPos.add(status);
4907    
4908                    if (orderByComparator != null) {
4909                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4910    
4911                            for (Object value : values) {
4912                                    qPos.add(value);
4913                            }
4914                    }
4915    
4916                    List<BlogsEntry> list = q.list();
4917    
4918                    if (list.size() == 2) {
4919                            return list.get(1);
4920                    }
4921                    else {
4922                            return null;
4923                    }
4924            }
4925    
4926            /**
4927             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
4928             *
4929             * @param groupId the group ID
4930             * @param urlTitle the url title
4931             * @return the matching blogs entry
4932             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4933             * @throws SystemException if a system exception occurred
4934             */
4935            public BlogsEntry findByG_UT(long groupId, String urlTitle)
4936                    throws NoSuchEntryException, SystemException {
4937                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
4938    
4939                    if (blogsEntry == null) {
4940                            StringBundler msg = new StringBundler(6);
4941    
4942                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4943    
4944                            msg.append("groupId=");
4945                            msg.append(groupId);
4946    
4947                            msg.append(", urlTitle=");
4948                            msg.append(urlTitle);
4949    
4950                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4951    
4952                            if (_log.isWarnEnabled()) {
4953                                    _log.warn(msg.toString());
4954                            }
4955    
4956                            throw new NoSuchEntryException(msg.toString());
4957                    }
4958    
4959                    return blogsEntry;
4960            }
4961    
4962            /**
4963             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
4964             *
4965             * @param groupId the group ID
4966             * @param urlTitle the url title
4967             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4968             * @throws SystemException if a system exception occurred
4969             */
4970            public BlogsEntry fetchByG_UT(long groupId, String urlTitle)
4971                    throws SystemException {
4972                    return fetchByG_UT(groupId, urlTitle, true);
4973            }
4974    
4975            /**
4976             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
4977             *
4978             * @param groupId the group ID
4979             * @param urlTitle the url title
4980             * @param retrieveFromCache whether to use the finder cache
4981             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4982             * @throws SystemException if a system exception occurred
4983             */
4984            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
4985                    boolean retrieveFromCache) throws SystemException {
4986                    Object[] finderArgs = new Object[] { groupId, urlTitle };
4987    
4988                    Object result = null;
4989    
4990                    if (retrieveFromCache) {
4991                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_UT,
4992                                            finderArgs, this);
4993                    }
4994    
4995                    if (result instanceof BlogsEntry) {
4996                            BlogsEntry blogsEntry = (BlogsEntry)result;
4997    
4998                            if ((groupId != blogsEntry.getGroupId()) ||
4999                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
5000                                    result = null;
5001                            }
5002                    }
5003    
5004                    if (result == null) {
5005                            StringBundler query = new StringBundler(4);
5006    
5007                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5008    
5009                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5010    
5011                            if (urlTitle == null) {
5012                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5013                            }
5014                            else {
5015                                    if (urlTitle.equals(StringPool.BLANK)) {
5016                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5017                                    }
5018                                    else {
5019                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5020                                    }
5021                            }
5022    
5023                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5024    
5025                            String sql = query.toString();
5026    
5027                            Session session = null;
5028    
5029                            try {
5030                                    session = openSession();
5031    
5032                                    Query q = session.createQuery(sql);
5033    
5034                                    QueryPos qPos = QueryPos.getInstance(q);
5035    
5036                                    qPos.add(groupId);
5037    
5038                                    if (urlTitle != null) {
5039                                            qPos.add(urlTitle);
5040                                    }
5041    
5042                                    List<BlogsEntry> list = q.list();
5043    
5044                                    result = list;
5045    
5046                                    BlogsEntry blogsEntry = null;
5047    
5048                                    if (list.isEmpty()) {
5049                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
5050                                                    finderArgs, list);
5051                                    }
5052                                    else {
5053                                            blogsEntry = list.get(0);
5054    
5055                                            cacheResult(blogsEntry);
5056    
5057                                            if ((blogsEntry.getGroupId() != groupId) ||
5058                                                            (blogsEntry.getUrlTitle() == null) ||
5059                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
5060                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
5061                                                            finderArgs, blogsEntry);
5062                                            }
5063                                    }
5064    
5065                                    return blogsEntry;
5066                            }
5067                            catch (Exception e) {
5068                                    throw processException(e);
5069                            }
5070                            finally {
5071                                    if (result == null) {
5072                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
5073                                                    finderArgs);
5074                                    }
5075    
5076                                    closeSession(session);
5077                            }
5078                    }
5079                    else {
5080                            if (result instanceof List<?>) {
5081                                    return null;
5082                            }
5083                            else {
5084                                    return (BlogsEntry)result;
5085                            }
5086                    }
5087            }
5088    
5089            /**
5090             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5091             *
5092             * @param groupId the group ID
5093             * @param displayDate the display date
5094             * @return the matching blogs entries
5095             * @throws SystemException if a system exception occurred
5096             */
5097            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate)
5098                    throws SystemException {
5099                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5100                            QueryUtil.ALL_POS, null);
5101            }
5102    
5103            /**
5104             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5105             *
5106             * <p>
5107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5108             * </p>
5109             *
5110             * @param groupId the group ID
5111             * @param displayDate the display date
5112             * @param start the lower bound of the range of blogs entries
5113             * @param end the upper bound of the range of blogs entries (not inclusive)
5114             * @return the range of matching blogs entries
5115             * @throws SystemException if a system exception occurred
5116             */
5117            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5118                    int start, int end) throws SystemException {
5119                    return findByG_LtD(groupId, displayDate, start, end, null);
5120            }
5121    
5122            /**
5123             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5124             *
5125             * <p>
5126             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5127             * </p>
5128             *
5129             * @param groupId the group ID
5130             * @param displayDate the display date
5131             * @param start the lower bound of the range of blogs entries
5132             * @param end the upper bound of the range of blogs entries (not inclusive)
5133             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5134             * @return the ordered range of matching blogs entries
5135             * @throws SystemException if a system exception occurred
5136             */
5137            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5138                    int start, int end, OrderByComparator orderByComparator)
5139                    throws SystemException {
5140                    FinderPath finderPath = null;
5141                    Object[] finderArgs = null;
5142    
5143                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
5144                    finderArgs = new Object[] {
5145                                    groupId, displayDate,
5146                                    
5147                                    start, end, orderByComparator
5148                            };
5149    
5150                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5151                                    finderArgs, this);
5152    
5153                    if ((list != null) && !list.isEmpty()) {
5154                            for (BlogsEntry blogsEntry : list) {
5155                                    if ((groupId != blogsEntry.getGroupId()) ||
5156                                                    !Validator.equals(displayDate,
5157                                                            blogsEntry.getDisplayDate())) {
5158                                            list = null;
5159    
5160                                            break;
5161                                    }
5162                            }
5163                    }
5164    
5165                    if (list == null) {
5166                            StringBundler query = null;
5167    
5168                            if (orderByComparator != null) {
5169                                    query = new StringBundler(4 +
5170                                                    (orderByComparator.getOrderByFields().length * 3));
5171                            }
5172                            else {
5173                                    query = new StringBundler(4);
5174                            }
5175    
5176                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5177    
5178                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5179    
5180                            if (displayDate == null) {
5181                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5182                            }
5183                            else {
5184                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5185                            }
5186    
5187                            if (orderByComparator != null) {
5188                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5189                                            orderByComparator);
5190                            }
5191    
5192                            else {
5193                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5194                            }
5195    
5196                            String sql = query.toString();
5197    
5198                            Session session = null;
5199    
5200                            try {
5201                                    session = openSession();
5202    
5203                                    Query q = session.createQuery(sql);
5204    
5205                                    QueryPos qPos = QueryPos.getInstance(q);
5206    
5207                                    qPos.add(groupId);
5208    
5209                                    if (displayDate != null) {
5210                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5211                                    }
5212    
5213                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
5214                                                    end);
5215                            }
5216                            catch (Exception e) {
5217                                    throw processException(e);
5218                            }
5219                            finally {
5220                                    if (list == null) {
5221                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5222                                    }
5223                                    else {
5224                                            cacheResult(list);
5225    
5226                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5227                                    }
5228    
5229                                    closeSession(session);
5230                            }
5231                    }
5232    
5233                    return list;
5234            }
5235    
5236            /**
5237             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5238             *
5239             * @param groupId the group ID
5240             * @param displayDate the display date
5241             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5242             * @return the first matching blogs entry
5243             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5244             * @throws SystemException if a system exception occurred
5245             */
5246            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
5247                    OrderByComparator orderByComparator)
5248                    throws NoSuchEntryException, SystemException {
5249                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
5250                                    orderByComparator);
5251    
5252                    if (blogsEntry != null) {
5253                            return blogsEntry;
5254                    }
5255    
5256                    StringBundler msg = new StringBundler(6);
5257    
5258                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5259    
5260                    msg.append("groupId=");
5261                    msg.append(groupId);
5262    
5263                    msg.append(", displayDate=");
5264                    msg.append(displayDate);
5265    
5266                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5267    
5268                    throw new NoSuchEntryException(msg.toString());
5269            }
5270    
5271            /**
5272             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5273             *
5274             * @param groupId the group ID
5275             * @param displayDate the display date
5276             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5277             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5278             * @throws SystemException if a system exception occurred
5279             */
5280            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
5281                    OrderByComparator orderByComparator) throws SystemException {
5282                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
5283                                    orderByComparator);
5284    
5285                    if (!list.isEmpty()) {
5286                            return list.get(0);
5287                    }
5288    
5289                    return null;
5290            }
5291    
5292            /**
5293             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5294             *
5295             * @param groupId the group ID
5296             * @param displayDate the display date
5297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5298             * @return the last matching blogs entry
5299             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5300             * @throws SystemException if a system exception occurred
5301             */
5302            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
5303                    OrderByComparator orderByComparator)
5304                    throws NoSuchEntryException, SystemException {
5305                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
5306                                    orderByComparator);
5307    
5308                    if (blogsEntry != null) {
5309                            return blogsEntry;
5310                    }
5311    
5312                    StringBundler msg = new StringBundler(6);
5313    
5314                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5315    
5316                    msg.append("groupId=");
5317                    msg.append(groupId);
5318    
5319                    msg.append(", displayDate=");
5320                    msg.append(displayDate);
5321    
5322                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5323    
5324                    throw new NoSuchEntryException(msg.toString());
5325            }
5326    
5327            /**
5328             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5329             *
5330             * @param groupId the group ID
5331             * @param displayDate the display date
5332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5333             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5334             * @throws SystemException if a system exception occurred
5335             */
5336            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
5337                    OrderByComparator orderByComparator) throws SystemException {
5338                    int count = countByG_LtD(groupId, displayDate);
5339    
5340                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
5341                                    count, orderByComparator);
5342    
5343                    if (!list.isEmpty()) {
5344                            return list.get(0);
5345                    }
5346    
5347                    return null;
5348            }
5349    
5350            /**
5351             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5352             *
5353             * @param entryId the primary key of the current blogs entry
5354             * @param groupId the group ID
5355             * @param displayDate the display date
5356             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5357             * @return the previous, current, and next blogs entry
5358             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5359             * @throws SystemException if a system exception occurred
5360             */
5361            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
5362                    Date displayDate, OrderByComparator orderByComparator)
5363                    throws NoSuchEntryException, SystemException {
5364                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5365    
5366                    Session session = null;
5367    
5368                    try {
5369                            session = openSession();
5370    
5371                            BlogsEntry[] array = new BlogsEntryImpl[3];
5372    
5373                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5374                                            displayDate, orderByComparator, true);
5375    
5376                            array[1] = blogsEntry;
5377    
5378                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5379                                            displayDate, orderByComparator, false);
5380    
5381                            return array;
5382                    }
5383                    catch (Exception e) {
5384                            throw processException(e);
5385                    }
5386                    finally {
5387                            closeSession(session);
5388                    }
5389            }
5390    
5391            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
5392                    BlogsEntry blogsEntry, long groupId, Date displayDate,
5393                    OrderByComparator orderByComparator, boolean previous) {
5394                    StringBundler query = null;
5395    
5396                    if (orderByComparator != null) {
5397                            query = new StringBundler(6 +
5398                                            (orderByComparator.getOrderByFields().length * 6));
5399                    }
5400                    else {
5401                            query = new StringBundler(3);
5402                    }
5403    
5404                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5405    
5406                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5407    
5408                    if (displayDate == null) {
5409                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5410                    }
5411                    else {
5412                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5413                    }
5414    
5415                    if (orderByComparator != null) {
5416                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5417    
5418                            if (orderByConditionFields.length > 0) {
5419                                    query.append(WHERE_AND);
5420                            }
5421    
5422                            for (int i = 0; i < orderByConditionFields.length; i++) {
5423                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5424                                    query.append(orderByConditionFields[i]);
5425    
5426                                    if ((i + 1) < orderByConditionFields.length) {
5427                                            if (orderByComparator.isAscending() ^ previous) {
5428                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5429                                            }
5430                                            else {
5431                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5432                                            }
5433                                    }
5434                                    else {
5435                                            if (orderByComparator.isAscending() ^ previous) {
5436                                                    query.append(WHERE_GREATER_THAN);
5437                                            }
5438                                            else {
5439                                                    query.append(WHERE_LESSER_THAN);
5440                                            }
5441                                    }
5442                            }
5443    
5444                            query.append(ORDER_BY_CLAUSE);
5445    
5446                            String[] orderByFields = orderByComparator.getOrderByFields();
5447    
5448                            for (int i = 0; i < orderByFields.length; i++) {
5449                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5450                                    query.append(orderByFields[i]);
5451    
5452                                    if ((i + 1) < orderByFields.length) {
5453                                            if (orderByComparator.isAscending() ^ previous) {
5454                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5455                                            }
5456                                            else {
5457                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5458                                            }
5459                                    }
5460                                    else {
5461                                            if (orderByComparator.isAscending() ^ previous) {
5462                                                    query.append(ORDER_BY_ASC);
5463                                            }
5464                                            else {
5465                                                    query.append(ORDER_BY_DESC);
5466                                            }
5467                                    }
5468                            }
5469                    }
5470    
5471                    else {
5472                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5473                    }
5474    
5475                    String sql = query.toString();
5476    
5477                    Query q = session.createQuery(sql);
5478    
5479                    q.setFirstResult(0);
5480                    q.setMaxResults(2);
5481    
5482                    QueryPos qPos = QueryPos.getInstance(q);
5483    
5484                    qPos.add(groupId);
5485    
5486                    if (displayDate != null) {
5487                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5488                    }
5489    
5490                    if (orderByComparator != null) {
5491                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5492    
5493                            for (Object value : values) {
5494                                    qPos.add(value);
5495                            }
5496                    }
5497    
5498                    List<BlogsEntry> list = q.list();
5499    
5500                    if (list.size() == 2) {
5501                            return list.get(1);
5502                    }
5503                    else {
5504                            return null;
5505                    }
5506            }
5507    
5508            /**
5509             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5510             *
5511             * @param groupId the group ID
5512             * @param displayDate the display date
5513             * @return the matching blogs entries that the user has permission to view
5514             * @throws SystemException if a system exception occurred
5515             */
5516            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate)
5517                    throws SystemException {
5518                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5519                            QueryUtil.ALL_POS, null);
5520            }
5521    
5522            /**
5523             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5524             *
5525             * <p>
5526             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5527             * </p>
5528             *
5529             * @param groupId the group ID
5530             * @param displayDate the display date
5531             * @param start the lower bound of the range of blogs entries
5532             * @param end the upper bound of the range of blogs entries (not inclusive)
5533             * @return the range of matching blogs entries that the user has permission to view
5534             * @throws SystemException if a system exception occurred
5535             */
5536            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5537                    int start, int end) throws SystemException {
5538                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
5539            }
5540    
5541            /**
5542             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
5543             *
5544             * <p>
5545             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5546             * </p>
5547             *
5548             * @param groupId the group ID
5549             * @param displayDate the display date
5550             * @param start the lower bound of the range of blogs entries
5551             * @param end the upper bound of the range of blogs entries (not inclusive)
5552             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5553             * @return the ordered range of matching blogs entries that the user has permission to view
5554             * @throws SystemException if a system exception occurred
5555             */
5556            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5557                    int start, int end, OrderByComparator orderByComparator)
5558                    throws SystemException {
5559                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5560                            return findByG_LtD(groupId, displayDate, start, end,
5561                                    orderByComparator);
5562                    }
5563    
5564                    StringBundler query = null;
5565    
5566                    if (orderByComparator != null) {
5567                            query = new StringBundler(4 +
5568                                            (orderByComparator.getOrderByFields().length * 3));
5569                    }
5570                    else {
5571                            query = new StringBundler(4);
5572                    }
5573    
5574                    if (getDB().isSupportsInlineDistinct()) {
5575                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5576                    }
5577                    else {
5578                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5579                    }
5580    
5581                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5582    
5583                    if (displayDate == null) {
5584                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5585                    }
5586                    else {
5587                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5588                    }
5589    
5590                    if (!getDB().isSupportsInlineDistinct()) {
5591                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5592                    }
5593    
5594                    if (orderByComparator != null) {
5595                            if (getDB().isSupportsInlineDistinct()) {
5596                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5597                                            orderByComparator);
5598                            }
5599                            else {
5600                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5601                                            orderByComparator);
5602                            }
5603                    }
5604    
5605                    else {
5606                            if (getDB().isSupportsInlineDistinct()) {
5607                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5608                            }
5609                            else {
5610                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5611                            }
5612                    }
5613    
5614                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5615                                    BlogsEntry.class.getName(),
5616                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5617    
5618                    Session session = null;
5619    
5620                    try {
5621                            session = openSession();
5622    
5623                            SQLQuery q = session.createSQLQuery(sql);
5624    
5625                            if (getDB().isSupportsInlineDistinct()) {
5626                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5627                            }
5628                            else {
5629                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5630                            }
5631    
5632                            QueryPos qPos = QueryPos.getInstance(q);
5633    
5634                            qPos.add(groupId);
5635    
5636                            if (displayDate != null) {
5637                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
5638                            }
5639    
5640                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5641                    }
5642                    catch (Exception e) {
5643                            throw processException(e);
5644                    }
5645                    finally {
5646                            closeSession(session);
5647                    }
5648            }
5649    
5650            /**
5651             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5652             *
5653             * @param entryId the primary key of the current blogs entry
5654             * @param groupId the group ID
5655             * @param displayDate the display date
5656             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5657             * @return the previous, current, and next blogs entry
5658             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5659             * @throws SystemException if a system exception occurred
5660             */
5661            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
5662                    long groupId, Date displayDate, OrderByComparator orderByComparator)
5663                    throws NoSuchEntryException, SystemException {
5664                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5665                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
5666                                    orderByComparator);
5667                    }
5668    
5669                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5670    
5671                    Session session = null;
5672    
5673                    try {
5674                            session = openSession();
5675    
5676                            BlogsEntry[] array = new BlogsEntryImpl[3];
5677    
5678                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5679                                            groupId, displayDate, orderByComparator, true);
5680    
5681                            array[1] = blogsEntry;
5682    
5683                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5684                                            groupId, displayDate, orderByComparator, false);
5685    
5686                            return array;
5687                    }
5688                    catch (Exception e) {
5689                            throw processException(e);
5690                    }
5691                    finally {
5692                            closeSession(session);
5693                    }
5694            }
5695    
5696            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
5697                    BlogsEntry blogsEntry, long groupId, Date displayDate,
5698                    OrderByComparator orderByComparator, boolean previous) {
5699                    StringBundler query = null;
5700    
5701                    if (orderByComparator != null) {
5702                            query = new StringBundler(6 +
5703                                            (orderByComparator.getOrderByFields().length * 6));
5704                    }
5705                    else {
5706                            query = new StringBundler(3);
5707                    }
5708    
5709                    if (getDB().isSupportsInlineDistinct()) {
5710                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5711                    }
5712                    else {
5713                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5714                    }
5715    
5716                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5717    
5718                    if (displayDate == null) {
5719                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5720                    }
5721                    else {
5722                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5723                    }
5724    
5725                    if (!getDB().isSupportsInlineDistinct()) {
5726                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5727                    }
5728    
5729                    if (orderByComparator != null) {
5730                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5731    
5732                            if (orderByConditionFields.length > 0) {
5733                                    query.append(WHERE_AND);
5734                            }
5735    
5736                            for (int i = 0; i < orderByConditionFields.length; i++) {
5737                                    if (getDB().isSupportsInlineDistinct()) {
5738                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5739                                    }
5740                                    else {
5741                                            query.append(_ORDER_BY_ENTITY_TABLE);
5742                                    }
5743    
5744                                    query.append(orderByConditionFields[i]);
5745    
5746                                    if ((i + 1) < orderByConditionFields.length) {
5747                                            if (orderByComparator.isAscending() ^ previous) {
5748                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5749                                            }
5750                                            else {
5751                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5752                                            }
5753                                    }
5754                                    else {
5755                                            if (orderByComparator.isAscending() ^ previous) {
5756                                                    query.append(WHERE_GREATER_THAN);
5757                                            }
5758                                            else {
5759                                                    query.append(WHERE_LESSER_THAN);
5760                                            }
5761                                    }
5762                            }
5763    
5764                            query.append(ORDER_BY_CLAUSE);
5765    
5766                            String[] orderByFields = orderByComparator.getOrderByFields();
5767    
5768                            for (int i = 0; i < orderByFields.length; i++) {
5769                                    if (getDB().isSupportsInlineDistinct()) {
5770                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5771                                    }
5772                                    else {
5773                                            query.append(_ORDER_BY_ENTITY_TABLE);
5774                                    }
5775    
5776                                    query.append(orderByFields[i]);
5777    
5778                                    if ((i + 1) < orderByFields.length) {
5779                                            if (orderByComparator.isAscending() ^ previous) {
5780                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5781                                            }
5782                                            else {
5783                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5784                                            }
5785                                    }
5786                                    else {
5787                                            if (orderByComparator.isAscending() ^ previous) {
5788                                                    query.append(ORDER_BY_ASC);
5789                                            }
5790                                            else {
5791                                                    query.append(ORDER_BY_DESC);
5792                                            }
5793                                    }
5794                            }
5795                    }
5796    
5797                    else {
5798                            if (getDB().isSupportsInlineDistinct()) {
5799                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5800                            }
5801                            else {
5802                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5803                            }
5804                    }
5805    
5806                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5807                                    BlogsEntry.class.getName(),
5808                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5809    
5810                    SQLQuery q = session.createSQLQuery(sql);
5811    
5812                    q.setFirstResult(0);
5813                    q.setMaxResults(2);
5814    
5815                    if (getDB().isSupportsInlineDistinct()) {
5816                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5817                    }
5818                    else {
5819                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5820                    }
5821    
5822                    QueryPos qPos = QueryPos.getInstance(q);
5823    
5824                    qPos.add(groupId);
5825    
5826                    if (displayDate != null) {
5827                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5828                    }
5829    
5830                    if (orderByComparator != null) {
5831                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5832    
5833                            for (Object value : values) {
5834                                    qPos.add(value);
5835                            }
5836                    }
5837    
5838                    List<BlogsEntry> list = q.list();
5839    
5840                    if (list.size() == 2) {
5841                            return list.get(1);
5842                    }
5843                    else {
5844                            return null;
5845                    }
5846            }
5847    
5848            /**
5849             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5850             *
5851             * @param groupId the group ID
5852             * @param status the status
5853             * @return the matching blogs entries
5854             * @throws SystemException if a system exception occurred
5855             */
5856            public List<BlogsEntry> findByG_NeS(long groupId, int status)
5857                    throws SystemException {
5858                    return findByG_NeS(groupId, status, QueryUtil.ALL_POS,
5859                            QueryUtil.ALL_POS, null);
5860            }
5861    
5862            /**
5863             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5864             *
5865             * <p>
5866             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5867             * </p>
5868             *
5869             * @param groupId the group ID
5870             * @param status the status
5871             * @param start the lower bound of the range of blogs entries
5872             * @param end the upper bound of the range of blogs entries (not inclusive)
5873             * @return the range of matching blogs entries
5874             * @throws SystemException if a system exception occurred
5875             */
5876            public List<BlogsEntry> findByG_NeS(long groupId, int status, int start,
5877                    int end) throws SystemException {
5878                    return findByG_NeS(groupId, status, start, end, null);
5879            }
5880    
5881            /**
5882             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5883             *
5884             * <p>
5885             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
5886             * </p>
5887             *
5888             * @param groupId the group ID
5889             * @param status the status
5890             * @param start the lower bound of the range of blogs entries
5891             * @param end the upper bound of the range of blogs entries (not inclusive)
5892             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5893             * @return the ordered range of matching blogs entries
5894             * @throws SystemException if a system exception occurred
5895             */
5896            public List<BlogsEntry> findByG_NeS(long groupId, int status, int start,
5897                    int end, OrderByComparator orderByComparator) throws SystemException {
5898                    FinderPath finderPath = null;
5899                    Object[] finderArgs = null;
5900    
5901                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NES;
5902                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
5903    
5904                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5905                                    finderArgs, this);
5906    
5907                    if ((list != null) && !list.isEmpty()) {
5908                            for (BlogsEntry blogsEntry : list) {
5909                                    if ((groupId != blogsEntry.getGroupId()) ||
5910                                                    (status != blogsEntry.getStatus())) {
5911                                            list = null;
5912    
5913                                            break;
5914                                    }
5915                            }
5916                    }
5917    
5918                    if (list == null) {
5919                            StringBundler query = null;
5920    
5921                            if (orderByComparator != null) {
5922                                    query = new StringBundler(4 +
5923                                                    (orderByComparator.getOrderByFields().length * 3));
5924                            }
5925                            else {
5926                                    query = new StringBundler(4);
5927                            }
5928    
5929                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5930    
5931                            query.append(_FINDER_COLUMN_G_NES_GROUPID_2);
5932    
5933                            query.append(_FINDER_COLUMN_G_NES_STATUS_2);
5934    
5935                            if (orderByComparator != null) {
5936                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5937                                            orderByComparator);
5938                            }
5939    
5940                            else {
5941                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5942                            }
5943    
5944                            String sql = query.toString();
5945    
5946                            Session session = null;
5947    
5948                            try {
5949                                    session = openSession();
5950    
5951                                    Query q = session.createQuery(sql);
5952    
5953                                    QueryPos qPos = QueryPos.getInstance(q);
5954    
5955                                    qPos.add(groupId);
5956    
5957                                    qPos.add(status);
5958    
5959                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
5960                                                    end);
5961                            }
5962                            catch (Exception e) {
5963                                    throw processException(e);
5964                            }
5965                            finally {
5966                                    if (list == null) {
5967                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5968                                    }
5969                                    else {
5970                                            cacheResult(list);
5971    
5972                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5973                                    }
5974    
5975                                    closeSession(session);
5976                            }
5977                    }
5978    
5979                    return list;
5980            }
5981    
5982            /**
5983             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5984             *
5985             * @param groupId the group ID
5986             * @param status the status
5987             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5988             * @return the first matching blogs entry
5989             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5990             * @throws SystemException if a system exception occurred
5991             */
5992            public BlogsEntry findByG_NeS_First(long groupId, int status,
5993                    OrderByComparator orderByComparator)
5994                    throws NoSuchEntryException, SystemException {
5995                    BlogsEntry blogsEntry = fetchByG_NeS_First(groupId, status,
5996                                    orderByComparator);
5997    
5998                    if (blogsEntry != null) {
5999                            return blogsEntry;
6000                    }
6001    
6002                    StringBundler msg = new StringBundler(6);
6003    
6004                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6005    
6006                    msg.append("groupId=");
6007                    msg.append(groupId);
6008    
6009                    msg.append(", status=");
6010                    msg.append(status);
6011    
6012                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6013    
6014                    throw new NoSuchEntryException(msg.toString());
6015            }
6016    
6017            /**
6018             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6019             *
6020             * @param groupId the group ID
6021             * @param status the status
6022             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6023             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6024             * @throws SystemException if a system exception occurred
6025             */
6026            public BlogsEntry fetchByG_NeS_First(long groupId, int status,
6027                    OrderByComparator orderByComparator) throws SystemException {
6028                    List<BlogsEntry> list = findByG_NeS(groupId, status, 0, 1,
6029                                    orderByComparator);
6030    
6031                    if (!list.isEmpty()) {
6032                            return list.get(0);
6033                    }
6034    
6035                    return null;
6036            }
6037    
6038            /**
6039             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6040             *
6041             * @param groupId the group ID
6042             * @param status the status
6043             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6044             * @return the last matching blogs entry
6045             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6046             * @throws SystemException if a system exception occurred
6047             */
6048            public BlogsEntry findByG_NeS_Last(long groupId, int status,
6049                    OrderByComparator orderByComparator)
6050                    throws NoSuchEntryException, SystemException {
6051                    BlogsEntry blogsEntry = fetchByG_NeS_Last(groupId, status,
6052                                    orderByComparator);
6053    
6054                    if (blogsEntry != null) {
6055                            return blogsEntry;
6056                    }
6057    
6058                    StringBundler msg = new StringBundler(6);
6059    
6060                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6061    
6062                    msg.append("groupId=");
6063                    msg.append(groupId);
6064    
6065                    msg.append(", status=");
6066                    msg.append(status);
6067    
6068                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6069    
6070                    throw new NoSuchEntryException(msg.toString());
6071            }
6072    
6073            /**
6074             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6075             *
6076             * @param groupId the group ID
6077             * @param status the status
6078             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6079             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6080             * @throws SystemException if a system exception occurred
6081             */
6082            public BlogsEntry fetchByG_NeS_Last(long groupId, int status,
6083                    OrderByComparator orderByComparator) throws SystemException {
6084                    int count = countByG_NeS(groupId, status);
6085    
6086                    List<BlogsEntry> list = findByG_NeS(groupId, status, count - 1, count,
6087                                    orderByComparator);
6088    
6089                    if (!list.isEmpty()) {
6090                            return list.get(0);
6091                    }
6092    
6093                    return null;
6094            }
6095    
6096            /**
6097             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6098             *
6099             * @param entryId the primary key of the current blogs entry
6100             * @param groupId the group ID
6101             * @param status the status
6102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6103             * @return the previous, current, and next blogs entry
6104             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6105             * @throws SystemException if a system exception occurred
6106             */
6107            public BlogsEntry[] findByG_NeS_PrevAndNext(long entryId, long groupId,
6108                    int status, OrderByComparator orderByComparator)
6109                    throws NoSuchEntryException, SystemException {
6110                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6111    
6112                    Session session = null;
6113    
6114                    try {
6115                            session = openSession();
6116    
6117                            BlogsEntry[] array = new BlogsEntryImpl[3];
6118    
6119                            array[0] = getByG_NeS_PrevAndNext(session, blogsEntry, groupId,
6120                                            status, orderByComparator, true);
6121    
6122                            array[1] = blogsEntry;
6123    
6124                            array[2] = getByG_NeS_PrevAndNext(session, blogsEntry, groupId,
6125                                            status, orderByComparator, false);
6126    
6127                            return array;
6128                    }
6129                    catch (Exception e) {
6130                            throw processException(e);
6131                    }
6132                    finally {
6133                            closeSession(session);
6134                    }
6135            }
6136    
6137            protected BlogsEntry getByG_NeS_PrevAndNext(Session session,
6138                    BlogsEntry blogsEntry, long groupId, int status,
6139                    OrderByComparator orderByComparator, boolean previous) {
6140                    StringBundler query = null;
6141    
6142                    if (orderByComparator != null) {
6143                            query = new StringBundler(6 +
6144                                            (orderByComparator.getOrderByFields().length * 6));
6145                    }
6146                    else {
6147                            query = new StringBundler(3);
6148                    }
6149    
6150                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6151    
6152                    query.append(_FINDER_COLUMN_G_NES_GROUPID_2);
6153    
6154                    query.append(_FINDER_COLUMN_G_NES_STATUS_2);
6155    
6156                    if (orderByComparator != null) {
6157                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6158    
6159                            if (orderByConditionFields.length > 0) {
6160                                    query.append(WHERE_AND);
6161                            }
6162    
6163                            for (int i = 0; i < orderByConditionFields.length; i++) {
6164                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6165                                    query.append(orderByConditionFields[i]);
6166    
6167                                    if ((i + 1) < orderByConditionFields.length) {
6168                                            if (orderByComparator.isAscending() ^ previous) {
6169                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6170                                            }
6171                                            else {
6172                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6173                                            }
6174                                    }
6175                                    else {
6176                                            if (orderByComparator.isAscending() ^ previous) {
6177                                                    query.append(WHERE_GREATER_THAN);
6178                                            }
6179                                            else {
6180                                                    query.append(WHERE_LESSER_THAN);
6181                                            }
6182                                    }
6183                            }
6184    
6185                            query.append(ORDER_BY_CLAUSE);
6186    
6187                            String[] orderByFields = orderByComparator.getOrderByFields();
6188    
6189                            for (int i = 0; i < orderByFields.length; i++) {
6190                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6191                                    query.append(orderByFields[i]);
6192    
6193                                    if ((i + 1) < orderByFields.length) {
6194                                            if (orderByComparator.isAscending() ^ previous) {
6195                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6196                                            }
6197                                            else {
6198                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6199                                            }
6200                                    }
6201                                    else {
6202                                            if (orderByComparator.isAscending() ^ previous) {
6203                                                    query.append(ORDER_BY_ASC);
6204                                            }
6205                                            else {
6206                                                    query.append(ORDER_BY_DESC);
6207                                            }
6208                                    }
6209                            }
6210                    }
6211    
6212                    else {
6213                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6214                    }
6215    
6216                    String sql = query.toString();
6217    
6218                    Query q = session.createQuery(sql);
6219    
6220                    q.setFirstResult(0);
6221                    q.setMaxResults(2);
6222    
6223                    QueryPos qPos = QueryPos.getInstance(q);
6224    
6225                    qPos.add(groupId);
6226    
6227                    qPos.add(status);
6228    
6229                    if (orderByComparator != null) {
6230                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6231    
6232                            for (Object value : values) {
6233                                    qPos.add(value);
6234                            }
6235                    }
6236    
6237                    List<BlogsEntry> list = q.list();
6238    
6239                    if (list.size() == 2) {
6240                            return list.get(1);
6241                    }
6242                    else {
6243                            return null;
6244                    }
6245            }
6246    
6247            /**
6248             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6249             *
6250             * @param groupId the group ID
6251             * @param status the status
6252             * @return the matching blogs entries that the user has permission to view
6253             * @throws SystemException if a system exception occurred
6254             */
6255            public List<BlogsEntry> filterFindByG_NeS(long groupId, int status)
6256                    throws SystemException {
6257                    return filterFindByG_NeS(groupId, status, QueryUtil.ALL_POS,
6258                            QueryUtil.ALL_POS, null);
6259            }
6260    
6261            /**
6262             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6263             *
6264             * <p>
6265             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6266             * </p>
6267             *
6268             * @param groupId the group ID
6269             * @param status the status
6270             * @param start the lower bound of the range of blogs entries
6271             * @param end the upper bound of the range of blogs entries (not inclusive)
6272             * @return the range of matching blogs entries that the user has permission to view
6273             * @throws SystemException if a system exception occurred
6274             */
6275            public List<BlogsEntry> filterFindByG_NeS(long groupId, int status,
6276                    int start, int end) throws SystemException {
6277                    return filterFindByG_NeS(groupId, status, start, end, null);
6278            }
6279    
6280            /**
6281             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
6282             *
6283             * <p>
6284             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6285             * </p>
6286             *
6287             * @param groupId the group ID
6288             * @param status the status
6289             * @param start the lower bound of the range of blogs entries
6290             * @param end the upper bound of the range of blogs entries (not inclusive)
6291             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6292             * @return the ordered range of matching blogs entries that the user has permission to view
6293             * @throws SystemException if a system exception occurred
6294             */
6295            public List<BlogsEntry> filterFindByG_NeS(long groupId, int status,
6296                    int start, int end, OrderByComparator orderByComparator)
6297                    throws SystemException {
6298                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6299                            return findByG_NeS(groupId, status, start, end, orderByComparator);
6300                    }
6301    
6302                    StringBundler query = null;
6303    
6304                    if (orderByComparator != null) {
6305                            query = new StringBundler(4 +
6306                                            (orderByComparator.getOrderByFields().length * 3));
6307                    }
6308                    else {
6309                            query = new StringBundler(4);
6310                    }
6311    
6312                    if (getDB().isSupportsInlineDistinct()) {
6313                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6314                    }
6315                    else {
6316                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6317                    }
6318    
6319                    query.append(_FINDER_COLUMN_G_NES_GROUPID_2);
6320    
6321                    query.append(_FINDER_COLUMN_G_NES_STATUS_2);
6322    
6323                    if (!getDB().isSupportsInlineDistinct()) {
6324                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6325                    }
6326    
6327                    if (orderByComparator != null) {
6328                            if (getDB().isSupportsInlineDistinct()) {
6329                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6330                                            orderByComparator);
6331                            }
6332                            else {
6333                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6334                                            orderByComparator);
6335                            }
6336                    }
6337    
6338                    else {
6339                            if (getDB().isSupportsInlineDistinct()) {
6340                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6341                            }
6342                            else {
6343                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6344                            }
6345                    }
6346    
6347                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6348                                    BlogsEntry.class.getName(),
6349                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6350    
6351                    Session session = null;
6352    
6353                    try {
6354                            session = openSession();
6355    
6356                            SQLQuery q = session.createSQLQuery(sql);
6357    
6358                            if (getDB().isSupportsInlineDistinct()) {
6359                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6360                            }
6361                            else {
6362                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6363                            }
6364    
6365                            QueryPos qPos = QueryPos.getInstance(q);
6366    
6367                            qPos.add(groupId);
6368    
6369                            qPos.add(status);
6370    
6371                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
6372                    }
6373                    catch (Exception e) {
6374                            throw processException(e);
6375                    }
6376                    finally {
6377                            closeSession(session);
6378                    }
6379            }
6380    
6381            /**
6382             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6383             *
6384             * @param entryId the primary key of the current blogs entry
6385             * @param groupId the group ID
6386             * @param status the status
6387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6388             * @return the previous, current, and next blogs entry
6389             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6390             * @throws SystemException if a system exception occurred
6391             */
6392            public BlogsEntry[] filterFindByG_NeS_PrevAndNext(long entryId,
6393                    long groupId, int status, OrderByComparator orderByComparator)
6394                    throws NoSuchEntryException, SystemException {
6395                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6396                            return findByG_NeS_PrevAndNext(entryId, groupId, status,
6397                                    orderByComparator);
6398                    }
6399    
6400                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6401    
6402                    Session session = null;
6403    
6404                    try {
6405                            session = openSession();
6406    
6407                            BlogsEntry[] array = new BlogsEntryImpl[3];
6408    
6409                            array[0] = filterGetByG_NeS_PrevAndNext(session, blogsEntry,
6410                                            groupId, status, orderByComparator, true);
6411    
6412                            array[1] = blogsEntry;
6413    
6414                            array[2] = filterGetByG_NeS_PrevAndNext(session, blogsEntry,
6415                                            groupId, status, orderByComparator, false);
6416    
6417                            return array;
6418                    }
6419                    catch (Exception e) {
6420                            throw processException(e);
6421                    }
6422                    finally {
6423                            closeSession(session);
6424                    }
6425            }
6426    
6427            protected BlogsEntry filterGetByG_NeS_PrevAndNext(Session session,
6428                    BlogsEntry blogsEntry, long groupId, int status,
6429                    OrderByComparator orderByComparator, boolean previous) {
6430                    StringBundler query = null;
6431    
6432                    if (orderByComparator != null) {
6433                            query = new StringBundler(6 +
6434                                            (orderByComparator.getOrderByFields().length * 6));
6435                    }
6436                    else {
6437                            query = new StringBundler(3);
6438                    }
6439    
6440                    if (getDB().isSupportsInlineDistinct()) {
6441                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6442                    }
6443                    else {
6444                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6445                    }
6446    
6447                    query.append(_FINDER_COLUMN_G_NES_GROUPID_2);
6448    
6449                    query.append(_FINDER_COLUMN_G_NES_STATUS_2);
6450    
6451                    if (!getDB().isSupportsInlineDistinct()) {
6452                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6453                    }
6454    
6455                    if (orderByComparator != null) {
6456                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6457    
6458                            if (orderByConditionFields.length > 0) {
6459                                    query.append(WHERE_AND);
6460                            }
6461    
6462                            for (int i = 0; i < orderByConditionFields.length; i++) {
6463                                    if (getDB().isSupportsInlineDistinct()) {
6464                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6465                                    }
6466                                    else {
6467                                            query.append(_ORDER_BY_ENTITY_TABLE);
6468                                    }
6469    
6470                                    query.append(orderByConditionFields[i]);
6471    
6472                                    if ((i + 1) < orderByConditionFields.length) {
6473                                            if (orderByComparator.isAscending() ^ previous) {
6474                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6475                                            }
6476                                            else {
6477                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6478                                            }
6479                                    }
6480                                    else {
6481                                            if (orderByComparator.isAscending() ^ previous) {
6482                                                    query.append(WHERE_GREATER_THAN);
6483                                            }
6484                                            else {
6485                                                    query.append(WHERE_LESSER_THAN);
6486                                            }
6487                                    }
6488                            }
6489    
6490                            query.append(ORDER_BY_CLAUSE);
6491    
6492                            String[] orderByFields = orderByComparator.getOrderByFields();
6493    
6494                            for (int i = 0; i < orderByFields.length; i++) {
6495                                    if (getDB().isSupportsInlineDistinct()) {
6496                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6497                                    }
6498                                    else {
6499                                            query.append(_ORDER_BY_ENTITY_TABLE);
6500                                    }
6501    
6502                                    query.append(orderByFields[i]);
6503    
6504                                    if ((i + 1) < orderByFields.length) {
6505                                            if (orderByComparator.isAscending() ^ previous) {
6506                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6507                                            }
6508                                            else {
6509                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6510                                            }
6511                                    }
6512                                    else {
6513                                            if (orderByComparator.isAscending() ^ previous) {
6514                                                    query.append(ORDER_BY_ASC);
6515                                            }
6516                                            else {
6517                                                    query.append(ORDER_BY_DESC);
6518                                            }
6519                                    }
6520                            }
6521                    }
6522    
6523                    else {
6524                            if (getDB().isSupportsInlineDistinct()) {
6525                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6526                            }
6527                            else {
6528                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6529                            }
6530                    }
6531    
6532                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6533                                    BlogsEntry.class.getName(),
6534                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6535    
6536                    SQLQuery q = session.createSQLQuery(sql);
6537    
6538                    q.setFirstResult(0);
6539                    q.setMaxResults(2);
6540    
6541                    if (getDB().isSupportsInlineDistinct()) {
6542                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6543                    }
6544                    else {
6545                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6546                    }
6547    
6548                    QueryPos qPos = QueryPos.getInstance(q);
6549    
6550                    qPos.add(groupId);
6551    
6552                    qPos.add(status);
6553    
6554                    if (orderByComparator != null) {
6555                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6556    
6557                            for (Object value : values) {
6558                                    qPos.add(value);
6559                            }
6560                    }
6561    
6562                    List<BlogsEntry> list = q.list();
6563    
6564                    if (list.size() == 2) {
6565                            return list.get(1);
6566                    }
6567                    else {
6568                            return null;
6569                    }
6570            }
6571    
6572            /**
6573             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
6574             *
6575             * @param groupId the group ID
6576             * @param status the status
6577             * @return the matching blogs entries
6578             * @throws SystemException if a system exception occurred
6579             */
6580            public List<BlogsEntry> findByG_S(long groupId, int status)
6581                    throws SystemException {
6582                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6583                            null);
6584            }
6585    
6586            /**
6587             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
6588             *
6589             * <p>
6590             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6591             * </p>
6592             *
6593             * @param groupId the group ID
6594             * @param status the status
6595             * @param start the lower bound of the range of blogs entries
6596             * @param end the upper bound of the range of blogs entries (not inclusive)
6597             * @return the range of matching blogs entries
6598             * @throws SystemException if a system exception occurred
6599             */
6600            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
6601                    int end) throws SystemException {
6602                    return findByG_S(groupId, status, start, end, null);
6603            }
6604    
6605            /**
6606             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
6607             *
6608             * <p>
6609             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
6610             * </p>
6611             *
6612             * @param groupId the group ID
6613             * @param status the status
6614             * @param start the lower bound of the range of blogs entries
6615             * @param end the upper bound of the range of blogs entries (not inclusive)
6616             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6617             * @return the ordered range of matching blogs entries
6618             * @throws SystemException if a system exception occurred
6619             */
6620            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
6621                    int end, OrderByComparator orderByComparator) throws SystemException {
6622                    FinderPath finderPath = null;
6623                    Object[] finderArgs = null;
6624    
6625                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6626                                    (orderByComparator == null)) {
6627                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
6628                            finderArgs = new Object[] { groupId, status };
6629                    }
6630                    else {
6631                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
6632                            finderArgs = new Object[] {
6633                                            groupId, status,
6634                                            
6635                                            start, end, orderByComparator
6636                                    };
6637                    }
6638    
6639                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6640                                    finderArgs, this);
6641    
6642                    if ((list != null) && !list.isEmpty()) {
6643                            for (BlogsEntry blogsEntry : list) {
6644                                    if ((groupId != blogsEntry.getGroupId()) ||
6645                                                    (status != blogsEntry.getStatus())) {
6646                                            list = null;
6647    
6648                                            break;
6649                                    }
6650                            }
6651                    }
6652    
6653                    if (list == null) {
6654                            StringBundler query = null;
6655    
6656                            if (orderByComparator != null) {
6657                                    query = new StringBundler(4 +
6658                                                    (orderByComparator.getOrderByFields().length * 3));
6659                            }
6660                            else {
6661                                    query = new StringBundler(4);
6662                            }
6663    
6664                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6665    
6666                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6667    
6668                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
6669    
6670                            if (orderByComparator != null) {
6671                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6672                                            orderByComparator);
6673                            }
6674    
6675                            else {
6676                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6677                            }
6678    
6679                            String sql = query.toString();
6680    
6681                            Session session = null;
6682    
6683                            try {
6684                                    session = openSession();
6685    
6686                                    Query q = session.createQuery(sql);
6687    
6688                                    QueryPos qPos = QueryPos.getInstance(q);
6689    
6690                                    qPos.add(groupId);
6691    
6692                                    qPos.add(status);
6693    
6694                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
6695                                                    end);
6696                            }
6697                            catch (Exception e) {
6698                                    throw processException(e);
6699                            }
6700                            finally {
6701                                    if (list == null) {
6702                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6703                                    }
6704                                    else {
6705                                            cacheResult(list);
6706    
6707                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6708                                    }
6709    
6710                                    closeSession(session);
6711                            }
6712                    }
6713    
6714                    return list;
6715            }
6716    
6717            /**
6718             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
6719             *
6720             * @param groupId the group ID
6721             * @param status the status
6722             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6723             * @return the first matching blogs entry
6724             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6725             * @throws SystemException if a system exception occurred
6726             */
6727            public BlogsEntry findByG_S_First(long groupId, int status,
6728                    OrderByComparator orderByComparator)
6729                    throws NoSuchEntryException, SystemException {
6730                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
6731                                    orderByComparator);
6732    
6733                    if (blogsEntry != null) {
6734                            return blogsEntry;
6735                    }
6736    
6737                    StringBundler msg = new StringBundler(6);
6738    
6739                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6740    
6741                    msg.append("groupId=");
6742                    msg.append(groupId);
6743    
6744                    msg.append(", status=");
6745                    msg.append(status);
6746    
6747                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6748    
6749                    throw new NoSuchEntryException(msg.toString());
6750            }
6751    
6752            /**
6753             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
6754             *
6755             * @param groupId the group ID
6756             * @param status the status
6757             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6758             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6759             * @throws SystemException if a system exception occurred
6760             */
6761            public BlogsEntry fetchByG_S_First(long groupId, int status,
6762                    OrderByComparator orderByComparator) throws SystemException {
6763                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
6764                                    orderByComparator);
6765    
6766                    if (!list.isEmpty()) {
6767                            return list.get(0);
6768                    }
6769    
6770                    return null;
6771            }
6772    
6773            /**
6774             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
6775             *
6776             * @param groupId the group ID
6777             * @param status the status
6778             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6779             * @return the last matching blogs entry
6780             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6781             * @throws SystemException if a system exception occurred
6782             */
6783            public BlogsEntry findByG_S_Last(long groupId, int status,
6784                    OrderByComparator orderByComparator)
6785                    throws NoSuchEntryException, SystemException {
6786                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
6787                                    orderByComparator);
6788    
6789                    if (blogsEntry != null) {
6790                            return blogsEntry;
6791                    }
6792    
6793                    StringBundler msg = new StringBundler(6);
6794    
6795                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6796    
6797                    msg.append("groupId=");
6798                    msg.append(groupId);
6799    
6800                    msg.append(", status=");
6801                    msg.append(status);
6802    
6803                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6804    
6805                    throw new NoSuchEntryException(msg.toString());
6806            }
6807    
6808            /**
6809             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
6810             *
6811             * @param groupId the group ID
6812             * @param status the status
6813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6814             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6815             * @throws SystemException if a system exception occurred
6816             */
6817            public BlogsEntry fetchByG_S_Last(long groupId, int status,
6818                    OrderByComparator orderByComparator) throws SystemException {
6819                    int count = countByG_S(groupId, status);
6820    
6821                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
6822                                    orderByComparator);
6823    
6824                    if (!list.isEmpty()) {
6825                            return list.get(0);
6826                    }
6827    
6828                    return null;
6829            }
6830    
6831            /**
6832             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
6833             *
6834             * @param entryId the primary key of the current blogs entry
6835             * @param groupId the group ID
6836             * @param status the status
6837             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6838             * @return the previous, current, and next blogs entry
6839             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6840             * @throws SystemException if a system exception occurred
6841             */
6842            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
6843                    int status, OrderByComparator orderByComparator)
6844                    throws NoSuchEntryException, SystemException {
6845                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6846    
6847                    Session session = null;
6848    
6849                    try {
6850                            session = openSession();
6851    
6852                            BlogsEntry[] array = new BlogsEntryImpl[3];
6853    
6854                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
6855                                            status, orderByComparator, true);
6856    
6857                            array[1] = blogsEntry;
6858    
6859                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
6860                                            status, orderByComparator, false);
6861    
6862                            return array;
6863                    }
6864                    catch (Exception e) {
6865                            throw processException(e);
6866                    }
6867                    finally {
6868                            closeSession(session);
6869                    }
6870            }
6871    
6872            protected BlogsEntry getByG_S_PrevAndNext(Session session,
6873                    BlogsEntry blogsEntry, long groupId, int status,
6874                    OrderByComparator orderByComparator, boolean previous) {
6875                    StringBundler query = null;
6876    
6877                    if (orderByComparator != null) {
6878                            query = new StringBundler(6 +
6879                                            (orderByComparator.getOrderByFields().length * 6));
6880                    }
6881                    else {
6882                            query = new StringBundler(3);
6883                    }
6884    
6885                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6886    
6887                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6888    
6889                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
6890    
6891                    if (orderByComparator != null) {
6892                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6893    
6894                            if (orderByConditionFields.length > 0) {
6895                                    query.append(WHERE_AND);
6896                            }
6897    
6898                            for (int i = 0; i < orderByConditionFields.length; i++) {
6899                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6900                                    query.append(orderByConditionFields[i]);
6901    
6902                                    if ((i + 1) < orderByConditionFields.length) {
6903                                            if (orderByComparator.isAscending() ^ previous) {
6904                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6905                                            }
6906                                            else {
6907                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6908                                            }
6909                                    }
6910                                    else {
6911                                            if (orderByComparator.isAscending() ^ previous) {
6912                                                    query.append(WHERE_GREATER_THAN);
6913                                            }
6914                                            else {
6915                                                    query.append(WHERE_LESSER_THAN);
6916                                            }
6917                                    }
6918                            }
6919    
6920                            query.append(ORDER_BY_CLAUSE);
6921    
6922                            String[] orderByFields = orderByComparator.getOrderByFields();
6923    
6924                            for (int i = 0; i < orderByFields.length; i++) {
6925                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6926                                    query.append(orderByFields[i]);
6927    
6928                                    if ((i + 1) < orderByFields.length) {
6929                                            if (orderByComparator.isAscending() ^ previous) {
6930                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6931                                            }
6932                                            else {
6933                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6934                                            }
6935                                    }
6936                                    else {
6937                                            if (orderByComparator.isAscending() ^ previous) {
6938                                                    query.append(ORDER_BY_ASC);
6939                                            }
6940                                            else {
6941                                                    query.append(ORDER_BY_DESC);
6942                                            }
6943                                    }
6944                            }
6945                    }
6946    
6947                    else {
6948                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6949                    }
6950    
6951                    String sql = query.toString();
6952    
6953                    Query q = session.createQuery(sql);
6954    
6955                    q.setFirstResult(0);
6956                    q.setMaxResults(2);
6957    
6958                    QueryPos qPos = QueryPos.getInstance(q);
6959    
6960                    qPos.add(groupId);
6961    
6962                    qPos.add(status);
6963    
6964                    if (orderByComparator != null) {
6965                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6966    
6967                            for (Object value : values) {
6968                                    qPos.add(value);
6969                            }
6970                    }
6971    
6972                    List<BlogsEntry> list = q.list();
6973    
6974                    if (list.size() == 2) {
6975                            return list.get(1);
6976                    }
6977                    else {
6978                            return null;
6979                    }
6980            }
6981    
6982            /**
6983             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
6984             *
6985             * @param groupId the group ID
6986             * @param status the status
6987             * @return the matching blogs entries that the user has permission to view
6988             * @throws SystemException if a system exception occurred
6989             */
6990            public List<BlogsEntry> filterFindByG_S(long groupId, int status)
6991                    throws SystemException {
6992                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
6993                            QueryUtil.ALL_POS, null);
6994            }
6995    
6996            /**
6997             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
6998             *
6999             * <p>
7000             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7001             * </p>
7002             *
7003             * @param groupId the group ID
7004             * @param status the status
7005             * @param start the lower bound of the range of blogs entries
7006             * @param end the upper bound of the range of blogs entries (not inclusive)
7007             * @return the range of matching blogs entries that the user has permission to view
7008             * @throws SystemException if a system exception occurred
7009             */
7010            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7011                    int start, int end) throws SystemException {
7012                    return filterFindByG_S(groupId, status, start, end, null);
7013            }
7014    
7015            /**
7016             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
7017             *
7018             * <p>
7019             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7020             * </p>
7021             *
7022             * @param groupId the group ID
7023             * @param status the status
7024             * @param start the lower bound of the range of blogs entries
7025             * @param end the upper bound of the range of blogs entries (not inclusive)
7026             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7027             * @return the ordered range of matching blogs entries that the user has permission to view
7028             * @throws SystemException if a system exception occurred
7029             */
7030            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7031                    int start, int end, OrderByComparator orderByComparator)
7032                    throws SystemException {
7033                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7034                            return findByG_S(groupId, status, start, end, orderByComparator);
7035                    }
7036    
7037                    StringBundler query = null;
7038    
7039                    if (orderByComparator != null) {
7040                            query = new StringBundler(4 +
7041                                            (orderByComparator.getOrderByFields().length * 3));
7042                    }
7043                    else {
7044                            query = new StringBundler(4);
7045                    }
7046    
7047                    if (getDB().isSupportsInlineDistinct()) {
7048                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7049                    }
7050                    else {
7051                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7052                    }
7053    
7054                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7055    
7056                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7057    
7058                    if (!getDB().isSupportsInlineDistinct()) {
7059                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7060                    }
7061    
7062                    if (orderByComparator != null) {
7063                            if (getDB().isSupportsInlineDistinct()) {
7064                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7065                                            orderByComparator);
7066                            }
7067                            else {
7068                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7069                                            orderByComparator);
7070                            }
7071                    }
7072    
7073                    else {
7074                            if (getDB().isSupportsInlineDistinct()) {
7075                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7076                            }
7077                            else {
7078                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7079                            }
7080                    }
7081    
7082                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7083                                    BlogsEntry.class.getName(),
7084                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7085    
7086                    Session session = null;
7087    
7088                    try {
7089                            session = openSession();
7090    
7091                            SQLQuery q = session.createSQLQuery(sql);
7092    
7093                            if (getDB().isSupportsInlineDistinct()) {
7094                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7095                            }
7096                            else {
7097                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7098                            }
7099    
7100                            QueryPos qPos = QueryPos.getInstance(q);
7101    
7102                            qPos.add(groupId);
7103    
7104                            qPos.add(status);
7105    
7106                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
7107                    }
7108                    catch (Exception e) {
7109                            throw processException(e);
7110                    }
7111                    finally {
7112                            closeSession(session);
7113                    }
7114            }
7115    
7116            /**
7117             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7118             *
7119             * @param entryId the primary key of the current blogs entry
7120             * @param groupId the group ID
7121             * @param status the status
7122             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7123             * @return the previous, current, and next blogs entry
7124             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7125             * @throws SystemException if a system exception occurred
7126             */
7127            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
7128                    int status, OrderByComparator orderByComparator)
7129                    throws NoSuchEntryException, SystemException {
7130                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7131                            return findByG_S_PrevAndNext(entryId, groupId, status,
7132                                    orderByComparator);
7133                    }
7134    
7135                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7136    
7137                    Session session = null;
7138    
7139                    try {
7140                            session = openSession();
7141    
7142                            BlogsEntry[] array = new BlogsEntryImpl[3];
7143    
7144                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7145                                            status, orderByComparator, true);
7146    
7147                            array[1] = blogsEntry;
7148    
7149                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7150                                            status, orderByComparator, false);
7151    
7152                            return array;
7153                    }
7154                    catch (Exception e) {
7155                            throw processException(e);
7156                    }
7157                    finally {
7158                            closeSession(session);
7159                    }
7160            }
7161    
7162            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
7163                    BlogsEntry blogsEntry, long groupId, int status,
7164                    OrderByComparator orderByComparator, boolean previous) {
7165                    StringBundler query = null;
7166    
7167                    if (orderByComparator != null) {
7168                            query = new StringBundler(6 +
7169                                            (orderByComparator.getOrderByFields().length * 6));
7170                    }
7171                    else {
7172                            query = new StringBundler(3);
7173                    }
7174    
7175                    if (getDB().isSupportsInlineDistinct()) {
7176                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7177                    }
7178                    else {
7179                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7180                    }
7181    
7182                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7183    
7184                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7185    
7186                    if (!getDB().isSupportsInlineDistinct()) {
7187                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7188                    }
7189    
7190                    if (orderByComparator != null) {
7191                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7192    
7193                            if (orderByConditionFields.length > 0) {
7194                                    query.append(WHERE_AND);
7195                            }
7196    
7197                            for (int i = 0; i < orderByConditionFields.length; i++) {
7198                                    if (getDB().isSupportsInlineDistinct()) {
7199                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7200                                    }
7201                                    else {
7202                                            query.append(_ORDER_BY_ENTITY_TABLE);
7203                                    }
7204    
7205                                    query.append(orderByConditionFields[i]);
7206    
7207                                    if ((i + 1) < orderByConditionFields.length) {
7208                                            if (orderByComparator.isAscending() ^ previous) {
7209                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7210                                            }
7211                                            else {
7212                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7213                                            }
7214                                    }
7215                                    else {
7216                                            if (orderByComparator.isAscending() ^ previous) {
7217                                                    query.append(WHERE_GREATER_THAN);
7218                                            }
7219                                            else {
7220                                                    query.append(WHERE_LESSER_THAN);
7221                                            }
7222                                    }
7223                            }
7224    
7225                            query.append(ORDER_BY_CLAUSE);
7226    
7227                            String[] orderByFields = orderByComparator.getOrderByFields();
7228    
7229                            for (int i = 0; i < orderByFields.length; i++) {
7230                                    if (getDB().isSupportsInlineDistinct()) {
7231                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7232                                    }
7233                                    else {
7234                                            query.append(_ORDER_BY_ENTITY_TABLE);
7235                                    }
7236    
7237                                    query.append(orderByFields[i]);
7238    
7239                                    if ((i + 1) < orderByFields.length) {
7240                                            if (orderByComparator.isAscending() ^ previous) {
7241                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7242                                            }
7243                                            else {
7244                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7245                                            }
7246                                    }
7247                                    else {
7248                                            if (orderByComparator.isAscending() ^ previous) {
7249                                                    query.append(ORDER_BY_ASC);
7250                                            }
7251                                            else {
7252                                                    query.append(ORDER_BY_DESC);
7253                                            }
7254                                    }
7255                            }
7256                    }
7257    
7258                    else {
7259                            if (getDB().isSupportsInlineDistinct()) {
7260                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7261                            }
7262                            else {
7263                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7264                            }
7265                    }
7266    
7267                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7268                                    BlogsEntry.class.getName(),
7269                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7270    
7271                    SQLQuery q = session.createSQLQuery(sql);
7272    
7273                    q.setFirstResult(0);
7274                    q.setMaxResults(2);
7275    
7276                    if (getDB().isSupportsInlineDistinct()) {
7277                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7278                    }
7279                    else {
7280                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7281                    }
7282    
7283                    QueryPos qPos = QueryPos.getInstance(q);
7284    
7285                    qPos.add(groupId);
7286    
7287                    qPos.add(status);
7288    
7289                    if (orderByComparator != null) {
7290                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7291    
7292                            for (Object value : values) {
7293                                    qPos.add(value);
7294                            }
7295                    }
7296    
7297                    List<BlogsEntry> list = q.list();
7298    
7299                    if (list.size() == 2) {
7300                            return list.get(1);
7301                    }
7302                    else {
7303                            return null;
7304                    }
7305            }
7306    
7307            /**
7308             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7309             *
7310             * @param displayDate the display date
7311             * @param status the status
7312             * @return the matching blogs entries
7313             * @throws SystemException if a system exception occurred
7314             */
7315            public List<BlogsEntry> findByLtD_S(Date displayDate, int status)
7316                    throws SystemException {
7317                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
7318                            QueryUtil.ALL_POS, null);
7319            }
7320    
7321            /**
7322             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7323             *
7324             * <p>
7325             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7326             * </p>
7327             *
7328             * @param displayDate the display date
7329             * @param status the status
7330             * @param start the lower bound of the range of blogs entries
7331             * @param end the upper bound of the range of blogs entries (not inclusive)
7332             * @return the range of matching blogs entries
7333             * @throws SystemException if a system exception occurred
7334             */
7335            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7336                    int start, int end) throws SystemException {
7337                    return findByLtD_S(displayDate, status, start, end, null);
7338            }
7339    
7340            /**
7341             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7342             *
7343             * <p>
7344             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7345             * </p>
7346             *
7347             * @param displayDate the display date
7348             * @param status the status
7349             * @param start the lower bound of the range of blogs entries
7350             * @param end the upper bound of the range of blogs entries (not inclusive)
7351             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7352             * @return the ordered range of matching blogs entries
7353             * @throws SystemException if a system exception occurred
7354             */
7355            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7356                    int start, int end, OrderByComparator orderByComparator)
7357                    throws SystemException {
7358                    FinderPath finderPath = null;
7359                    Object[] finderArgs = null;
7360    
7361                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
7362                    finderArgs = new Object[] {
7363                                    displayDate, status,
7364                                    
7365                                    start, end, orderByComparator
7366                            };
7367    
7368                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7369                                    finderArgs, this);
7370    
7371                    if ((list != null) && !list.isEmpty()) {
7372                            for (BlogsEntry blogsEntry : list) {
7373                                    if (!Validator.equals(displayDate, blogsEntry.getDisplayDate()) ||
7374                                                    (status != blogsEntry.getStatus())) {
7375                                            list = null;
7376    
7377                                            break;
7378                                    }
7379                            }
7380                    }
7381    
7382                    if (list == null) {
7383                            StringBundler query = null;
7384    
7385                            if (orderByComparator != null) {
7386                                    query = new StringBundler(4 +
7387                                                    (orderByComparator.getOrderByFields().length * 3));
7388                            }
7389                            else {
7390                                    query = new StringBundler(4);
7391                            }
7392    
7393                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7394    
7395                            if (displayDate == null) {
7396                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
7397                            }
7398                            else {
7399                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
7400                            }
7401    
7402                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
7403    
7404                            if (orderByComparator != null) {
7405                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7406                                            orderByComparator);
7407                            }
7408    
7409                            else {
7410                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7411                            }
7412    
7413                            String sql = query.toString();
7414    
7415                            Session session = null;
7416    
7417                            try {
7418                                    session = openSession();
7419    
7420                                    Query q = session.createQuery(sql);
7421    
7422                                    QueryPos qPos = QueryPos.getInstance(q);
7423    
7424                                    if (displayDate != null) {
7425                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
7426                                    }
7427    
7428                                    qPos.add(status);
7429    
7430                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
7431                                                    end);
7432                            }
7433                            catch (Exception e) {
7434                                    throw processException(e);
7435                            }
7436                            finally {
7437                                    if (list == null) {
7438                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7439                                    }
7440                                    else {
7441                                            cacheResult(list);
7442    
7443                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7444                                    }
7445    
7446                                    closeSession(session);
7447                            }
7448                    }
7449    
7450                    return list;
7451            }
7452    
7453            /**
7454             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7455             *
7456             * @param displayDate the display date
7457             * @param status the status
7458             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7459             * @return the first matching blogs entry
7460             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7461             * @throws SystemException if a system exception occurred
7462             */
7463            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
7464                    OrderByComparator orderByComparator)
7465                    throws NoSuchEntryException, SystemException {
7466                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
7467                                    orderByComparator);
7468    
7469                    if (blogsEntry != null) {
7470                            return blogsEntry;
7471                    }
7472    
7473                    StringBundler msg = new StringBundler(6);
7474    
7475                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7476    
7477                    msg.append("displayDate=");
7478                    msg.append(displayDate);
7479    
7480                    msg.append(", status=");
7481                    msg.append(status);
7482    
7483                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7484    
7485                    throw new NoSuchEntryException(msg.toString());
7486            }
7487    
7488            /**
7489             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7490             *
7491             * @param displayDate the display date
7492             * @param status the status
7493             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7494             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7495             * @throws SystemException if a system exception occurred
7496             */
7497            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
7498                    OrderByComparator orderByComparator) throws SystemException {
7499                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
7500                                    orderByComparator);
7501    
7502                    if (!list.isEmpty()) {
7503                            return list.get(0);
7504                    }
7505    
7506                    return null;
7507            }
7508    
7509            /**
7510             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7511             *
7512             * @param displayDate the display date
7513             * @param status the status
7514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7515             * @return the last matching blogs entry
7516             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7517             * @throws SystemException if a system exception occurred
7518             */
7519            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
7520                    OrderByComparator orderByComparator)
7521                    throws NoSuchEntryException, SystemException {
7522                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
7523                                    orderByComparator);
7524    
7525                    if (blogsEntry != null) {
7526                            return blogsEntry;
7527                    }
7528    
7529                    StringBundler msg = new StringBundler(6);
7530    
7531                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7532    
7533                    msg.append("displayDate=");
7534                    msg.append(displayDate);
7535    
7536                    msg.append(", status=");
7537                    msg.append(status);
7538    
7539                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7540    
7541                    throw new NoSuchEntryException(msg.toString());
7542            }
7543    
7544            /**
7545             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7546             *
7547             * @param displayDate the display date
7548             * @param status the status
7549             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7550             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7551             * @throws SystemException if a system exception occurred
7552             */
7553            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
7554                    OrderByComparator orderByComparator) throws SystemException {
7555                    int count = countByLtD_S(displayDate, status);
7556    
7557                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
7558                                    count, orderByComparator);
7559    
7560                    if (!list.isEmpty()) {
7561                            return list.get(0);
7562                    }
7563    
7564                    return null;
7565            }
7566    
7567            /**
7568             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7569             *
7570             * @param entryId the primary key of the current blogs entry
7571             * @param displayDate the display date
7572             * @param status the status
7573             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7574             * @return the previous, current, and next blogs entry
7575             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7576             * @throws SystemException if a system exception occurred
7577             */
7578            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
7579                    int status, OrderByComparator orderByComparator)
7580                    throws NoSuchEntryException, SystemException {
7581                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7582    
7583                    Session session = null;
7584    
7585                    try {
7586                            session = openSession();
7587    
7588                            BlogsEntry[] array = new BlogsEntryImpl[3];
7589    
7590                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
7591                                            status, orderByComparator, true);
7592    
7593                            array[1] = blogsEntry;
7594    
7595                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
7596                                            status, orderByComparator, false);
7597    
7598                            return array;
7599                    }
7600                    catch (Exception e) {
7601                            throw processException(e);
7602                    }
7603                    finally {
7604                            closeSession(session);
7605                    }
7606            }
7607    
7608            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
7609                    BlogsEntry blogsEntry, Date displayDate, int status,
7610                    OrderByComparator orderByComparator, boolean previous) {
7611                    StringBundler query = null;
7612    
7613                    if (orderByComparator != null) {
7614                            query = new StringBundler(6 +
7615                                            (orderByComparator.getOrderByFields().length * 6));
7616                    }
7617                    else {
7618                            query = new StringBundler(3);
7619                    }
7620    
7621                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7622    
7623                    if (displayDate == null) {
7624                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
7625                    }
7626                    else {
7627                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
7628                    }
7629    
7630                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
7631    
7632                    if (orderByComparator != null) {
7633                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7634    
7635                            if (orderByConditionFields.length > 0) {
7636                                    query.append(WHERE_AND);
7637                            }
7638    
7639                            for (int i = 0; i < orderByConditionFields.length; i++) {
7640                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7641                                    query.append(orderByConditionFields[i]);
7642    
7643                                    if ((i + 1) < orderByConditionFields.length) {
7644                                            if (orderByComparator.isAscending() ^ previous) {
7645                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7646                                            }
7647                                            else {
7648                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7649                                            }
7650                                    }
7651                                    else {
7652                                            if (orderByComparator.isAscending() ^ previous) {
7653                                                    query.append(WHERE_GREATER_THAN);
7654                                            }
7655                                            else {
7656                                                    query.append(WHERE_LESSER_THAN);
7657                                            }
7658                                    }
7659                            }
7660    
7661                            query.append(ORDER_BY_CLAUSE);
7662    
7663                            String[] orderByFields = orderByComparator.getOrderByFields();
7664    
7665                            for (int i = 0; i < orderByFields.length; i++) {
7666                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7667                                    query.append(orderByFields[i]);
7668    
7669                                    if ((i + 1) < orderByFields.length) {
7670                                            if (orderByComparator.isAscending() ^ previous) {
7671                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7672                                            }
7673                                            else {
7674                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7675                                            }
7676                                    }
7677                                    else {
7678                                            if (orderByComparator.isAscending() ^ previous) {
7679                                                    query.append(ORDER_BY_ASC);
7680                                            }
7681                                            else {
7682                                                    query.append(ORDER_BY_DESC);
7683                                            }
7684                                    }
7685                            }
7686                    }
7687    
7688                    else {
7689                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7690                    }
7691    
7692                    String sql = query.toString();
7693    
7694                    Query q = session.createQuery(sql);
7695    
7696                    q.setFirstResult(0);
7697                    q.setMaxResults(2);
7698    
7699                    QueryPos qPos = QueryPos.getInstance(q);
7700    
7701                    if (displayDate != null) {
7702                            qPos.add(CalendarUtil.getTimestamp(displayDate));
7703                    }
7704    
7705                    qPos.add(status);
7706    
7707                    if (orderByComparator != null) {
7708                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7709    
7710                            for (Object value : values) {
7711                                    qPos.add(value);
7712                            }
7713                    }
7714    
7715                    List<BlogsEntry> list = q.list();
7716    
7717                    if (list.size() == 2) {
7718                            return list.get(1);
7719                    }
7720                    else {
7721                            return null;
7722                    }
7723            }
7724    
7725            /**
7726             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
7727             *
7728             * @param companyId the company ID
7729             * @param userId the user ID
7730             * @param status the status
7731             * @return the matching blogs entries
7732             * @throws SystemException if a system exception occurred
7733             */
7734            public List<BlogsEntry> findByC_U_NeS(long companyId, long userId,
7735                    int status) throws SystemException {
7736                    return findByC_U_NeS(companyId, userId, status, QueryUtil.ALL_POS,
7737                            QueryUtil.ALL_POS, null);
7738            }
7739    
7740            /**
7741             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
7742             *
7743             * <p>
7744             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7745             * </p>
7746             *
7747             * @param companyId the company ID
7748             * @param userId the user ID
7749             * @param status the status
7750             * @param start the lower bound of the range of blogs entries
7751             * @param end the upper bound of the range of blogs entries (not inclusive)
7752             * @return the range of matching blogs entries
7753             * @throws SystemException if a system exception occurred
7754             */
7755            public List<BlogsEntry> findByC_U_NeS(long companyId, long userId,
7756                    int status, int start, int end) throws SystemException {
7757                    return findByC_U_NeS(companyId, userId, status, start, end, null);
7758            }
7759    
7760            /**
7761             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
7762             *
7763             * <p>
7764             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
7765             * </p>
7766             *
7767             * @param companyId the company ID
7768             * @param userId the user ID
7769             * @param status the status
7770             * @param start the lower bound of the range of blogs entries
7771             * @param end the upper bound of the range of blogs entries (not inclusive)
7772             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7773             * @return the ordered range of matching blogs entries
7774             * @throws SystemException if a system exception occurred
7775             */
7776            public List<BlogsEntry> findByC_U_NeS(long companyId, long userId,
7777                    int status, int start, int end, OrderByComparator orderByComparator)
7778                    throws SystemException {
7779                    FinderPath finderPath = null;
7780                    Object[] finderArgs = null;
7781    
7782                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NES;
7783                    finderArgs = new Object[] {
7784                                    companyId, userId, status,
7785                                    
7786                                    start, end, orderByComparator
7787                            };
7788    
7789                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7790                                    finderArgs, this);
7791    
7792                    if ((list != null) && !list.isEmpty()) {
7793                            for (BlogsEntry blogsEntry : list) {
7794                                    if ((companyId != blogsEntry.getCompanyId()) ||
7795                                                    (userId != blogsEntry.getUserId()) ||
7796                                                    (status != blogsEntry.getStatus())) {
7797                                            list = null;
7798    
7799                                            break;
7800                                    }
7801                            }
7802                    }
7803    
7804                    if (list == null) {
7805                            StringBundler query = null;
7806    
7807                            if (orderByComparator != null) {
7808                                    query = new StringBundler(5 +
7809                                                    (orderByComparator.getOrderByFields().length * 3));
7810                            }
7811                            else {
7812                                    query = new StringBundler(5);
7813                            }
7814    
7815                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7816    
7817                            query.append(_FINDER_COLUMN_C_U_NES_COMPANYID_2);
7818    
7819                            query.append(_FINDER_COLUMN_C_U_NES_USERID_2);
7820    
7821                            query.append(_FINDER_COLUMN_C_U_NES_STATUS_2);
7822    
7823                            if (orderByComparator != null) {
7824                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7825                                            orderByComparator);
7826                            }
7827    
7828                            else {
7829                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7830                            }
7831    
7832                            String sql = query.toString();
7833    
7834                            Session session = null;
7835    
7836                            try {
7837                                    session = openSession();
7838    
7839                                    Query q = session.createQuery(sql);
7840    
7841                                    QueryPos qPos = QueryPos.getInstance(q);
7842    
7843                                    qPos.add(companyId);
7844    
7845                                    qPos.add(userId);
7846    
7847                                    qPos.add(status);
7848    
7849                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
7850                                                    end);
7851                            }
7852                            catch (Exception e) {
7853                                    throw processException(e);
7854                            }
7855                            finally {
7856                                    if (list == null) {
7857                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7858                                    }
7859                                    else {
7860                                            cacheResult(list);
7861    
7862                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7863                                    }
7864    
7865                                    closeSession(session);
7866                            }
7867                    }
7868    
7869                    return list;
7870            }
7871    
7872            /**
7873             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
7874             *
7875             * @param companyId the company ID
7876             * @param userId the user ID
7877             * @param status the status
7878             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7879             * @return the first matching blogs entry
7880             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7881             * @throws SystemException if a system exception occurred
7882             */
7883            public BlogsEntry findByC_U_NeS_First(long companyId, long userId,
7884                    int status, OrderByComparator orderByComparator)
7885                    throws NoSuchEntryException, SystemException {
7886                    BlogsEntry blogsEntry = fetchByC_U_NeS_First(companyId, userId, status,
7887                                    orderByComparator);
7888    
7889                    if (blogsEntry != null) {
7890                            return blogsEntry;
7891                    }
7892    
7893                    StringBundler msg = new StringBundler(8);
7894    
7895                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7896    
7897                    msg.append("companyId=");
7898                    msg.append(companyId);
7899    
7900                    msg.append(", userId=");
7901                    msg.append(userId);
7902    
7903                    msg.append(", status=");
7904                    msg.append(status);
7905    
7906                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7907    
7908                    throw new NoSuchEntryException(msg.toString());
7909            }
7910    
7911            /**
7912             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
7913             *
7914             * @param companyId the company ID
7915             * @param userId the user ID
7916             * @param status the status
7917             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7918             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7919             * @throws SystemException if a system exception occurred
7920             */
7921            public BlogsEntry fetchByC_U_NeS_First(long companyId, long userId,
7922                    int status, OrderByComparator orderByComparator)
7923                    throws SystemException {
7924                    List<BlogsEntry> list = findByC_U_NeS(companyId, userId, status, 0, 1,
7925                                    orderByComparator);
7926    
7927                    if (!list.isEmpty()) {
7928                            return list.get(0);
7929                    }
7930    
7931                    return null;
7932            }
7933    
7934            /**
7935             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
7936             *
7937             * @param companyId the company ID
7938             * @param userId the user ID
7939             * @param status the status
7940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7941             * @return the last matching blogs entry
7942             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7943             * @throws SystemException if a system exception occurred
7944             */
7945            public BlogsEntry findByC_U_NeS_Last(long companyId, long userId,
7946                    int status, OrderByComparator orderByComparator)
7947                    throws NoSuchEntryException, SystemException {
7948                    BlogsEntry blogsEntry = fetchByC_U_NeS_Last(companyId, userId, status,
7949                                    orderByComparator);
7950    
7951                    if (blogsEntry != null) {
7952                            return blogsEntry;
7953                    }
7954    
7955                    StringBundler msg = new StringBundler(8);
7956    
7957                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7958    
7959                    msg.append("companyId=");
7960                    msg.append(companyId);
7961    
7962                    msg.append(", userId=");
7963                    msg.append(userId);
7964    
7965                    msg.append(", status=");
7966                    msg.append(status);
7967    
7968                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7969    
7970                    throw new NoSuchEntryException(msg.toString());
7971            }
7972    
7973            /**
7974             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
7975             *
7976             * @param companyId the company ID
7977             * @param userId the user ID
7978             * @param status the status
7979             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7980             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7981             * @throws SystemException if a system exception occurred
7982             */
7983            public BlogsEntry fetchByC_U_NeS_Last(long companyId, long userId,
7984                    int status, OrderByComparator orderByComparator)
7985                    throws SystemException {
7986                    int count = countByC_U_NeS(companyId, userId, status);
7987    
7988                    List<BlogsEntry> list = findByC_U_NeS(companyId, userId, status,
7989                                    count - 1, count, orderByComparator);
7990    
7991                    if (!list.isEmpty()) {
7992                            return list.get(0);
7993                    }
7994    
7995                    return null;
7996            }
7997    
7998            /**
7999             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8000             *
8001             * @param entryId the primary key of the current blogs entry
8002             * @param companyId the company ID
8003             * @param userId the user ID
8004             * @param status the status
8005             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8006             * @return the previous, current, and next blogs entry
8007             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8008             * @throws SystemException if a system exception occurred
8009             */
8010            public BlogsEntry[] findByC_U_NeS_PrevAndNext(long entryId, long companyId,
8011                    long userId, int status, OrderByComparator orderByComparator)
8012                    throws NoSuchEntryException, SystemException {
8013                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8014    
8015                    Session session = null;
8016    
8017                    try {
8018                            session = openSession();
8019    
8020                            BlogsEntry[] array = new BlogsEntryImpl[3];
8021    
8022                            array[0] = getByC_U_NeS_PrevAndNext(session, blogsEntry, companyId,
8023                                            userId, status, orderByComparator, true);
8024    
8025                            array[1] = blogsEntry;
8026    
8027                            array[2] = getByC_U_NeS_PrevAndNext(session, blogsEntry, companyId,
8028                                            userId, status, orderByComparator, false);
8029    
8030                            return array;
8031                    }
8032                    catch (Exception e) {
8033                            throw processException(e);
8034                    }
8035                    finally {
8036                            closeSession(session);
8037                    }
8038            }
8039    
8040            protected BlogsEntry getByC_U_NeS_PrevAndNext(Session session,
8041                    BlogsEntry blogsEntry, long companyId, long userId, int status,
8042                    OrderByComparator orderByComparator, boolean previous) {
8043                    StringBundler query = null;
8044    
8045                    if (orderByComparator != null) {
8046                            query = new StringBundler(6 +
8047                                            (orderByComparator.getOrderByFields().length * 6));
8048                    }
8049                    else {
8050                            query = new StringBundler(3);
8051                    }
8052    
8053                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8054    
8055                    query.append(_FINDER_COLUMN_C_U_NES_COMPANYID_2);
8056    
8057                    query.append(_FINDER_COLUMN_C_U_NES_USERID_2);
8058    
8059                    query.append(_FINDER_COLUMN_C_U_NES_STATUS_2);
8060    
8061                    if (orderByComparator != null) {
8062                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8063    
8064                            if (orderByConditionFields.length > 0) {
8065                                    query.append(WHERE_AND);
8066                            }
8067    
8068                            for (int i = 0; i < orderByConditionFields.length; i++) {
8069                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8070                                    query.append(orderByConditionFields[i]);
8071    
8072                                    if ((i + 1) < orderByConditionFields.length) {
8073                                            if (orderByComparator.isAscending() ^ previous) {
8074                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8075                                            }
8076                                            else {
8077                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8078                                            }
8079                                    }
8080                                    else {
8081                                            if (orderByComparator.isAscending() ^ previous) {
8082                                                    query.append(WHERE_GREATER_THAN);
8083                                            }
8084                                            else {
8085                                                    query.append(WHERE_LESSER_THAN);
8086                                            }
8087                                    }
8088                            }
8089    
8090                            query.append(ORDER_BY_CLAUSE);
8091    
8092                            String[] orderByFields = orderByComparator.getOrderByFields();
8093    
8094                            for (int i = 0; i < orderByFields.length; i++) {
8095                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8096                                    query.append(orderByFields[i]);
8097    
8098                                    if ((i + 1) < orderByFields.length) {
8099                                            if (orderByComparator.isAscending() ^ previous) {
8100                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8101                                            }
8102                                            else {
8103                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8104                                            }
8105                                    }
8106                                    else {
8107                                            if (orderByComparator.isAscending() ^ previous) {
8108                                                    query.append(ORDER_BY_ASC);
8109                                            }
8110                                            else {
8111                                                    query.append(ORDER_BY_DESC);
8112                                            }
8113                                    }
8114                            }
8115                    }
8116    
8117                    else {
8118                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8119                    }
8120    
8121                    String sql = query.toString();
8122    
8123                    Query q = session.createQuery(sql);
8124    
8125                    q.setFirstResult(0);
8126                    q.setMaxResults(2);
8127    
8128                    QueryPos qPos = QueryPos.getInstance(q);
8129    
8130                    qPos.add(companyId);
8131    
8132                    qPos.add(userId);
8133    
8134                    qPos.add(status);
8135    
8136                    if (orderByComparator != null) {
8137                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8138    
8139                            for (Object value : values) {
8140                                    qPos.add(value);
8141                            }
8142                    }
8143    
8144                    List<BlogsEntry> list = q.list();
8145    
8146                    if (list.size() == 2) {
8147                            return list.get(1);
8148                    }
8149                    else {
8150                            return null;
8151                    }
8152            }
8153    
8154            /**
8155             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
8156             *
8157             * @param companyId the company ID
8158             * @param userId the user ID
8159             * @param status the status
8160             * @return the matching blogs entries
8161             * @throws SystemException if a system exception occurred
8162             */
8163            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status)
8164                    throws SystemException {
8165                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
8166                            QueryUtil.ALL_POS, null);
8167            }
8168    
8169            /**
8170             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
8171             *
8172             * <p>
8173             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8174             * </p>
8175             *
8176             * @param companyId the company ID
8177             * @param userId the user ID
8178             * @param status the status
8179             * @param start the lower bound of the range of blogs entries
8180             * @param end the upper bound of the range of blogs entries (not inclusive)
8181             * @return the range of matching blogs entries
8182             * @throws SystemException if a system exception occurred
8183             */
8184            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
8185                    int status, int start, int end) throws SystemException {
8186                    return findByC_U_S(companyId, userId, status, start, end, null);
8187            }
8188    
8189            /**
8190             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
8191             *
8192             * <p>
8193             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8194             * </p>
8195             *
8196             * @param companyId the company ID
8197             * @param userId the user ID
8198             * @param status the status
8199             * @param start the lower bound of the range of blogs entries
8200             * @param end the upper bound of the range of blogs entries (not inclusive)
8201             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8202             * @return the ordered range of matching blogs entries
8203             * @throws SystemException if a system exception occurred
8204             */
8205            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
8206                    int status, int start, int end, OrderByComparator orderByComparator)
8207                    throws SystemException {
8208                    FinderPath finderPath = null;
8209                    Object[] finderArgs = null;
8210    
8211                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8212                                    (orderByComparator == null)) {
8213                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
8214                            finderArgs = new Object[] { companyId, userId, status };
8215                    }
8216                    else {
8217                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
8218                            finderArgs = new Object[] {
8219                                            companyId, userId, status,
8220                                            
8221                                            start, end, orderByComparator
8222                                    };
8223                    }
8224    
8225                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8226                                    finderArgs, this);
8227    
8228                    if ((list != null) && !list.isEmpty()) {
8229                            for (BlogsEntry blogsEntry : list) {
8230                                    if ((companyId != blogsEntry.getCompanyId()) ||
8231                                                    (userId != blogsEntry.getUserId()) ||
8232                                                    (status != blogsEntry.getStatus())) {
8233                                            list = null;
8234    
8235                                            break;
8236                                    }
8237                            }
8238                    }
8239    
8240                    if (list == null) {
8241                            StringBundler query = null;
8242    
8243                            if (orderByComparator != null) {
8244                                    query = new StringBundler(5 +
8245                                                    (orderByComparator.getOrderByFields().length * 3));
8246                            }
8247                            else {
8248                                    query = new StringBundler(5);
8249                            }
8250    
8251                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8252    
8253                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
8254    
8255                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
8256    
8257                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
8258    
8259                            if (orderByComparator != null) {
8260                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8261                                            orderByComparator);
8262                            }
8263    
8264                            else {
8265                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8266                            }
8267    
8268                            String sql = query.toString();
8269    
8270                            Session session = null;
8271    
8272                            try {
8273                                    session = openSession();
8274    
8275                                    Query q = session.createQuery(sql);
8276    
8277                                    QueryPos qPos = QueryPos.getInstance(q);
8278    
8279                                    qPos.add(companyId);
8280    
8281                                    qPos.add(userId);
8282    
8283                                    qPos.add(status);
8284    
8285                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
8286                                                    end);
8287                            }
8288                            catch (Exception e) {
8289                                    throw processException(e);
8290                            }
8291                            finally {
8292                                    if (list == null) {
8293                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8294                                    }
8295                                    else {
8296                                            cacheResult(list);
8297    
8298                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8299                                    }
8300    
8301                                    closeSession(session);
8302                            }
8303                    }
8304    
8305                    return list;
8306            }
8307    
8308            /**
8309             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
8310             *
8311             * @param companyId the company ID
8312             * @param userId the user ID
8313             * @param status the status
8314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8315             * @return the first matching blogs entry
8316             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8317             * @throws SystemException if a system exception occurred
8318             */
8319            public BlogsEntry findByC_U_S_First(long companyId, long userId,
8320                    int status, OrderByComparator orderByComparator)
8321                    throws NoSuchEntryException, SystemException {
8322                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
8323                                    orderByComparator);
8324    
8325                    if (blogsEntry != null) {
8326                            return blogsEntry;
8327                    }
8328    
8329                    StringBundler msg = new StringBundler(8);
8330    
8331                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8332    
8333                    msg.append("companyId=");
8334                    msg.append(companyId);
8335    
8336                    msg.append(", userId=");
8337                    msg.append(userId);
8338    
8339                    msg.append(", status=");
8340                    msg.append(status);
8341    
8342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8343    
8344                    throw new NoSuchEntryException(msg.toString());
8345            }
8346    
8347            /**
8348             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
8349             *
8350             * @param companyId the company ID
8351             * @param userId the user ID
8352             * @param status the status
8353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8354             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8355             * @throws SystemException if a system exception occurred
8356             */
8357            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
8358                    int status, OrderByComparator orderByComparator)
8359                    throws SystemException {
8360                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
8361                                    orderByComparator);
8362    
8363                    if (!list.isEmpty()) {
8364                            return list.get(0);
8365                    }
8366    
8367                    return null;
8368            }
8369    
8370            /**
8371             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
8372             *
8373             * @param companyId the company ID
8374             * @param userId the user ID
8375             * @param status the status
8376             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8377             * @return the last matching blogs entry
8378             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8379             * @throws SystemException if a system exception occurred
8380             */
8381            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
8382                    OrderByComparator orderByComparator)
8383                    throws NoSuchEntryException, SystemException {
8384                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
8385                                    orderByComparator);
8386    
8387                    if (blogsEntry != null) {
8388                            return blogsEntry;
8389                    }
8390    
8391                    StringBundler msg = new StringBundler(8);
8392    
8393                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8394    
8395                    msg.append("companyId=");
8396                    msg.append(companyId);
8397    
8398                    msg.append(", userId=");
8399                    msg.append(userId);
8400    
8401                    msg.append(", status=");
8402                    msg.append(status);
8403    
8404                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8405    
8406                    throw new NoSuchEntryException(msg.toString());
8407            }
8408    
8409            /**
8410             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
8411             *
8412             * @param companyId the company ID
8413             * @param userId the user ID
8414             * @param status the status
8415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8416             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8417             * @throws SystemException if a system exception occurred
8418             */
8419            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
8420                    int status, OrderByComparator orderByComparator)
8421                    throws SystemException {
8422                    int count = countByC_U_S(companyId, userId, status);
8423    
8424                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
8425                                    count - 1, count, orderByComparator);
8426    
8427                    if (!list.isEmpty()) {
8428                            return list.get(0);
8429                    }
8430    
8431                    return null;
8432            }
8433    
8434            /**
8435             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
8436             *
8437             * @param entryId the primary key of the current blogs entry
8438             * @param companyId the company ID
8439             * @param userId the user ID
8440             * @param status the status
8441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8442             * @return the previous, current, and next blogs entry
8443             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8444             * @throws SystemException if a system exception occurred
8445             */
8446            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
8447                    long userId, int status, OrderByComparator orderByComparator)
8448                    throws NoSuchEntryException, SystemException {
8449                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8450    
8451                    Session session = null;
8452    
8453                    try {
8454                            session = openSession();
8455    
8456                            BlogsEntry[] array = new BlogsEntryImpl[3];
8457    
8458                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
8459                                            userId, status, orderByComparator, true);
8460    
8461                            array[1] = blogsEntry;
8462    
8463                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
8464                                            userId, status, orderByComparator, false);
8465    
8466                            return array;
8467                    }
8468                    catch (Exception e) {
8469                            throw processException(e);
8470                    }
8471                    finally {
8472                            closeSession(session);
8473                    }
8474            }
8475    
8476            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
8477                    BlogsEntry blogsEntry, long companyId, long userId, int status,
8478                    OrderByComparator orderByComparator, boolean previous) {
8479                    StringBundler query = null;
8480    
8481                    if (orderByComparator != null) {
8482                            query = new StringBundler(6 +
8483                                            (orderByComparator.getOrderByFields().length * 6));
8484                    }
8485                    else {
8486                            query = new StringBundler(3);
8487                    }
8488    
8489                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8490    
8491                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
8492    
8493                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
8494    
8495                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
8496    
8497                    if (orderByComparator != null) {
8498                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8499    
8500                            if (orderByConditionFields.length > 0) {
8501                                    query.append(WHERE_AND);
8502                            }
8503    
8504                            for (int i = 0; i < orderByConditionFields.length; i++) {
8505                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8506                                    query.append(orderByConditionFields[i]);
8507    
8508                                    if ((i + 1) < orderByConditionFields.length) {
8509                                            if (orderByComparator.isAscending() ^ previous) {
8510                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8511                                            }
8512                                            else {
8513                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8514                                            }
8515                                    }
8516                                    else {
8517                                            if (orderByComparator.isAscending() ^ previous) {
8518                                                    query.append(WHERE_GREATER_THAN);
8519                                            }
8520                                            else {
8521                                                    query.append(WHERE_LESSER_THAN);
8522                                            }
8523                                    }
8524                            }
8525    
8526                            query.append(ORDER_BY_CLAUSE);
8527    
8528                            String[] orderByFields = orderByComparator.getOrderByFields();
8529    
8530                            for (int i = 0; i < orderByFields.length; i++) {
8531                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8532                                    query.append(orderByFields[i]);
8533    
8534                                    if ((i + 1) < orderByFields.length) {
8535                                            if (orderByComparator.isAscending() ^ previous) {
8536                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8537                                            }
8538                                            else {
8539                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8540                                            }
8541                                    }
8542                                    else {
8543                                            if (orderByComparator.isAscending() ^ previous) {
8544                                                    query.append(ORDER_BY_ASC);
8545                                            }
8546                                            else {
8547                                                    query.append(ORDER_BY_DESC);
8548                                            }
8549                                    }
8550                            }
8551                    }
8552    
8553                    else {
8554                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8555                    }
8556    
8557                    String sql = query.toString();
8558    
8559                    Query q = session.createQuery(sql);
8560    
8561                    q.setFirstResult(0);
8562                    q.setMaxResults(2);
8563    
8564                    QueryPos qPos = QueryPos.getInstance(q);
8565    
8566                    qPos.add(companyId);
8567    
8568                    qPos.add(userId);
8569    
8570                    qPos.add(status);
8571    
8572                    if (orderByComparator != null) {
8573                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8574    
8575                            for (Object value : values) {
8576                                    qPos.add(value);
8577                            }
8578                    }
8579    
8580                    List<BlogsEntry> list = q.list();
8581    
8582                    if (list.size() == 2) {
8583                            return list.get(1);
8584                    }
8585                    else {
8586                            return null;
8587                    }
8588            }
8589    
8590            /**
8591             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8592             *
8593             * @param companyId the company ID
8594             * @param displayDate the display date
8595             * @param status the status
8596             * @return the matching blogs entries
8597             * @throws SystemException if a system exception occurred
8598             */
8599            public List<BlogsEntry> findByC_LtD_NeS(long companyId, Date displayDate,
8600                    int status) throws SystemException {
8601                    return findByC_LtD_NeS(companyId, displayDate, status,
8602                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8603            }
8604    
8605            /**
8606             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8607             *
8608             * <p>
8609             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8610             * </p>
8611             *
8612             * @param companyId the company ID
8613             * @param displayDate the display date
8614             * @param status the status
8615             * @param start the lower bound of the range of blogs entries
8616             * @param end the upper bound of the range of blogs entries (not inclusive)
8617             * @return the range of matching blogs entries
8618             * @throws SystemException if a system exception occurred
8619             */
8620            public List<BlogsEntry> findByC_LtD_NeS(long companyId, Date displayDate,
8621                    int status, int start, int end) throws SystemException {
8622                    return findByC_LtD_NeS(companyId, displayDate, status, start, end, null);
8623            }
8624    
8625            /**
8626             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8627             *
8628             * <p>
8629             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
8630             * </p>
8631             *
8632             * @param companyId the company ID
8633             * @param displayDate the display date
8634             * @param status the status
8635             * @param start the lower bound of the range of blogs entries
8636             * @param end the upper bound of the range of blogs entries (not inclusive)
8637             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8638             * @return the ordered range of matching blogs entries
8639             * @throws SystemException if a system exception occurred
8640             */
8641            public List<BlogsEntry> findByC_LtD_NeS(long companyId, Date displayDate,
8642                    int status, int start, int end, OrderByComparator orderByComparator)
8643                    throws SystemException {
8644                    FinderPath finderPath = null;
8645                    Object[] finderArgs = null;
8646    
8647                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NES;
8648                    finderArgs = new Object[] {
8649                                    companyId, displayDate, status,
8650                                    
8651                                    start, end, orderByComparator
8652                            };
8653    
8654                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8655                                    finderArgs, this);
8656    
8657                    if ((list != null) && !list.isEmpty()) {
8658                            for (BlogsEntry blogsEntry : list) {
8659                                    if ((companyId != blogsEntry.getCompanyId()) ||
8660                                                    !Validator.equals(displayDate,
8661                                                            blogsEntry.getDisplayDate()) ||
8662                                                    (status != blogsEntry.getStatus())) {
8663                                            list = null;
8664    
8665                                            break;
8666                                    }
8667                            }
8668                    }
8669    
8670                    if (list == null) {
8671                            StringBundler query = null;
8672    
8673                            if (orderByComparator != null) {
8674                                    query = new StringBundler(5 +
8675                                                    (orderByComparator.getOrderByFields().length * 3));
8676                            }
8677                            else {
8678                                    query = new StringBundler(5);
8679                            }
8680    
8681                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8682    
8683                            query.append(_FINDER_COLUMN_C_LTD_NES_COMPANYID_2);
8684    
8685                            if (displayDate == null) {
8686                                    query.append(_FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_1);
8687                            }
8688                            else {
8689                                    query.append(_FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_2);
8690                            }
8691    
8692                            query.append(_FINDER_COLUMN_C_LTD_NES_STATUS_2);
8693    
8694                            if (orderByComparator != null) {
8695                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8696                                            orderByComparator);
8697                            }
8698    
8699                            else {
8700                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8701                            }
8702    
8703                            String sql = query.toString();
8704    
8705                            Session session = null;
8706    
8707                            try {
8708                                    session = openSession();
8709    
8710                                    Query q = session.createQuery(sql);
8711    
8712                                    QueryPos qPos = QueryPos.getInstance(q);
8713    
8714                                    qPos.add(companyId);
8715    
8716                                    if (displayDate != null) {
8717                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8718                                    }
8719    
8720                                    qPos.add(status);
8721    
8722                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
8723                                                    end);
8724                            }
8725                            catch (Exception e) {
8726                                    throw processException(e);
8727                            }
8728                            finally {
8729                                    if (list == null) {
8730                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8731                                    }
8732                                    else {
8733                                            cacheResult(list);
8734    
8735                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8736                                    }
8737    
8738                                    closeSession(session);
8739                            }
8740                    }
8741    
8742                    return list;
8743            }
8744    
8745            /**
8746             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8747             *
8748             * @param companyId the company ID
8749             * @param displayDate the display date
8750             * @param status the status
8751             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8752             * @return the first matching blogs entry
8753             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8754             * @throws SystemException if a system exception occurred
8755             */
8756            public BlogsEntry findByC_LtD_NeS_First(long companyId, Date displayDate,
8757                    int status, OrderByComparator orderByComparator)
8758                    throws NoSuchEntryException, SystemException {
8759                    BlogsEntry blogsEntry = fetchByC_LtD_NeS_First(companyId, displayDate,
8760                                    status, orderByComparator);
8761    
8762                    if (blogsEntry != null) {
8763                            return blogsEntry;
8764                    }
8765    
8766                    StringBundler msg = new StringBundler(8);
8767    
8768                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8769    
8770                    msg.append("companyId=");
8771                    msg.append(companyId);
8772    
8773                    msg.append(", displayDate=");
8774                    msg.append(displayDate);
8775    
8776                    msg.append(", status=");
8777                    msg.append(status);
8778    
8779                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8780    
8781                    throw new NoSuchEntryException(msg.toString());
8782            }
8783    
8784            /**
8785             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8786             *
8787             * @param companyId the company ID
8788             * @param displayDate the display date
8789             * @param status the status
8790             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8791             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8792             * @throws SystemException if a system exception occurred
8793             */
8794            public BlogsEntry fetchByC_LtD_NeS_First(long companyId, Date displayDate,
8795                    int status, OrderByComparator orderByComparator)
8796                    throws SystemException {
8797                    List<BlogsEntry> list = findByC_LtD_NeS(companyId, displayDate, status,
8798                                    0, 1, orderByComparator);
8799    
8800                    if (!list.isEmpty()) {
8801                            return list.get(0);
8802                    }
8803    
8804                    return null;
8805            }
8806    
8807            /**
8808             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8809             *
8810             * @param companyId the company ID
8811             * @param displayDate the display date
8812             * @param status the status
8813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8814             * @return the last matching blogs entry
8815             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8816             * @throws SystemException if a system exception occurred
8817             */
8818            public BlogsEntry findByC_LtD_NeS_Last(long companyId, Date displayDate,
8819                    int status, OrderByComparator orderByComparator)
8820                    throws NoSuchEntryException, SystemException {
8821                    BlogsEntry blogsEntry = fetchByC_LtD_NeS_Last(companyId, displayDate,
8822                                    status, orderByComparator);
8823    
8824                    if (blogsEntry != null) {
8825                            return blogsEntry;
8826                    }
8827    
8828                    StringBundler msg = new StringBundler(8);
8829    
8830                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8831    
8832                    msg.append("companyId=");
8833                    msg.append(companyId);
8834    
8835                    msg.append(", displayDate=");
8836                    msg.append(displayDate);
8837    
8838                    msg.append(", status=");
8839                    msg.append(status);
8840    
8841                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8842    
8843                    throw new NoSuchEntryException(msg.toString());
8844            }
8845    
8846            /**
8847             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8848             *
8849             * @param companyId the company ID
8850             * @param displayDate the display date
8851             * @param status the status
8852             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8853             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8854             * @throws SystemException if a system exception occurred
8855             */
8856            public BlogsEntry fetchByC_LtD_NeS_Last(long companyId, Date displayDate,
8857                    int status, OrderByComparator orderByComparator)
8858                    throws SystemException {
8859                    int count = countByC_LtD_NeS(companyId, displayDate, status);
8860    
8861                    List<BlogsEntry> list = findByC_LtD_NeS(companyId, displayDate, status,
8862                                    count - 1, count, orderByComparator);
8863    
8864                    if (!list.isEmpty()) {
8865                            return list.get(0);
8866                    }
8867    
8868                    return null;
8869            }
8870    
8871            /**
8872             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
8873             *
8874             * @param entryId the primary key of the current blogs entry
8875             * @param companyId the company ID
8876             * @param displayDate the display date
8877             * @param status the status
8878             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8879             * @return the previous, current, and next blogs entry
8880             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8881             * @throws SystemException if a system exception occurred
8882             */
8883            public BlogsEntry[] findByC_LtD_NeS_PrevAndNext(long entryId,
8884                    long companyId, Date displayDate, int status,
8885                    OrderByComparator orderByComparator)
8886                    throws NoSuchEntryException, SystemException {
8887                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8888    
8889                    Session session = null;
8890    
8891                    try {
8892                            session = openSession();
8893    
8894                            BlogsEntry[] array = new BlogsEntryImpl[3];
8895    
8896                            array[0] = getByC_LtD_NeS_PrevAndNext(session, blogsEntry,
8897                                            companyId, displayDate, status, orderByComparator, true);
8898    
8899                            array[1] = blogsEntry;
8900    
8901                            array[2] = getByC_LtD_NeS_PrevAndNext(session, blogsEntry,
8902                                            companyId, displayDate, status, orderByComparator, false);
8903    
8904                            return array;
8905                    }
8906                    catch (Exception e) {
8907                            throw processException(e);
8908                    }
8909                    finally {
8910                            closeSession(session);
8911                    }
8912            }
8913    
8914            protected BlogsEntry getByC_LtD_NeS_PrevAndNext(Session session,
8915                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
8916                    OrderByComparator orderByComparator, boolean previous) {
8917                    StringBundler query = null;
8918    
8919                    if (orderByComparator != null) {
8920                            query = new StringBundler(6 +
8921                                            (orderByComparator.getOrderByFields().length * 6));
8922                    }
8923                    else {
8924                            query = new StringBundler(3);
8925                    }
8926    
8927                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8928    
8929                    query.append(_FINDER_COLUMN_C_LTD_NES_COMPANYID_2);
8930    
8931                    if (displayDate == null) {
8932                            query.append(_FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_1);
8933                    }
8934                    else {
8935                            query.append(_FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_2);
8936                    }
8937    
8938                    query.append(_FINDER_COLUMN_C_LTD_NES_STATUS_2);
8939    
8940                    if (orderByComparator != null) {
8941                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8942    
8943                            if (orderByConditionFields.length > 0) {
8944                                    query.append(WHERE_AND);
8945                            }
8946    
8947                            for (int i = 0; i < orderByConditionFields.length; i++) {
8948                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8949                                    query.append(orderByConditionFields[i]);
8950    
8951                                    if ((i + 1) < orderByConditionFields.length) {
8952                                            if (orderByComparator.isAscending() ^ previous) {
8953                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8954                                            }
8955                                            else {
8956                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8957                                            }
8958                                    }
8959                                    else {
8960                                            if (orderByComparator.isAscending() ^ previous) {
8961                                                    query.append(WHERE_GREATER_THAN);
8962                                            }
8963                                            else {
8964                                                    query.append(WHERE_LESSER_THAN);
8965                                            }
8966                                    }
8967                            }
8968    
8969                            query.append(ORDER_BY_CLAUSE);
8970    
8971                            String[] orderByFields = orderByComparator.getOrderByFields();
8972    
8973                            for (int i = 0; i < orderByFields.length; i++) {
8974                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8975                                    query.append(orderByFields[i]);
8976    
8977                                    if ((i + 1) < orderByFields.length) {
8978                                            if (orderByComparator.isAscending() ^ previous) {
8979                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8980                                            }
8981                                            else {
8982                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8983                                            }
8984                                    }
8985                                    else {
8986                                            if (orderByComparator.isAscending() ^ previous) {
8987                                                    query.append(ORDER_BY_ASC);
8988                                            }
8989                                            else {
8990                                                    query.append(ORDER_BY_DESC);
8991                                            }
8992                                    }
8993                            }
8994                    }
8995    
8996                    else {
8997                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8998                    }
8999    
9000                    String sql = query.toString();
9001    
9002                    Query q = session.createQuery(sql);
9003    
9004                    q.setFirstResult(0);
9005                    q.setMaxResults(2);
9006    
9007                    QueryPos qPos = QueryPos.getInstance(q);
9008    
9009                    qPos.add(companyId);
9010    
9011                    if (displayDate != null) {
9012                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9013                    }
9014    
9015                    qPos.add(status);
9016    
9017                    if (orderByComparator != null) {
9018                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9019    
9020                            for (Object value : values) {
9021                                    qPos.add(value);
9022                            }
9023                    }
9024    
9025                    List<BlogsEntry> list = q.list();
9026    
9027                    if (list.size() == 2) {
9028                            return list.get(1);
9029                    }
9030                    else {
9031                            return null;
9032                    }
9033            }
9034    
9035            /**
9036             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9037             *
9038             * @param companyId the company ID
9039             * @param displayDate the display date
9040             * @param status the status
9041             * @return the matching blogs entries
9042             * @throws SystemException if a system exception occurred
9043             */
9044            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
9045                    int status) throws SystemException {
9046                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
9047                            QueryUtil.ALL_POS, null);
9048            }
9049    
9050            /**
9051             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9052             *
9053             * <p>
9054             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9055             * </p>
9056             *
9057             * @param companyId the company ID
9058             * @param displayDate the display date
9059             * @param status the status
9060             * @param start the lower bound of the range of blogs entries
9061             * @param end the upper bound of the range of blogs entries (not inclusive)
9062             * @return the range of matching blogs entries
9063             * @throws SystemException if a system exception occurred
9064             */
9065            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
9066                    int status, int start, int end) throws SystemException {
9067                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
9068            }
9069    
9070            /**
9071             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9072             *
9073             * <p>
9074             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9075             * </p>
9076             *
9077             * @param companyId the company ID
9078             * @param displayDate the display date
9079             * @param status the status
9080             * @param start the lower bound of the range of blogs entries
9081             * @param end the upper bound of the range of blogs entries (not inclusive)
9082             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9083             * @return the ordered range of matching blogs entries
9084             * @throws SystemException if a system exception occurred
9085             */
9086            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
9087                    int status, int start, int end, OrderByComparator orderByComparator)
9088                    throws SystemException {
9089                    FinderPath finderPath = null;
9090                    Object[] finderArgs = null;
9091    
9092                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
9093                    finderArgs = new Object[] {
9094                                    companyId, displayDate, status,
9095                                    
9096                                    start, end, orderByComparator
9097                            };
9098    
9099                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9100                                    finderArgs, this);
9101    
9102                    if ((list != null) && !list.isEmpty()) {
9103                            for (BlogsEntry blogsEntry : list) {
9104                                    if ((companyId != blogsEntry.getCompanyId()) ||
9105                                                    !Validator.equals(displayDate,
9106                                                            blogsEntry.getDisplayDate()) ||
9107                                                    (status != blogsEntry.getStatus())) {
9108                                            list = null;
9109    
9110                                            break;
9111                                    }
9112                            }
9113                    }
9114    
9115                    if (list == null) {
9116                            StringBundler query = null;
9117    
9118                            if (orderByComparator != null) {
9119                                    query = new StringBundler(5 +
9120                                                    (orderByComparator.getOrderByFields().length * 3));
9121                            }
9122                            else {
9123                                    query = new StringBundler(5);
9124                            }
9125    
9126                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9127    
9128                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
9129    
9130                            if (displayDate == null) {
9131                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
9132                            }
9133                            else {
9134                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
9135                            }
9136    
9137                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
9138    
9139                            if (orderByComparator != null) {
9140                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9141                                            orderByComparator);
9142                            }
9143    
9144                            else {
9145                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9146                            }
9147    
9148                            String sql = query.toString();
9149    
9150                            Session session = null;
9151    
9152                            try {
9153                                    session = openSession();
9154    
9155                                    Query q = session.createQuery(sql);
9156    
9157                                    QueryPos qPos = QueryPos.getInstance(q);
9158    
9159                                    qPos.add(companyId);
9160    
9161                                    if (displayDate != null) {
9162                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9163                                    }
9164    
9165                                    qPos.add(status);
9166    
9167                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
9168                                                    end);
9169                            }
9170                            catch (Exception e) {
9171                                    throw processException(e);
9172                            }
9173                            finally {
9174                                    if (list == null) {
9175                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9176                                    }
9177                                    else {
9178                                            cacheResult(list);
9179    
9180                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9181                                    }
9182    
9183                                    closeSession(session);
9184                            }
9185                    }
9186    
9187                    return list;
9188            }
9189    
9190            /**
9191             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9192             *
9193             * @param companyId the company ID
9194             * @param displayDate the display date
9195             * @param status the status
9196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9197             * @return the first matching blogs entry
9198             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9199             * @throws SystemException if a system exception occurred
9200             */
9201            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
9202                    int status, OrderByComparator orderByComparator)
9203                    throws NoSuchEntryException, SystemException {
9204                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
9205                                    status, orderByComparator);
9206    
9207                    if (blogsEntry != null) {
9208                            return blogsEntry;
9209                    }
9210    
9211                    StringBundler msg = new StringBundler(8);
9212    
9213                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9214    
9215                    msg.append("companyId=");
9216                    msg.append(companyId);
9217    
9218                    msg.append(", displayDate=");
9219                    msg.append(displayDate);
9220    
9221                    msg.append(", status=");
9222                    msg.append(status);
9223    
9224                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9225    
9226                    throw new NoSuchEntryException(msg.toString());
9227            }
9228    
9229            /**
9230             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9231             *
9232             * @param companyId the company ID
9233             * @param displayDate the display date
9234             * @param status the status
9235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9236             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9237             * @throws SystemException if a system exception occurred
9238             */
9239            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
9240                    int status, OrderByComparator orderByComparator)
9241                    throws SystemException {
9242                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
9243                                    0, 1, orderByComparator);
9244    
9245                    if (!list.isEmpty()) {
9246                            return list.get(0);
9247                    }
9248    
9249                    return null;
9250            }
9251    
9252            /**
9253             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9254             *
9255             * @param companyId the company ID
9256             * @param displayDate the display date
9257             * @param status the status
9258             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9259             * @return the last matching blogs entry
9260             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9261             * @throws SystemException if a system exception occurred
9262             */
9263            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
9264                    int status, OrderByComparator orderByComparator)
9265                    throws NoSuchEntryException, SystemException {
9266                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
9267                                    status, orderByComparator);
9268    
9269                    if (blogsEntry != null) {
9270                            return blogsEntry;
9271                    }
9272    
9273                    StringBundler msg = new StringBundler(8);
9274    
9275                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9276    
9277                    msg.append("companyId=");
9278                    msg.append(companyId);
9279    
9280                    msg.append(", displayDate=");
9281                    msg.append(displayDate);
9282    
9283                    msg.append(", status=");
9284                    msg.append(status);
9285    
9286                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9287    
9288                    throw new NoSuchEntryException(msg.toString());
9289            }
9290    
9291            /**
9292             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9293             *
9294             * @param companyId the company ID
9295             * @param displayDate the display date
9296             * @param status the status
9297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9298             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9299             * @throws SystemException if a system exception occurred
9300             */
9301            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
9302                    int status, OrderByComparator orderByComparator)
9303                    throws SystemException {
9304                    int count = countByC_LtD_S(companyId, displayDate, status);
9305    
9306                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
9307                                    count - 1, count, orderByComparator);
9308    
9309                    if (!list.isEmpty()) {
9310                            return list.get(0);
9311                    }
9312    
9313                    return null;
9314            }
9315    
9316            /**
9317             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9318             *
9319             * @param entryId the primary key of the current blogs entry
9320             * @param companyId the company ID
9321             * @param displayDate the display date
9322             * @param status the status
9323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9324             * @return the previous, current, and next blogs entry
9325             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9326             * @throws SystemException if a system exception occurred
9327             */
9328            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
9329                    Date displayDate, int status, OrderByComparator orderByComparator)
9330                    throws NoSuchEntryException, SystemException {
9331                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9332    
9333                    Session session = null;
9334    
9335                    try {
9336                            session = openSession();
9337    
9338                            BlogsEntry[] array = new BlogsEntryImpl[3];
9339    
9340                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
9341                                            displayDate, status, orderByComparator, true);
9342    
9343                            array[1] = blogsEntry;
9344    
9345                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
9346                                            displayDate, status, orderByComparator, false);
9347    
9348                            return array;
9349                    }
9350                    catch (Exception e) {
9351                            throw processException(e);
9352                    }
9353                    finally {
9354                            closeSession(session);
9355                    }
9356            }
9357    
9358            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
9359                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
9360                    OrderByComparator orderByComparator, boolean previous) {
9361                    StringBundler query = null;
9362    
9363                    if (orderByComparator != null) {
9364                            query = new StringBundler(6 +
9365                                            (orderByComparator.getOrderByFields().length * 6));
9366                    }
9367                    else {
9368                            query = new StringBundler(3);
9369                    }
9370    
9371                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9372    
9373                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
9374    
9375                    if (displayDate == null) {
9376                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
9377                    }
9378                    else {
9379                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
9380                    }
9381    
9382                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
9383    
9384                    if (orderByComparator != null) {
9385                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9386    
9387                            if (orderByConditionFields.length > 0) {
9388                                    query.append(WHERE_AND);
9389                            }
9390    
9391                            for (int i = 0; i < orderByConditionFields.length; i++) {
9392                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9393                                    query.append(orderByConditionFields[i]);
9394    
9395                                    if ((i + 1) < orderByConditionFields.length) {
9396                                            if (orderByComparator.isAscending() ^ previous) {
9397                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9398                                            }
9399                                            else {
9400                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9401                                            }
9402                                    }
9403                                    else {
9404                                            if (orderByComparator.isAscending() ^ previous) {
9405                                                    query.append(WHERE_GREATER_THAN);
9406                                            }
9407                                            else {
9408                                                    query.append(WHERE_LESSER_THAN);
9409                                            }
9410                                    }
9411                            }
9412    
9413                            query.append(ORDER_BY_CLAUSE);
9414    
9415                            String[] orderByFields = orderByComparator.getOrderByFields();
9416    
9417                            for (int i = 0; i < orderByFields.length; i++) {
9418                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9419                                    query.append(orderByFields[i]);
9420    
9421                                    if ((i + 1) < orderByFields.length) {
9422                                            if (orderByComparator.isAscending() ^ previous) {
9423                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9424                                            }
9425                                            else {
9426                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9427                                            }
9428                                    }
9429                                    else {
9430                                            if (orderByComparator.isAscending() ^ previous) {
9431                                                    query.append(ORDER_BY_ASC);
9432                                            }
9433                                            else {
9434                                                    query.append(ORDER_BY_DESC);
9435                                            }
9436                                    }
9437                            }
9438                    }
9439    
9440                    else {
9441                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9442                    }
9443    
9444                    String sql = query.toString();
9445    
9446                    Query q = session.createQuery(sql);
9447    
9448                    q.setFirstResult(0);
9449                    q.setMaxResults(2);
9450    
9451                    QueryPos qPos = QueryPos.getInstance(q);
9452    
9453                    qPos.add(companyId);
9454    
9455                    if (displayDate != null) {
9456                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9457                    }
9458    
9459                    qPos.add(status);
9460    
9461                    if (orderByComparator != null) {
9462                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9463    
9464                            for (Object value : values) {
9465                                    qPos.add(value);
9466                            }
9467                    }
9468    
9469                    List<BlogsEntry> list = q.list();
9470    
9471                    if (list.size() == 2) {
9472                            return list.get(1);
9473                    }
9474                    else {
9475                            return null;
9476                    }
9477            }
9478    
9479            /**
9480             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9481             *
9482             * @param groupId the group ID
9483             * @param userId the user ID
9484             * @param displayDate the display date
9485             * @return the matching blogs entries
9486             * @throws SystemException if a system exception occurred
9487             */
9488            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
9489                    Date displayDate) throws SystemException {
9490                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
9491                            QueryUtil.ALL_POS, null);
9492            }
9493    
9494            /**
9495             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9496             *
9497             * <p>
9498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9499             * </p>
9500             *
9501             * @param groupId the group ID
9502             * @param userId the user ID
9503             * @param displayDate the display date
9504             * @param start the lower bound of the range of blogs entries
9505             * @param end the upper bound of the range of blogs entries (not inclusive)
9506             * @return the range of matching blogs entries
9507             * @throws SystemException if a system exception occurred
9508             */
9509            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
9510                    Date displayDate, int start, int end) throws SystemException {
9511                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
9512            }
9513    
9514            /**
9515             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9516             *
9517             * <p>
9518             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9519             * </p>
9520             *
9521             * @param groupId the group ID
9522             * @param userId the user ID
9523             * @param displayDate the display date
9524             * @param start the lower bound of the range of blogs entries
9525             * @param end the upper bound of the range of blogs entries (not inclusive)
9526             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9527             * @return the ordered range of matching blogs entries
9528             * @throws SystemException if a system exception occurred
9529             */
9530            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
9531                    Date displayDate, int start, int end,
9532                    OrderByComparator orderByComparator) throws SystemException {
9533                    FinderPath finderPath = null;
9534                    Object[] finderArgs = null;
9535    
9536                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
9537                    finderArgs = new Object[] {
9538                                    groupId, userId, displayDate,
9539                                    
9540                                    start, end, orderByComparator
9541                            };
9542    
9543                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9544                                    finderArgs, this);
9545    
9546                    if ((list != null) && !list.isEmpty()) {
9547                            for (BlogsEntry blogsEntry : list) {
9548                                    if ((groupId != blogsEntry.getGroupId()) ||
9549                                                    (userId != blogsEntry.getUserId()) ||
9550                                                    !Validator.equals(displayDate,
9551                                                            blogsEntry.getDisplayDate())) {
9552                                            list = null;
9553    
9554                                            break;
9555                                    }
9556                            }
9557                    }
9558    
9559                    if (list == null) {
9560                            StringBundler query = null;
9561    
9562                            if (orderByComparator != null) {
9563                                    query = new StringBundler(5 +
9564                                                    (orderByComparator.getOrderByFields().length * 3));
9565                            }
9566                            else {
9567                                    query = new StringBundler(5);
9568                            }
9569    
9570                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9571    
9572                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9573    
9574                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9575    
9576                            if (displayDate == null) {
9577                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9578                            }
9579                            else {
9580                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9581                            }
9582    
9583                            if (orderByComparator != null) {
9584                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9585                                            orderByComparator);
9586                            }
9587    
9588                            else {
9589                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9590                            }
9591    
9592                            String sql = query.toString();
9593    
9594                            Session session = null;
9595    
9596                            try {
9597                                    session = openSession();
9598    
9599                                    Query q = session.createQuery(sql);
9600    
9601                                    QueryPos qPos = QueryPos.getInstance(q);
9602    
9603                                    qPos.add(groupId);
9604    
9605                                    qPos.add(userId);
9606    
9607                                    if (displayDate != null) {
9608                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9609                                    }
9610    
9611                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
9612                                                    end);
9613                            }
9614                            catch (Exception e) {
9615                                    throw processException(e);
9616                            }
9617                            finally {
9618                                    if (list == null) {
9619                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
9620                                    }
9621                                    else {
9622                                            cacheResult(list);
9623    
9624                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
9625                                    }
9626    
9627                                    closeSession(session);
9628                            }
9629                    }
9630    
9631                    return list;
9632            }
9633    
9634            /**
9635             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9636             *
9637             * @param groupId the group ID
9638             * @param userId the user ID
9639             * @param displayDate the display date
9640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9641             * @return the first matching blogs entry
9642             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9643             * @throws SystemException if a system exception occurred
9644             */
9645            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
9646                    Date displayDate, OrderByComparator orderByComparator)
9647                    throws NoSuchEntryException, SystemException {
9648                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
9649                                    displayDate, orderByComparator);
9650    
9651                    if (blogsEntry != null) {
9652                            return blogsEntry;
9653                    }
9654    
9655                    StringBundler msg = new StringBundler(8);
9656    
9657                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9658    
9659                    msg.append("groupId=");
9660                    msg.append(groupId);
9661    
9662                    msg.append(", userId=");
9663                    msg.append(userId);
9664    
9665                    msg.append(", displayDate=");
9666                    msg.append(displayDate);
9667    
9668                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9669    
9670                    throw new NoSuchEntryException(msg.toString());
9671            }
9672    
9673            /**
9674             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9675             *
9676             * @param groupId the group ID
9677             * @param userId the user ID
9678             * @param displayDate the display date
9679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9680             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9681             * @throws SystemException if a system exception occurred
9682             */
9683            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
9684                    Date displayDate, OrderByComparator orderByComparator)
9685                    throws SystemException {
9686                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
9687                                    1, orderByComparator);
9688    
9689                    if (!list.isEmpty()) {
9690                            return list.get(0);
9691                    }
9692    
9693                    return null;
9694            }
9695    
9696            /**
9697             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9698             *
9699             * @param groupId the group ID
9700             * @param userId the user ID
9701             * @param displayDate the display date
9702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9703             * @return the last matching blogs entry
9704             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9705             * @throws SystemException if a system exception occurred
9706             */
9707            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
9708                    Date displayDate, OrderByComparator orderByComparator)
9709                    throws NoSuchEntryException, SystemException {
9710                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
9711                                    displayDate, orderByComparator);
9712    
9713                    if (blogsEntry != null) {
9714                            return blogsEntry;
9715                    }
9716    
9717                    StringBundler msg = new StringBundler(8);
9718    
9719                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9720    
9721                    msg.append("groupId=");
9722                    msg.append(groupId);
9723    
9724                    msg.append(", userId=");
9725                    msg.append(userId);
9726    
9727                    msg.append(", displayDate=");
9728                    msg.append(displayDate);
9729    
9730                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9731    
9732                    throw new NoSuchEntryException(msg.toString());
9733            }
9734    
9735            /**
9736             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9737             *
9738             * @param groupId the group ID
9739             * @param userId the user ID
9740             * @param displayDate the display date
9741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9742             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9743             * @throws SystemException if a system exception occurred
9744             */
9745            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
9746                    Date displayDate, OrderByComparator orderByComparator)
9747                    throws SystemException {
9748                    int count = countByG_U_LtD(groupId, userId, displayDate);
9749    
9750                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
9751                                    count - 1, count, orderByComparator);
9752    
9753                    if (!list.isEmpty()) {
9754                            return list.get(0);
9755                    }
9756    
9757                    return null;
9758            }
9759    
9760            /**
9761             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9762             *
9763             * @param entryId the primary key of the current blogs entry
9764             * @param groupId the group ID
9765             * @param userId the user ID
9766             * @param displayDate the display date
9767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9768             * @return the previous, current, and next blogs entry
9769             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9770             * @throws SystemException if a system exception occurred
9771             */
9772            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
9773                    long userId, Date displayDate, OrderByComparator orderByComparator)
9774                    throws NoSuchEntryException, SystemException {
9775                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9776    
9777                    Session session = null;
9778    
9779                    try {
9780                            session = openSession();
9781    
9782                            BlogsEntry[] array = new BlogsEntryImpl[3];
9783    
9784                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9785                                            userId, displayDate, orderByComparator, true);
9786    
9787                            array[1] = blogsEntry;
9788    
9789                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9790                                            userId, displayDate, orderByComparator, false);
9791    
9792                            return array;
9793                    }
9794                    catch (Exception e) {
9795                            throw processException(e);
9796                    }
9797                    finally {
9798                            closeSession(session);
9799                    }
9800            }
9801    
9802            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
9803                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9804                    OrderByComparator orderByComparator, boolean previous) {
9805                    StringBundler query = null;
9806    
9807                    if (orderByComparator != null) {
9808                            query = new StringBundler(6 +
9809                                            (orderByComparator.getOrderByFields().length * 6));
9810                    }
9811                    else {
9812                            query = new StringBundler(3);
9813                    }
9814    
9815                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9816    
9817                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9818    
9819                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9820    
9821                    if (displayDate == null) {
9822                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9823                    }
9824                    else {
9825                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9826                    }
9827    
9828                    if (orderByComparator != null) {
9829                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9830    
9831                            if (orderByConditionFields.length > 0) {
9832                                    query.append(WHERE_AND);
9833                            }
9834    
9835                            for (int i = 0; i < orderByConditionFields.length; i++) {
9836                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9837                                    query.append(orderByConditionFields[i]);
9838    
9839                                    if ((i + 1) < orderByConditionFields.length) {
9840                                            if (orderByComparator.isAscending() ^ previous) {
9841                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9842                                            }
9843                                            else {
9844                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9845                                            }
9846                                    }
9847                                    else {
9848                                            if (orderByComparator.isAscending() ^ previous) {
9849                                                    query.append(WHERE_GREATER_THAN);
9850                                            }
9851                                            else {
9852                                                    query.append(WHERE_LESSER_THAN);
9853                                            }
9854                                    }
9855                            }
9856    
9857                            query.append(ORDER_BY_CLAUSE);
9858    
9859                            String[] orderByFields = orderByComparator.getOrderByFields();
9860    
9861                            for (int i = 0; i < orderByFields.length; i++) {
9862                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9863                                    query.append(orderByFields[i]);
9864    
9865                                    if ((i + 1) < orderByFields.length) {
9866                                            if (orderByComparator.isAscending() ^ previous) {
9867                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9868                                            }
9869                                            else {
9870                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9871                                            }
9872                                    }
9873                                    else {
9874                                            if (orderByComparator.isAscending() ^ previous) {
9875                                                    query.append(ORDER_BY_ASC);
9876                                            }
9877                                            else {
9878                                                    query.append(ORDER_BY_DESC);
9879                                            }
9880                                    }
9881                            }
9882                    }
9883    
9884                    else {
9885                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9886                    }
9887    
9888                    String sql = query.toString();
9889    
9890                    Query q = session.createQuery(sql);
9891    
9892                    q.setFirstResult(0);
9893                    q.setMaxResults(2);
9894    
9895                    QueryPos qPos = QueryPos.getInstance(q);
9896    
9897                    qPos.add(groupId);
9898    
9899                    qPos.add(userId);
9900    
9901                    if (displayDate != null) {
9902                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9903                    }
9904    
9905                    if (orderByComparator != null) {
9906                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9907    
9908                            for (Object value : values) {
9909                                    qPos.add(value);
9910                            }
9911                    }
9912    
9913                    List<BlogsEntry> list = q.list();
9914    
9915                    if (list.size() == 2) {
9916                            return list.get(1);
9917                    }
9918                    else {
9919                            return null;
9920                    }
9921            }
9922    
9923            /**
9924             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9925             *
9926             * @param groupId the group ID
9927             * @param userId the user ID
9928             * @param displayDate the display date
9929             * @return the matching blogs entries that the user has permission to view
9930             * @throws SystemException if a system exception occurred
9931             */
9932            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9933                    Date displayDate) throws SystemException {
9934                    return filterFindByG_U_LtD(groupId, userId, displayDate,
9935                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9936            }
9937    
9938            /**
9939             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9940             *
9941             * <p>
9942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9943             * </p>
9944             *
9945             * @param groupId the group ID
9946             * @param userId the user ID
9947             * @param displayDate the display date
9948             * @param start the lower bound of the range of blogs entries
9949             * @param end the upper bound of the range of blogs entries (not inclusive)
9950             * @return the range of matching blogs entries that the user has permission to view
9951             * @throws SystemException if a system exception occurred
9952             */
9953            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9954                    Date displayDate, int start, int end) throws SystemException {
9955                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
9956                            null);
9957            }
9958    
9959            /**
9960             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9961             *
9962             * <p>
9963             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
9964             * </p>
9965             *
9966             * @param groupId the group ID
9967             * @param userId the user ID
9968             * @param displayDate the display date
9969             * @param start the lower bound of the range of blogs entries
9970             * @param end the upper bound of the range of blogs entries (not inclusive)
9971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9972             * @return the ordered range of matching blogs entries that the user has permission to view
9973             * @throws SystemException if a system exception occurred
9974             */
9975            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9976                    Date displayDate, int start, int end,
9977                    OrderByComparator orderByComparator) throws SystemException {
9978                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9979                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
9980                                    orderByComparator);
9981                    }
9982    
9983                    StringBundler query = null;
9984    
9985                    if (orderByComparator != null) {
9986                            query = new StringBundler(5 +
9987                                            (orderByComparator.getOrderByFields().length * 3));
9988                    }
9989                    else {
9990                            query = new StringBundler(5);
9991                    }
9992    
9993                    if (getDB().isSupportsInlineDistinct()) {
9994                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9995                    }
9996                    else {
9997                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9998                    }
9999    
10000                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10001    
10002                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10003    
10004                    if (displayDate == null) {
10005                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10006                    }
10007                    else {
10008                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10009                    }
10010    
10011                    if (!getDB().isSupportsInlineDistinct()) {
10012                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10013                    }
10014    
10015                    if (orderByComparator != null) {
10016                            if (getDB().isSupportsInlineDistinct()) {
10017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10018                                            orderByComparator);
10019                            }
10020                            else {
10021                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10022                                            orderByComparator);
10023                            }
10024                    }
10025    
10026                    else {
10027                            if (getDB().isSupportsInlineDistinct()) {
10028                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10029                            }
10030                            else {
10031                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10032                            }
10033                    }
10034    
10035                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10036                                    BlogsEntry.class.getName(),
10037                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10038    
10039                    Session session = null;
10040    
10041                    try {
10042                            session = openSession();
10043    
10044                            SQLQuery q = session.createSQLQuery(sql);
10045    
10046                            if (getDB().isSupportsInlineDistinct()) {
10047                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10048                            }
10049                            else {
10050                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10051                            }
10052    
10053                            QueryPos qPos = QueryPos.getInstance(q);
10054    
10055                            qPos.add(groupId);
10056    
10057                            qPos.add(userId);
10058    
10059                            if (displayDate != null) {
10060                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
10061                            }
10062    
10063                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10064                    }
10065                    catch (Exception e) {
10066                            throw processException(e);
10067                    }
10068                    finally {
10069                            closeSession(session);
10070                    }
10071            }
10072    
10073            /**
10074             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10075             *
10076             * @param entryId the primary key of the current blogs entry
10077             * @param groupId the group ID
10078             * @param userId the user ID
10079             * @param displayDate the display date
10080             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10081             * @return the previous, current, and next blogs entry
10082             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10083             * @throws SystemException if a system exception occurred
10084             */
10085            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
10086                    long groupId, long userId, Date displayDate,
10087                    OrderByComparator orderByComparator)
10088                    throws NoSuchEntryException, SystemException {
10089                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10090                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
10091                                    displayDate, orderByComparator);
10092                    }
10093    
10094                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10095    
10096                    Session session = null;
10097    
10098                    try {
10099                            session = openSession();
10100    
10101                            BlogsEntry[] array = new BlogsEntryImpl[3];
10102    
10103                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
10104                                            groupId, userId, displayDate, orderByComparator, true);
10105    
10106                            array[1] = blogsEntry;
10107    
10108                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
10109                                            groupId, userId, displayDate, orderByComparator, false);
10110    
10111                            return array;
10112                    }
10113                    catch (Exception e) {
10114                            throw processException(e);
10115                    }
10116                    finally {
10117                            closeSession(session);
10118                    }
10119            }
10120    
10121            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
10122                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
10123                    OrderByComparator orderByComparator, boolean previous) {
10124                    StringBundler query = null;
10125    
10126                    if (orderByComparator != null) {
10127                            query = new StringBundler(6 +
10128                                            (orderByComparator.getOrderByFields().length * 6));
10129                    }
10130                    else {
10131                            query = new StringBundler(3);
10132                    }
10133    
10134                    if (getDB().isSupportsInlineDistinct()) {
10135                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10136                    }
10137                    else {
10138                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10139                    }
10140    
10141                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10142    
10143                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10144    
10145                    if (displayDate == null) {
10146                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10147                    }
10148                    else {
10149                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10150                    }
10151    
10152                    if (!getDB().isSupportsInlineDistinct()) {
10153                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10154                    }
10155    
10156                    if (orderByComparator != null) {
10157                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10158    
10159                            if (orderByConditionFields.length > 0) {
10160                                    query.append(WHERE_AND);
10161                            }
10162    
10163                            for (int i = 0; i < orderByConditionFields.length; i++) {
10164                                    if (getDB().isSupportsInlineDistinct()) {
10165                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10166                                    }
10167                                    else {
10168                                            query.append(_ORDER_BY_ENTITY_TABLE);
10169                                    }
10170    
10171                                    query.append(orderByConditionFields[i]);
10172    
10173                                    if ((i + 1) < orderByConditionFields.length) {
10174                                            if (orderByComparator.isAscending() ^ previous) {
10175                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10176                                            }
10177                                            else {
10178                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10179                                            }
10180                                    }
10181                                    else {
10182                                            if (orderByComparator.isAscending() ^ previous) {
10183                                                    query.append(WHERE_GREATER_THAN);
10184                                            }
10185                                            else {
10186                                                    query.append(WHERE_LESSER_THAN);
10187                                            }
10188                                    }
10189                            }
10190    
10191                            query.append(ORDER_BY_CLAUSE);
10192    
10193                            String[] orderByFields = orderByComparator.getOrderByFields();
10194    
10195                            for (int i = 0; i < orderByFields.length; i++) {
10196                                    if (getDB().isSupportsInlineDistinct()) {
10197                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10198                                    }
10199                                    else {
10200                                            query.append(_ORDER_BY_ENTITY_TABLE);
10201                                    }
10202    
10203                                    query.append(orderByFields[i]);
10204    
10205                                    if ((i + 1) < orderByFields.length) {
10206                                            if (orderByComparator.isAscending() ^ previous) {
10207                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10208                                            }
10209                                            else {
10210                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10211                                            }
10212                                    }
10213                                    else {
10214                                            if (orderByComparator.isAscending() ^ previous) {
10215                                                    query.append(ORDER_BY_ASC);
10216                                            }
10217                                            else {
10218                                                    query.append(ORDER_BY_DESC);
10219                                            }
10220                                    }
10221                            }
10222                    }
10223    
10224                    else {
10225                            if (getDB().isSupportsInlineDistinct()) {
10226                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10227                            }
10228                            else {
10229                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10230                            }
10231                    }
10232    
10233                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10234                                    BlogsEntry.class.getName(),
10235                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10236    
10237                    SQLQuery q = session.createSQLQuery(sql);
10238    
10239                    q.setFirstResult(0);
10240                    q.setMaxResults(2);
10241    
10242                    if (getDB().isSupportsInlineDistinct()) {
10243                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10244                    }
10245                    else {
10246                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10247                    }
10248    
10249                    QueryPos qPos = QueryPos.getInstance(q);
10250    
10251                    qPos.add(groupId);
10252    
10253                    qPos.add(userId);
10254    
10255                    if (displayDate != null) {
10256                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10257                    }
10258    
10259                    if (orderByComparator != null) {
10260                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10261    
10262                            for (Object value : values) {
10263                                    qPos.add(value);
10264                            }
10265                    }
10266    
10267                    List<BlogsEntry> list = q.list();
10268    
10269                    if (list.size() == 2) {
10270                            return list.get(1);
10271                    }
10272                    else {
10273                            return null;
10274                    }
10275            }
10276    
10277            /**
10278             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10279             *
10280             * @param groupId the group ID
10281             * @param userId the user ID
10282             * @param status the status
10283             * @return the matching blogs entries
10284             * @throws SystemException if a system exception occurred
10285             */
10286            public List<BlogsEntry> findByG_U_NeS(long groupId, long userId, int status)
10287                    throws SystemException {
10288                    return findByG_U_NeS(groupId, userId, status, QueryUtil.ALL_POS,
10289                            QueryUtil.ALL_POS, null);
10290            }
10291    
10292            /**
10293             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10294             *
10295             * <p>
10296             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10297             * </p>
10298             *
10299             * @param groupId the group ID
10300             * @param userId the user ID
10301             * @param status the status
10302             * @param start the lower bound of the range of blogs entries
10303             * @param end the upper bound of the range of blogs entries (not inclusive)
10304             * @return the range of matching blogs entries
10305             * @throws SystemException if a system exception occurred
10306             */
10307            public List<BlogsEntry> findByG_U_NeS(long groupId, long userId,
10308                    int status, int start, int end) throws SystemException {
10309                    return findByG_U_NeS(groupId, userId, status, start, end, null);
10310            }
10311    
10312            /**
10313             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10314             *
10315             * <p>
10316             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10317             * </p>
10318             *
10319             * @param groupId the group ID
10320             * @param userId the user ID
10321             * @param status the status
10322             * @param start the lower bound of the range of blogs entries
10323             * @param end the upper bound of the range of blogs entries (not inclusive)
10324             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10325             * @return the ordered range of matching blogs entries
10326             * @throws SystemException if a system exception occurred
10327             */
10328            public List<BlogsEntry> findByG_U_NeS(long groupId, long userId,
10329                    int status, int start, int end, OrderByComparator orderByComparator)
10330                    throws SystemException {
10331                    FinderPath finderPath = null;
10332                    Object[] finderArgs = null;
10333    
10334                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NES;
10335                    finderArgs = new Object[] {
10336                                    groupId, userId, status,
10337                                    
10338                                    start, end, orderByComparator
10339                            };
10340    
10341                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10342                                    finderArgs, this);
10343    
10344                    if ((list != null) && !list.isEmpty()) {
10345                            for (BlogsEntry blogsEntry : list) {
10346                                    if ((groupId != blogsEntry.getGroupId()) ||
10347                                                    (userId != blogsEntry.getUserId()) ||
10348                                                    (status != blogsEntry.getStatus())) {
10349                                            list = null;
10350    
10351                                            break;
10352                                    }
10353                            }
10354                    }
10355    
10356                    if (list == null) {
10357                            StringBundler query = null;
10358    
10359                            if (orderByComparator != null) {
10360                                    query = new StringBundler(5 +
10361                                                    (orderByComparator.getOrderByFields().length * 3));
10362                            }
10363                            else {
10364                                    query = new StringBundler(5);
10365                            }
10366    
10367                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10368    
10369                            query.append(_FINDER_COLUMN_G_U_NES_GROUPID_2);
10370    
10371                            query.append(_FINDER_COLUMN_G_U_NES_USERID_2);
10372    
10373                            query.append(_FINDER_COLUMN_G_U_NES_STATUS_2);
10374    
10375                            if (orderByComparator != null) {
10376                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10377                                            orderByComparator);
10378                            }
10379    
10380                            else {
10381                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10382                            }
10383    
10384                            String sql = query.toString();
10385    
10386                            Session session = null;
10387    
10388                            try {
10389                                    session = openSession();
10390    
10391                                    Query q = session.createQuery(sql);
10392    
10393                                    QueryPos qPos = QueryPos.getInstance(q);
10394    
10395                                    qPos.add(groupId);
10396    
10397                                    qPos.add(userId);
10398    
10399                                    qPos.add(status);
10400    
10401                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
10402                                                    end);
10403                            }
10404                            catch (Exception e) {
10405                                    throw processException(e);
10406                            }
10407                            finally {
10408                                    if (list == null) {
10409                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
10410                                    }
10411                                    else {
10412                                            cacheResult(list);
10413    
10414                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
10415                                    }
10416    
10417                                    closeSession(session);
10418                            }
10419                    }
10420    
10421                    return list;
10422            }
10423    
10424            /**
10425             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10426             *
10427             * @param groupId the group ID
10428             * @param userId the user ID
10429             * @param status the status
10430             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10431             * @return the first matching blogs entry
10432             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10433             * @throws SystemException if a system exception occurred
10434             */
10435            public BlogsEntry findByG_U_NeS_First(long groupId, long userId,
10436                    int status, OrderByComparator orderByComparator)
10437                    throws NoSuchEntryException, SystemException {
10438                    BlogsEntry blogsEntry = fetchByG_U_NeS_First(groupId, userId, status,
10439                                    orderByComparator);
10440    
10441                    if (blogsEntry != null) {
10442                            return blogsEntry;
10443                    }
10444    
10445                    StringBundler msg = new StringBundler(8);
10446    
10447                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10448    
10449                    msg.append("groupId=");
10450                    msg.append(groupId);
10451    
10452                    msg.append(", userId=");
10453                    msg.append(userId);
10454    
10455                    msg.append(", status=");
10456                    msg.append(status);
10457    
10458                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10459    
10460                    throw new NoSuchEntryException(msg.toString());
10461            }
10462    
10463            /**
10464             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10465             *
10466             * @param groupId the group ID
10467             * @param userId the user ID
10468             * @param status the status
10469             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10470             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10471             * @throws SystemException if a system exception occurred
10472             */
10473            public BlogsEntry fetchByG_U_NeS_First(long groupId, long userId,
10474                    int status, OrderByComparator orderByComparator)
10475                    throws SystemException {
10476                    List<BlogsEntry> list = findByG_U_NeS(groupId, userId, status, 0, 1,
10477                                    orderByComparator);
10478    
10479                    if (!list.isEmpty()) {
10480                            return list.get(0);
10481                    }
10482    
10483                    return null;
10484            }
10485    
10486            /**
10487             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10488             *
10489             * @param groupId the group ID
10490             * @param userId the user ID
10491             * @param status the status
10492             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10493             * @return the last matching blogs entry
10494             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10495             * @throws SystemException if a system exception occurred
10496             */
10497            public BlogsEntry findByG_U_NeS_Last(long groupId, long userId, int status,
10498                    OrderByComparator orderByComparator)
10499                    throws NoSuchEntryException, SystemException {
10500                    BlogsEntry blogsEntry = fetchByG_U_NeS_Last(groupId, userId, status,
10501                                    orderByComparator);
10502    
10503                    if (blogsEntry != null) {
10504                            return blogsEntry;
10505                    }
10506    
10507                    StringBundler msg = new StringBundler(8);
10508    
10509                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10510    
10511                    msg.append("groupId=");
10512                    msg.append(groupId);
10513    
10514                    msg.append(", userId=");
10515                    msg.append(userId);
10516    
10517                    msg.append(", status=");
10518                    msg.append(status);
10519    
10520                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10521    
10522                    throw new NoSuchEntryException(msg.toString());
10523            }
10524    
10525            /**
10526             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10527             *
10528             * @param groupId the group ID
10529             * @param userId the user ID
10530             * @param status the status
10531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10532             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10533             * @throws SystemException if a system exception occurred
10534             */
10535            public BlogsEntry fetchByG_U_NeS_Last(long groupId, long userId,
10536                    int status, OrderByComparator orderByComparator)
10537                    throws SystemException {
10538                    int count = countByG_U_NeS(groupId, userId, status);
10539    
10540                    List<BlogsEntry> list = findByG_U_NeS(groupId, userId, status,
10541                                    count - 1, count, orderByComparator);
10542    
10543                    if (!list.isEmpty()) {
10544                            return list.get(0);
10545                    }
10546    
10547                    return null;
10548            }
10549    
10550            /**
10551             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10552             *
10553             * @param entryId the primary key of the current blogs entry
10554             * @param groupId the group ID
10555             * @param userId the user ID
10556             * @param status the status
10557             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10558             * @return the previous, current, and next blogs entry
10559             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10560             * @throws SystemException if a system exception occurred
10561             */
10562            public BlogsEntry[] findByG_U_NeS_PrevAndNext(long entryId, long groupId,
10563                    long userId, int status, OrderByComparator orderByComparator)
10564                    throws NoSuchEntryException, SystemException {
10565                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10566    
10567                    Session session = null;
10568    
10569                    try {
10570                            session = openSession();
10571    
10572                            BlogsEntry[] array = new BlogsEntryImpl[3];
10573    
10574                            array[0] = getByG_U_NeS_PrevAndNext(session, blogsEntry, groupId,
10575                                            userId, status, orderByComparator, true);
10576    
10577                            array[1] = blogsEntry;
10578    
10579                            array[2] = getByG_U_NeS_PrevAndNext(session, blogsEntry, groupId,
10580                                            userId, status, orderByComparator, false);
10581    
10582                            return array;
10583                    }
10584                    catch (Exception e) {
10585                            throw processException(e);
10586                    }
10587                    finally {
10588                            closeSession(session);
10589                    }
10590            }
10591    
10592            protected BlogsEntry getByG_U_NeS_PrevAndNext(Session session,
10593                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10594                    OrderByComparator orderByComparator, boolean previous) {
10595                    StringBundler query = null;
10596    
10597                    if (orderByComparator != null) {
10598                            query = new StringBundler(6 +
10599                                            (orderByComparator.getOrderByFields().length * 6));
10600                    }
10601                    else {
10602                            query = new StringBundler(3);
10603                    }
10604    
10605                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10606    
10607                    query.append(_FINDER_COLUMN_G_U_NES_GROUPID_2);
10608    
10609                    query.append(_FINDER_COLUMN_G_U_NES_USERID_2);
10610    
10611                    query.append(_FINDER_COLUMN_G_U_NES_STATUS_2);
10612    
10613                    if (orderByComparator != null) {
10614                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10615    
10616                            if (orderByConditionFields.length > 0) {
10617                                    query.append(WHERE_AND);
10618                            }
10619    
10620                            for (int i = 0; i < orderByConditionFields.length; i++) {
10621                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10622                                    query.append(orderByConditionFields[i]);
10623    
10624                                    if ((i + 1) < orderByConditionFields.length) {
10625                                            if (orderByComparator.isAscending() ^ previous) {
10626                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10627                                            }
10628                                            else {
10629                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10630                                            }
10631                                    }
10632                                    else {
10633                                            if (orderByComparator.isAscending() ^ previous) {
10634                                                    query.append(WHERE_GREATER_THAN);
10635                                            }
10636                                            else {
10637                                                    query.append(WHERE_LESSER_THAN);
10638                                            }
10639                                    }
10640                            }
10641    
10642                            query.append(ORDER_BY_CLAUSE);
10643    
10644                            String[] orderByFields = orderByComparator.getOrderByFields();
10645    
10646                            for (int i = 0; i < orderByFields.length; i++) {
10647                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10648                                    query.append(orderByFields[i]);
10649    
10650                                    if ((i + 1) < orderByFields.length) {
10651                                            if (orderByComparator.isAscending() ^ previous) {
10652                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10653                                            }
10654                                            else {
10655                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10656                                            }
10657                                    }
10658                                    else {
10659                                            if (orderByComparator.isAscending() ^ previous) {
10660                                                    query.append(ORDER_BY_ASC);
10661                                            }
10662                                            else {
10663                                                    query.append(ORDER_BY_DESC);
10664                                            }
10665                                    }
10666                            }
10667                    }
10668    
10669                    else {
10670                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10671                    }
10672    
10673                    String sql = query.toString();
10674    
10675                    Query q = session.createQuery(sql);
10676    
10677                    q.setFirstResult(0);
10678                    q.setMaxResults(2);
10679    
10680                    QueryPos qPos = QueryPos.getInstance(q);
10681    
10682                    qPos.add(groupId);
10683    
10684                    qPos.add(userId);
10685    
10686                    qPos.add(status);
10687    
10688                    if (orderByComparator != null) {
10689                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10690    
10691                            for (Object value : values) {
10692                                    qPos.add(value);
10693                            }
10694                    }
10695    
10696                    List<BlogsEntry> list = q.list();
10697    
10698                    if (list.size() == 2) {
10699                            return list.get(1);
10700                    }
10701                    else {
10702                            return null;
10703                    }
10704            }
10705    
10706            /**
10707             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10708             *
10709             * @param groupId the group ID
10710             * @param userId the user ID
10711             * @param status the status
10712             * @return the matching blogs entries that the user has permission to view
10713             * @throws SystemException if a system exception occurred
10714             */
10715            public List<BlogsEntry> filterFindByG_U_NeS(long groupId, long userId,
10716                    int status) throws SystemException {
10717                    return filterFindByG_U_NeS(groupId, userId, status, QueryUtil.ALL_POS,
10718                            QueryUtil.ALL_POS, null);
10719            }
10720    
10721            /**
10722             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10723             *
10724             * <p>
10725             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10726             * </p>
10727             *
10728             * @param groupId the group ID
10729             * @param userId the user ID
10730             * @param status the status
10731             * @param start the lower bound of the range of blogs entries
10732             * @param end the upper bound of the range of blogs entries (not inclusive)
10733             * @return the range of matching blogs entries that the user has permission to view
10734             * @throws SystemException if a system exception occurred
10735             */
10736            public List<BlogsEntry> filterFindByG_U_NeS(long groupId, long userId,
10737                    int status, int start, int end) throws SystemException {
10738                    return filterFindByG_U_NeS(groupId, userId, status, start, end, null);
10739            }
10740    
10741            /**
10742             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10743             *
10744             * <p>
10745             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
10746             * </p>
10747             *
10748             * @param groupId the group ID
10749             * @param userId the user ID
10750             * @param status the status
10751             * @param start the lower bound of the range of blogs entries
10752             * @param end the upper bound of the range of blogs entries (not inclusive)
10753             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10754             * @return the ordered range of matching blogs entries that the user has permission to view
10755             * @throws SystemException if a system exception occurred
10756             */
10757            public List<BlogsEntry> filterFindByG_U_NeS(long groupId, long userId,
10758                    int status, int start, int end, OrderByComparator orderByComparator)
10759                    throws SystemException {
10760                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10761                            return findByG_U_NeS(groupId, userId, status, start, end,
10762                                    orderByComparator);
10763                    }
10764    
10765                    StringBundler query = null;
10766    
10767                    if (orderByComparator != null) {
10768                            query = new StringBundler(5 +
10769                                            (orderByComparator.getOrderByFields().length * 3));
10770                    }
10771                    else {
10772                            query = new StringBundler(5);
10773                    }
10774    
10775                    if (getDB().isSupportsInlineDistinct()) {
10776                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10777                    }
10778                    else {
10779                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10780                    }
10781    
10782                    query.append(_FINDER_COLUMN_G_U_NES_GROUPID_2);
10783    
10784                    query.append(_FINDER_COLUMN_G_U_NES_USERID_2);
10785    
10786                    query.append(_FINDER_COLUMN_G_U_NES_STATUS_2);
10787    
10788                    if (!getDB().isSupportsInlineDistinct()) {
10789                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10790                    }
10791    
10792                    if (orderByComparator != null) {
10793                            if (getDB().isSupportsInlineDistinct()) {
10794                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10795                                            orderByComparator);
10796                            }
10797                            else {
10798                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10799                                            orderByComparator);
10800                            }
10801                    }
10802    
10803                    else {
10804                            if (getDB().isSupportsInlineDistinct()) {
10805                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10806                            }
10807                            else {
10808                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10809                            }
10810                    }
10811    
10812                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10813                                    BlogsEntry.class.getName(),
10814                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10815    
10816                    Session session = null;
10817    
10818                    try {
10819                            session = openSession();
10820    
10821                            SQLQuery q = session.createSQLQuery(sql);
10822    
10823                            if (getDB().isSupportsInlineDistinct()) {
10824                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10825                            }
10826                            else {
10827                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10828                            }
10829    
10830                            QueryPos qPos = QueryPos.getInstance(q);
10831    
10832                            qPos.add(groupId);
10833    
10834                            qPos.add(userId);
10835    
10836                            qPos.add(status);
10837    
10838                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10839                    }
10840                    catch (Exception e) {
10841                            throw processException(e);
10842                    }
10843                    finally {
10844                            closeSession(session);
10845                    }
10846            }
10847    
10848            /**
10849             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10850             *
10851             * @param entryId the primary key of the current blogs entry
10852             * @param groupId the group ID
10853             * @param userId the user ID
10854             * @param status the status
10855             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10856             * @return the previous, current, and next blogs entry
10857             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10858             * @throws SystemException if a system exception occurred
10859             */
10860            public BlogsEntry[] filterFindByG_U_NeS_PrevAndNext(long entryId,
10861                    long groupId, long userId, int status,
10862                    OrderByComparator orderByComparator)
10863                    throws NoSuchEntryException, SystemException {
10864                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10865                            return findByG_U_NeS_PrevAndNext(entryId, groupId, userId, status,
10866                                    orderByComparator);
10867                    }
10868    
10869                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10870    
10871                    Session session = null;
10872    
10873                    try {
10874                            session = openSession();
10875    
10876                            BlogsEntry[] array = new BlogsEntryImpl[3];
10877    
10878                            array[0] = filterGetByG_U_NeS_PrevAndNext(session, blogsEntry,
10879                                            groupId, userId, status, orderByComparator, true);
10880    
10881                            array[1] = blogsEntry;
10882    
10883                            array[2] = filterGetByG_U_NeS_PrevAndNext(session, blogsEntry,
10884                                            groupId, userId, status, orderByComparator, false);
10885    
10886                            return array;
10887                    }
10888                    catch (Exception e) {
10889                            throw processException(e);
10890                    }
10891                    finally {
10892                            closeSession(session);
10893                    }
10894            }
10895    
10896            protected BlogsEntry filterGetByG_U_NeS_PrevAndNext(Session session,
10897                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10898                    OrderByComparator orderByComparator, boolean previous) {
10899                    StringBundler query = null;
10900    
10901                    if (orderByComparator != null) {
10902                            query = new StringBundler(6 +
10903                                            (orderByComparator.getOrderByFields().length * 6));
10904                    }
10905                    else {
10906                            query = new StringBundler(3);
10907                    }
10908    
10909                    if (getDB().isSupportsInlineDistinct()) {
10910                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10911                    }
10912                    else {
10913                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10914                    }
10915    
10916                    query.append(_FINDER_COLUMN_G_U_NES_GROUPID_2);
10917    
10918                    query.append(_FINDER_COLUMN_G_U_NES_USERID_2);
10919    
10920                    query.append(_FINDER_COLUMN_G_U_NES_STATUS_2);
10921    
10922                    if (!getDB().isSupportsInlineDistinct()) {
10923                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10924                    }
10925    
10926                    if (orderByComparator != null) {
10927                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10928    
10929                            if (orderByConditionFields.length > 0) {
10930                                    query.append(WHERE_AND);
10931                            }
10932    
10933                            for (int i = 0; i < orderByConditionFields.length; i++) {
10934                                    if (getDB().isSupportsInlineDistinct()) {
10935                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10936                                    }
10937                                    else {
10938                                            query.append(_ORDER_BY_ENTITY_TABLE);
10939                                    }
10940    
10941                                    query.append(orderByConditionFields[i]);
10942    
10943                                    if ((i + 1) < orderByConditionFields.length) {
10944                                            if (orderByComparator.isAscending() ^ previous) {
10945                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10946                                            }
10947                                            else {
10948                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10949                                            }
10950                                    }
10951                                    else {
10952                                            if (orderByComparator.isAscending() ^ previous) {
10953                                                    query.append(WHERE_GREATER_THAN);
10954                                            }
10955                                            else {
10956                                                    query.append(WHERE_LESSER_THAN);
10957                                            }
10958                                    }
10959                            }
10960    
10961                            query.append(ORDER_BY_CLAUSE);
10962    
10963                            String[] orderByFields = orderByComparator.getOrderByFields();
10964    
10965                            for (int i = 0; i < orderByFields.length; i++) {
10966                                    if (getDB().isSupportsInlineDistinct()) {
10967                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10968                                    }
10969                                    else {
10970                                            query.append(_ORDER_BY_ENTITY_TABLE);
10971                                    }
10972    
10973                                    query.append(orderByFields[i]);
10974    
10975                                    if ((i + 1) < orderByFields.length) {
10976                                            if (orderByComparator.isAscending() ^ previous) {
10977                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10978                                            }
10979                                            else {
10980                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10981                                            }
10982                                    }
10983                                    else {
10984                                            if (orderByComparator.isAscending() ^ previous) {
10985                                                    query.append(ORDER_BY_ASC);
10986                                            }
10987                                            else {
10988                                                    query.append(ORDER_BY_DESC);
10989                                            }
10990                                    }
10991                            }
10992                    }
10993    
10994                    else {
10995                            if (getDB().isSupportsInlineDistinct()) {
10996                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10997                            }
10998                            else {
10999                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11000                            }
11001                    }
11002    
11003                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11004                                    BlogsEntry.class.getName(),
11005                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11006    
11007                    SQLQuery q = session.createSQLQuery(sql);
11008    
11009                    q.setFirstResult(0);
11010                    q.setMaxResults(2);
11011    
11012                    if (getDB().isSupportsInlineDistinct()) {
11013                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11014                    }
11015                    else {
11016                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11017                    }
11018    
11019                    QueryPos qPos = QueryPos.getInstance(q);
11020    
11021                    qPos.add(groupId);
11022    
11023                    qPos.add(userId);
11024    
11025                    qPos.add(status);
11026    
11027                    if (orderByComparator != null) {
11028                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11029    
11030                            for (Object value : values) {
11031                                    qPos.add(value);
11032                            }
11033                    }
11034    
11035                    List<BlogsEntry> list = q.list();
11036    
11037                    if (list.size() == 2) {
11038                            return list.get(1);
11039                    }
11040                    else {
11041                            return null;
11042                    }
11043            }
11044    
11045            /**
11046             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
11047             *
11048             * @param groupId the group ID
11049             * @param userId the user ID
11050             * @param status the status
11051             * @return the matching blogs entries
11052             * @throws SystemException if a system exception occurred
11053             */
11054            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status)
11055                    throws SystemException {
11056                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
11057                            QueryUtil.ALL_POS, null);
11058            }
11059    
11060            /**
11061             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
11062             *
11063             * <p>
11064             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11065             * </p>
11066             *
11067             * @param groupId the group ID
11068             * @param userId the user ID
11069             * @param status the status
11070             * @param start the lower bound of the range of blogs entries
11071             * @param end the upper bound of the range of blogs entries (not inclusive)
11072             * @return the range of matching blogs entries
11073             * @throws SystemException if a system exception occurred
11074             */
11075            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
11076                    int start, int end) throws SystemException {
11077                    return findByG_U_S(groupId, userId, status, start, end, null);
11078            }
11079    
11080            /**
11081             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
11082             *
11083             * <p>
11084             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11085             * </p>
11086             *
11087             * @param groupId the group ID
11088             * @param userId the user ID
11089             * @param status the status
11090             * @param start the lower bound of the range of blogs entries
11091             * @param end the upper bound of the range of blogs entries (not inclusive)
11092             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11093             * @return the ordered range of matching blogs entries
11094             * @throws SystemException if a system exception occurred
11095             */
11096            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
11097                    int start, int end, OrderByComparator orderByComparator)
11098                    throws SystemException {
11099                    FinderPath finderPath = null;
11100                    Object[] finderArgs = null;
11101    
11102                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11103                                    (orderByComparator == null)) {
11104                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
11105                            finderArgs = new Object[] { groupId, userId, status };
11106                    }
11107                    else {
11108                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
11109                            finderArgs = new Object[] {
11110                                            groupId, userId, status,
11111                                            
11112                                            start, end, orderByComparator
11113                                    };
11114                    }
11115    
11116                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11117                                    finderArgs, this);
11118    
11119                    if ((list != null) && !list.isEmpty()) {
11120                            for (BlogsEntry blogsEntry : list) {
11121                                    if ((groupId != blogsEntry.getGroupId()) ||
11122                                                    (userId != blogsEntry.getUserId()) ||
11123                                                    (status != blogsEntry.getStatus())) {
11124                                            list = null;
11125    
11126                                            break;
11127                                    }
11128                            }
11129                    }
11130    
11131                    if (list == null) {
11132                            StringBundler query = null;
11133    
11134                            if (orderByComparator != null) {
11135                                    query = new StringBundler(5 +
11136                                                    (orderByComparator.getOrderByFields().length * 3));
11137                            }
11138                            else {
11139                                    query = new StringBundler(5);
11140                            }
11141    
11142                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11143    
11144                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11145    
11146                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11147    
11148                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11149    
11150                            if (orderByComparator != null) {
11151                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11152                                            orderByComparator);
11153                            }
11154    
11155                            else {
11156                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11157                            }
11158    
11159                            String sql = query.toString();
11160    
11161                            Session session = null;
11162    
11163                            try {
11164                                    session = openSession();
11165    
11166                                    Query q = session.createQuery(sql);
11167    
11168                                    QueryPos qPos = QueryPos.getInstance(q);
11169    
11170                                    qPos.add(groupId);
11171    
11172                                    qPos.add(userId);
11173    
11174                                    qPos.add(status);
11175    
11176                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
11177                                                    end);
11178                            }
11179                            catch (Exception e) {
11180                                    throw processException(e);
11181                            }
11182                            finally {
11183                                    if (list == null) {
11184                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11185                                    }
11186                                    else {
11187                                            cacheResult(list);
11188    
11189                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11190                                    }
11191    
11192                                    closeSession(session);
11193                            }
11194                    }
11195    
11196                    return list;
11197            }
11198    
11199            /**
11200             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
11201             *
11202             * @param groupId the group ID
11203             * @param userId the user ID
11204             * @param status the status
11205             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11206             * @return the first matching blogs entry
11207             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11208             * @throws SystemException if a system exception occurred
11209             */
11210            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
11211                    OrderByComparator orderByComparator)
11212                    throws NoSuchEntryException, SystemException {
11213                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
11214                                    orderByComparator);
11215    
11216                    if (blogsEntry != null) {
11217                            return blogsEntry;
11218                    }
11219    
11220                    StringBundler msg = new StringBundler(8);
11221    
11222                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11223    
11224                    msg.append("groupId=");
11225                    msg.append(groupId);
11226    
11227                    msg.append(", userId=");
11228                    msg.append(userId);
11229    
11230                    msg.append(", status=");
11231                    msg.append(status);
11232    
11233                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11234    
11235                    throw new NoSuchEntryException(msg.toString());
11236            }
11237    
11238            /**
11239             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
11240             *
11241             * @param groupId the group ID
11242             * @param userId the user ID
11243             * @param status the status
11244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11245             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11246             * @throws SystemException if a system exception occurred
11247             */
11248            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
11249                    OrderByComparator orderByComparator) throws SystemException {
11250                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
11251                                    orderByComparator);
11252    
11253                    if (!list.isEmpty()) {
11254                            return list.get(0);
11255                    }
11256    
11257                    return null;
11258            }
11259    
11260            /**
11261             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
11262             *
11263             * @param groupId the group ID
11264             * @param userId the user ID
11265             * @param status the status
11266             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11267             * @return the last matching blogs entry
11268             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11269             * @throws SystemException if a system exception occurred
11270             */
11271            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
11272                    OrderByComparator orderByComparator)
11273                    throws NoSuchEntryException, SystemException {
11274                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
11275                                    orderByComparator);
11276    
11277                    if (blogsEntry != null) {
11278                            return blogsEntry;
11279                    }
11280    
11281                    StringBundler msg = new StringBundler(8);
11282    
11283                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11284    
11285                    msg.append("groupId=");
11286                    msg.append(groupId);
11287    
11288                    msg.append(", userId=");
11289                    msg.append(userId);
11290    
11291                    msg.append(", status=");
11292                    msg.append(status);
11293    
11294                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11295    
11296                    throw new NoSuchEntryException(msg.toString());
11297            }
11298    
11299            /**
11300             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
11301             *
11302             * @param groupId the group ID
11303             * @param userId the user ID
11304             * @param status the status
11305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11306             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11307             * @throws SystemException if a system exception occurred
11308             */
11309            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
11310                    OrderByComparator orderByComparator) throws SystemException {
11311                    int count = countByG_U_S(groupId, userId, status);
11312    
11313                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
11314                                    count, orderByComparator);
11315    
11316                    if (!list.isEmpty()) {
11317                            return list.get(0);
11318                    }
11319    
11320                    return null;
11321            }
11322    
11323            /**
11324             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
11325             *
11326             * @param entryId the primary key of the current blogs entry
11327             * @param groupId the group ID
11328             * @param userId the user ID
11329             * @param status the status
11330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11331             * @return the previous, current, and next blogs entry
11332             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11333             * @throws SystemException if a system exception occurred
11334             */
11335            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
11336                    long userId, int status, OrderByComparator orderByComparator)
11337                    throws NoSuchEntryException, SystemException {
11338                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11339    
11340                    Session session = null;
11341    
11342                    try {
11343                            session = openSession();
11344    
11345                            BlogsEntry[] array = new BlogsEntryImpl[3];
11346    
11347                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
11348                                            userId, status, orderByComparator, true);
11349    
11350                            array[1] = blogsEntry;
11351    
11352                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
11353                                            userId, status, orderByComparator, false);
11354    
11355                            return array;
11356                    }
11357                    catch (Exception e) {
11358                            throw processException(e);
11359                    }
11360                    finally {
11361                            closeSession(session);
11362                    }
11363            }
11364    
11365            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
11366                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11367                    OrderByComparator orderByComparator, boolean previous) {
11368                    StringBundler query = null;
11369    
11370                    if (orderByComparator != null) {
11371                            query = new StringBundler(6 +
11372                                            (orderByComparator.getOrderByFields().length * 6));
11373                    }
11374                    else {
11375                            query = new StringBundler(3);
11376                    }
11377    
11378                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11379    
11380                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11381    
11382                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11383    
11384                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11385    
11386                    if (orderByComparator != null) {
11387                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11388    
11389                            if (orderByConditionFields.length > 0) {
11390                                    query.append(WHERE_AND);
11391                            }
11392    
11393                            for (int i = 0; i < orderByConditionFields.length; i++) {
11394                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11395                                    query.append(orderByConditionFields[i]);
11396    
11397                                    if ((i + 1) < orderByConditionFields.length) {
11398                                            if (orderByComparator.isAscending() ^ previous) {
11399                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11400                                            }
11401                                            else {
11402                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11403                                            }
11404                                    }
11405                                    else {
11406                                            if (orderByComparator.isAscending() ^ previous) {
11407                                                    query.append(WHERE_GREATER_THAN);
11408                                            }
11409                                            else {
11410                                                    query.append(WHERE_LESSER_THAN);
11411                                            }
11412                                    }
11413                            }
11414    
11415                            query.append(ORDER_BY_CLAUSE);
11416    
11417                            String[] orderByFields = orderByComparator.getOrderByFields();
11418    
11419                            for (int i = 0; i < orderByFields.length; i++) {
11420                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11421                                    query.append(orderByFields[i]);
11422    
11423                                    if ((i + 1) < orderByFields.length) {
11424                                            if (orderByComparator.isAscending() ^ previous) {
11425                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11426                                            }
11427                                            else {
11428                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11429                                            }
11430                                    }
11431                                    else {
11432                                            if (orderByComparator.isAscending() ^ previous) {
11433                                                    query.append(ORDER_BY_ASC);
11434                                            }
11435                                            else {
11436                                                    query.append(ORDER_BY_DESC);
11437                                            }
11438                                    }
11439                            }
11440                    }
11441    
11442                    else {
11443                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11444                    }
11445    
11446                    String sql = query.toString();
11447    
11448                    Query q = session.createQuery(sql);
11449    
11450                    q.setFirstResult(0);
11451                    q.setMaxResults(2);
11452    
11453                    QueryPos qPos = QueryPos.getInstance(q);
11454    
11455                    qPos.add(groupId);
11456    
11457                    qPos.add(userId);
11458    
11459                    qPos.add(status);
11460    
11461                    if (orderByComparator != null) {
11462                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11463    
11464                            for (Object value : values) {
11465                                    qPos.add(value);
11466                            }
11467                    }
11468    
11469                    List<BlogsEntry> list = q.list();
11470    
11471                    if (list.size() == 2) {
11472                            return list.get(1);
11473                    }
11474                    else {
11475                            return null;
11476                    }
11477            }
11478    
11479            /**
11480             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
11481             *
11482             * @param groupId the group ID
11483             * @param userId the user ID
11484             * @param status the status
11485             * @return the matching blogs entries that the user has permission to view
11486             * @throws SystemException if a system exception occurred
11487             */
11488            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
11489                    int status) throws SystemException {
11490                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
11491                            QueryUtil.ALL_POS, null);
11492            }
11493    
11494            /**
11495             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
11496             *
11497             * <p>
11498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11499             * </p>
11500             *
11501             * @param groupId the group ID
11502             * @param userId the user ID
11503             * @param status the status
11504             * @param start the lower bound of the range of blogs entries
11505             * @param end the upper bound of the range of blogs entries (not inclusive)
11506             * @return the range of matching blogs entries that the user has permission to view
11507             * @throws SystemException if a system exception occurred
11508             */
11509            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
11510                    int status, int start, int end) throws SystemException {
11511                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
11512            }
11513    
11514            /**
11515             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and status = &#63;.
11516             *
11517             * <p>
11518             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11519             * </p>
11520             *
11521             * @param groupId the group ID
11522             * @param userId the user ID
11523             * @param status the status
11524             * @param start the lower bound of the range of blogs entries
11525             * @param end the upper bound of the range of blogs entries (not inclusive)
11526             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11527             * @return the ordered range of matching blogs entries that the user has permission to view
11528             * @throws SystemException if a system exception occurred
11529             */
11530            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
11531                    int status, int start, int end, OrderByComparator orderByComparator)
11532                    throws SystemException {
11533                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11534                            return findByG_U_S(groupId, userId, status, start, end,
11535                                    orderByComparator);
11536                    }
11537    
11538                    StringBundler query = null;
11539    
11540                    if (orderByComparator != null) {
11541                            query = new StringBundler(5 +
11542                                            (orderByComparator.getOrderByFields().length * 3));
11543                    }
11544                    else {
11545                            query = new StringBundler(5);
11546                    }
11547    
11548                    if (getDB().isSupportsInlineDistinct()) {
11549                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11550                    }
11551                    else {
11552                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11553                    }
11554    
11555                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11556    
11557                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11558    
11559                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11560    
11561                    if (!getDB().isSupportsInlineDistinct()) {
11562                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11563                    }
11564    
11565                    if (orderByComparator != null) {
11566                            if (getDB().isSupportsInlineDistinct()) {
11567                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11568                                            orderByComparator);
11569                            }
11570                            else {
11571                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11572                                            orderByComparator);
11573                            }
11574                    }
11575    
11576                    else {
11577                            if (getDB().isSupportsInlineDistinct()) {
11578                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11579                            }
11580                            else {
11581                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11582                            }
11583                    }
11584    
11585                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11586                                    BlogsEntry.class.getName(),
11587                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11588    
11589                    Session session = null;
11590    
11591                    try {
11592                            session = openSession();
11593    
11594                            SQLQuery q = session.createSQLQuery(sql);
11595    
11596                            if (getDB().isSupportsInlineDistinct()) {
11597                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11598                            }
11599                            else {
11600                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11601                            }
11602    
11603                            QueryPos qPos = QueryPos.getInstance(q);
11604    
11605                            qPos.add(groupId);
11606    
11607                            qPos.add(userId);
11608    
11609                            qPos.add(status);
11610    
11611                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11612                    }
11613                    catch (Exception e) {
11614                            throw processException(e);
11615                    }
11616                    finally {
11617                            closeSession(session);
11618                    }
11619            }
11620    
11621            /**
11622             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
11623             *
11624             * @param entryId the primary key of the current blogs entry
11625             * @param groupId the group ID
11626             * @param userId the user ID
11627             * @param status the status
11628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11629             * @return the previous, current, and next blogs entry
11630             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11631             * @throws SystemException if a system exception occurred
11632             */
11633            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
11634                    long groupId, long userId, int status,
11635                    OrderByComparator orderByComparator)
11636                    throws NoSuchEntryException, SystemException {
11637                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11638                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
11639                                    orderByComparator);
11640                    }
11641    
11642                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11643    
11644                    Session session = null;
11645    
11646                    try {
11647                            session = openSession();
11648    
11649                            BlogsEntry[] array = new BlogsEntryImpl[3];
11650    
11651                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
11652                                            groupId, userId, status, orderByComparator, true);
11653    
11654                            array[1] = blogsEntry;
11655    
11656                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
11657                                            groupId, userId, status, orderByComparator, false);
11658    
11659                            return array;
11660                    }
11661                    catch (Exception e) {
11662                            throw processException(e);
11663                    }
11664                    finally {
11665                            closeSession(session);
11666                    }
11667            }
11668    
11669            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
11670                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11671                    OrderByComparator orderByComparator, boolean previous) {
11672                    StringBundler query = null;
11673    
11674                    if (orderByComparator != null) {
11675                            query = new StringBundler(6 +
11676                                            (orderByComparator.getOrderByFields().length * 6));
11677                    }
11678                    else {
11679                            query = new StringBundler(3);
11680                    }
11681    
11682                    if (getDB().isSupportsInlineDistinct()) {
11683                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11684                    }
11685                    else {
11686                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11687                    }
11688    
11689                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11690    
11691                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11692    
11693                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11694    
11695                    if (!getDB().isSupportsInlineDistinct()) {
11696                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11697                    }
11698    
11699                    if (orderByComparator != null) {
11700                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11701    
11702                            if (orderByConditionFields.length > 0) {
11703                                    query.append(WHERE_AND);
11704                            }
11705    
11706                            for (int i = 0; i < orderByConditionFields.length; i++) {
11707                                    if (getDB().isSupportsInlineDistinct()) {
11708                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11709                                    }
11710                                    else {
11711                                            query.append(_ORDER_BY_ENTITY_TABLE);
11712                                    }
11713    
11714                                    query.append(orderByConditionFields[i]);
11715    
11716                                    if ((i + 1) < orderByConditionFields.length) {
11717                                            if (orderByComparator.isAscending() ^ previous) {
11718                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11719                                            }
11720                                            else {
11721                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11722                                            }
11723                                    }
11724                                    else {
11725                                            if (orderByComparator.isAscending() ^ previous) {
11726                                                    query.append(WHERE_GREATER_THAN);
11727                                            }
11728                                            else {
11729                                                    query.append(WHERE_LESSER_THAN);
11730                                            }
11731                                    }
11732                            }
11733    
11734                            query.append(ORDER_BY_CLAUSE);
11735    
11736                            String[] orderByFields = orderByComparator.getOrderByFields();
11737    
11738                            for (int i = 0; i < orderByFields.length; i++) {
11739                                    if (getDB().isSupportsInlineDistinct()) {
11740                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11741                                    }
11742                                    else {
11743                                            query.append(_ORDER_BY_ENTITY_TABLE);
11744                                    }
11745    
11746                                    query.append(orderByFields[i]);
11747    
11748                                    if ((i + 1) < orderByFields.length) {
11749                                            if (orderByComparator.isAscending() ^ previous) {
11750                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11751                                            }
11752                                            else {
11753                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11754                                            }
11755                                    }
11756                                    else {
11757                                            if (orderByComparator.isAscending() ^ previous) {
11758                                                    query.append(ORDER_BY_ASC);
11759                                            }
11760                                            else {
11761                                                    query.append(ORDER_BY_DESC);
11762                                            }
11763                                    }
11764                            }
11765                    }
11766    
11767                    else {
11768                            if (getDB().isSupportsInlineDistinct()) {
11769                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11770                            }
11771                            else {
11772                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11773                            }
11774                    }
11775    
11776                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11777                                    BlogsEntry.class.getName(),
11778                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11779    
11780                    SQLQuery q = session.createSQLQuery(sql);
11781    
11782                    q.setFirstResult(0);
11783                    q.setMaxResults(2);
11784    
11785                    if (getDB().isSupportsInlineDistinct()) {
11786                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11787                    }
11788                    else {
11789                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11790                    }
11791    
11792                    QueryPos qPos = QueryPos.getInstance(q);
11793    
11794                    qPos.add(groupId);
11795    
11796                    qPos.add(userId);
11797    
11798                    qPos.add(status);
11799    
11800                    if (orderByComparator != null) {
11801                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11802    
11803                            for (Object value : values) {
11804                                    qPos.add(value);
11805                            }
11806                    }
11807    
11808                    List<BlogsEntry> list = q.list();
11809    
11810                    if (list.size() == 2) {
11811                            return list.get(1);
11812                    }
11813                    else {
11814                            return null;
11815                    }
11816            }
11817    
11818            /**
11819             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
11820             *
11821             * @param groupId the group ID
11822             * @param displayDate the display date
11823             * @param status the status
11824             * @return the matching blogs entries
11825             * @throws SystemException if a system exception occurred
11826             */
11827            public List<BlogsEntry> findByG_LtD_NeS(long groupId, Date displayDate,
11828                    int status) throws SystemException {
11829                    return findByG_LtD_NeS(groupId, displayDate, status, QueryUtil.ALL_POS,
11830                            QueryUtil.ALL_POS, null);
11831            }
11832    
11833            /**
11834             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
11835             *
11836             * <p>
11837             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11838             * </p>
11839             *
11840             * @param groupId the group ID
11841             * @param displayDate the display date
11842             * @param status the status
11843             * @param start the lower bound of the range of blogs entries
11844             * @param end the upper bound of the range of blogs entries (not inclusive)
11845             * @return the range of matching blogs entries
11846             * @throws SystemException if a system exception occurred
11847             */
11848            public List<BlogsEntry> findByG_LtD_NeS(long groupId, Date displayDate,
11849                    int status, int start, int end) throws SystemException {
11850                    return findByG_LtD_NeS(groupId, displayDate, status, start, end, null);
11851            }
11852    
11853            /**
11854             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
11855             *
11856             * <p>
11857             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
11858             * </p>
11859             *
11860             * @param groupId the group ID
11861             * @param displayDate the display date
11862             * @param status the status
11863             * @param start the lower bound of the range of blogs entries
11864             * @param end the upper bound of the range of blogs entries (not inclusive)
11865             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11866             * @return the ordered range of matching blogs entries
11867             * @throws SystemException if a system exception occurred
11868             */
11869            public List<BlogsEntry> findByG_LtD_NeS(long groupId, Date displayDate,
11870                    int status, int start, int end, OrderByComparator orderByComparator)
11871                    throws SystemException {
11872                    FinderPath finderPath = null;
11873                    Object[] finderArgs = null;
11874    
11875                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NES;
11876                    finderArgs = new Object[] {
11877                                    groupId, displayDate, status,
11878                                    
11879                                    start, end, orderByComparator
11880                            };
11881    
11882                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11883                                    finderArgs, this);
11884    
11885                    if ((list != null) && !list.isEmpty()) {
11886                            for (BlogsEntry blogsEntry : list) {
11887                                    if ((groupId != blogsEntry.getGroupId()) ||
11888                                                    !Validator.equals(displayDate,
11889                                                            blogsEntry.getDisplayDate()) ||
11890                                                    (status != blogsEntry.getStatus())) {
11891                                            list = null;
11892    
11893                                            break;
11894                                    }
11895                            }
11896                    }
11897    
11898                    if (list == null) {
11899                            StringBundler query = null;
11900    
11901                            if (orderByComparator != null) {
11902                                    query = new StringBundler(5 +
11903                                                    (orderByComparator.getOrderByFields().length * 3));
11904                            }
11905                            else {
11906                                    query = new StringBundler(5);
11907                            }
11908    
11909                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11910    
11911                            query.append(_FINDER_COLUMN_G_LTD_NES_GROUPID_2);
11912    
11913                            if (displayDate == null) {
11914                                    query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_1);
11915                            }
11916                            else {
11917                                    query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_2);
11918                            }
11919    
11920                            query.append(_FINDER_COLUMN_G_LTD_NES_STATUS_2);
11921    
11922                            if (orderByComparator != null) {
11923                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11924                                            orderByComparator);
11925                            }
11926    
11927                            else {
11928                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11929                            }
11930    
11931                            String sql = query.toString();
11932    
11933                            Session session = null;
11934    
11935                            try {
11936                                    session = openSession();
11937    
11938                                    Query q = session.createQuery(sql);
11939    
11940                                    QueryPos qPos = QueryPos.getInstance(q);
11941    
11942                                    qPos.add(groupId);
11943    
11944                                    if (displayDate != null) {
11945                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11946                                    }
11947    
11948                                    qPos.add(status);
11949    
11950                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
11951                                                    end);
11952                            }
11953                            catch (Exception e) {
11954                                    throw processException(e);
11955                            }
11956                            finally {
11957                                    if (list == null) {
11958                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
11959                                    }
11960                                    else {
11961                                            cacheResult(list);
11962    
11963                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
11964                                    }
11965    
11966                                    closeSession(session);
11967                            }
11968                    }
11969    
11970                    return list;
11971            }
11972    
11973            /**
11974             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
11975             *
11976             * @param groupId the group ID
11977             * @param displayDate the display date
11978             * @param status the status
11979             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11980             * @return the first matching blogs entry
11981             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11982             * @throws SystemException if a system exception occurred
11983             */
11984            public BlogsEntry findByG_LtD_NeS_First(long groupId, Date displayDate,
11985                    int status, OrderByComparator orderByComparator)
11986                    throws NoSuchEntryException, SystemException {
11987                    BlogsEntry blogsEntry = fetchByG_LtD_NeS_First(groupId, displayDate,
11988                                    status, orderByComparator);
11989    
11990                    if (blogsEntry != null) {
11991                            return blogsEntry;
11992                    }
11993    
11994                    StringBundler msg = new StringBundler(8);
11995    
11996                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11997    
11998                    msg.append("groupId=");
11999                    msg.append(groupId);
12000    
12001                    msg.append(", displayDate=");
12002                    msg.append(displayDate);
12003    
12004                    msg.append(", status=");
12005                    msg.append(status);
12006    
12007                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12008    
12009                    throw new NoSuchEntryException(msg.toString());
12010            }
12011    
12012            /**
12013             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12014             *
12015             * @param groupId the group ID
12016             * @param displayDate the display date
12017             * @param status the status
12018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12019             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12020             * @throws SystemException if a system exception occurred
12021             */
12022            public BlogsEntry fetchByG_LtD_NeS_First(long groupId, Date displayDate,
12023                    int status, OrderByComparator orderByComparator)
12024                    throws SystemException {
12025                    List<BlogsEntry> list = findByG_LtD_NeS(groupId, displayDate, status,
12026                                    0, 1, orderByComparator);
12027    
12028                    if (!list.isEmpty()) {
12029                            return list.get(0);
12030                    }
12031    
12032                    return null;
12033            }
12034    
12035            /**
12036             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12037             *
12038             * @param groupId the group ID
12039             * @param displayDate the display date
12040             * @param status the status
12041             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12042             * @return the last matching blogs entry
12043             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12044             * @throws SystemException if a system exception occurred
12045             */
12046            public BlogsEntry findByG_LtD_NeS_Last(long groupId, Date displayDate,
12047                    int status, OrderByComparator orderByComparator)
12048                    throws NoSuchEntryException, SystemException {
12049                    BlogsEntry blogsEntry = fetchByG_LtD_NeS_Last(groupId, displayDate,
12050                                    status, orderByComparator);
12051    
12052                    if (blogsEntry != null) {
12053                            return blogsEntry;
12054                    }
12055    
12056                    StringBundler msg = new StringBundler(8);
12057    
12058                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12059    
12060                    msg.append("groupId=");
12061                    msg.append(groupId);
12062    
12063                    msg.append(", displayDate=");
12064                    msg.append(displayDate);
12065    
12066                    msg.append(", status=");
12067                    msg.append(status);
12068    
12069                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12070    
12071                    throw new NoSuchEntryException(msg.toString());
12072            }
12073    
12074            /**
12075             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12076             *
12077             * @param groupId the group ID
12078             * @param displayDate the display date
12079             * @param status the status
12080             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12081             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12082             * @throws SystemException if a system exception occurred
12083             */
12084            public BlogsEntry fetchByG_LtD_NeS_Last(long groupId, Date displayDate,
12085                    int status, OrderByComparator orderByComparator)
12086                    throws SystemException {
12087                    int count = countByG_LtD_NeS(groupId, displayDate, status);
12088    
12089                    List<BlogsEntry> list = findByG_LtD_NeS(groupId, displayDate, status,
12090                                    count - 1, count, orderByComparator);
12091    
12092                    if (!list.isEmpty()) {
12093                            return list.get(0);
12094                    }
12095    
12096                    return null;
12097            }
12098    
12099            /**
12100             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12101             *
12102             * @param entryId the primary key of the current blogs entry
12103             * @param groupId the group ID
12104             * @param displayDate the display date
12105             * @param status the status
12106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12107             * @return the previous, current, and next blogs entry
12108             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12109             * @throws SystemException if a system exception occurred
12110             */
12111            public BlogsEntry[] findByG_LtD_NeS_PrevAndNext(long entryId, long groupId,
12112                    Date displayDate, int status, OrderByComparator orderByComparator)
12113                    throws NoSuchEntryException, SystemException {
12114                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12115    
12116                    Session session = null;
12117    
12118                    try {
12119                            session = openSession();
12120    
12121                            BlogsEntry[] array = new BlogsEntryImpl[3];
12122    
12123                            array[0] = getByG_LtD_NeS_PrevAndNext(session, blogsEntry, groupId,
12124                                            displayDate, status, orderByComparator, true);
12125    
12126                            array[1] = blogsEntry;
12127    
12128                            array[2] = getByG_LtD_NeS_PrevAndNext(session, blogsEntry, groupId,
12129                                            displayDate, status, orderByComparator, false);
12130    
12131                            return array;
12132                    }
12133                    catch (Exception e) {
12134                            throw processException(e);
12135                    }
12136                    finally {
12137                            closeSession(session);
12138                    }
12139            }
12140    
12141            protected BlogsEntry getByG_LtD_NeS_PrevAndNext(Session session,
12142                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12143                    OrderByComparator orderByComparator, boolean previous) {
12144                    StringBundler query = null;
12145    
12146                    if (orderByComparator != null) {
12147                            query = new StringBundler(6 +
12148                                            (orderByComparator.getOrderByFields().length * 6));
12149                    }
12150                    else {
12151                            query = new StringBundler(3);
12152                    }
12153    
12154                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12155    
12156                    query.append(_FINDER_COLUMN_G_LTD_NES_GROUPID_2);
12157    
12158                    if (displayDate == null) {
12159                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_1);
12160                    }
12161                    else {
12162                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_2);
12163                    }
12164    
12165                    query.append(_FINDER_COLUMN_G_LTD_NES_STATUS_2);
12166    
12167                    if (orderByComparator != null) {
12168                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12169    
12170                            if (orderByConditionFields.length > 0) {
12171                                    query.append(WHERE_AND);
12172                            }
12173    
12174                            for (int i = 0; i < orderByConditionFields.length; i++) {
12175                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12176                                    query.append(orderByConditionFields[i]);
12177    
12178                                    if ((i + 1) < orderByConditionFields.length) {
12179                                            if (orderByComparator.isAscending() ^ previous) {
12180                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12181                                            }
12182                                            else {
12183                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12184                                            }
12185                                    }
12186                                    else {
12187                                            if (orderByComparator.isAscending() ^ previous) {
12188                                                    query.append(WHERE_GREATER_THAN);
12189                                            }
12190                                            else {
12191                                                    query.append(WHERE_LESSER_THAN);
12192                                            }
12193                                    }
12194                            }
12195    
12196                            query.append(ORDER_BY_CLAUSE);
12197    
12198                            String[] orderByFields = orderByComparator.getOrderByFields();
12199    
12200                            for (int i = 0; i < orderByFields.length; i++) {
12201                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12202                                    query.append(orderByFields[i]);
12203    
12204                                    if ((i + 1) < orderByFields.length) {
12205                                            if (orderByComparator.isAscending() ^ previous) {
12206                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12207                                            }
12208                                            else {
12209                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12210                                            }
12211                                    }
12212                                    else {
12213                                            if (orderByComparator.isAscending() ^ previous) {
12214                                                    query.append(ORDER_BY_ASC);
12215                                            }
12216                                            else {
12217                                                    query.append(ORDER_BY_DESC);
12218                                            }
12219                                    }
12220                            }
12221                    }
12222    
12223                    else {
12224                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12225                    }
12226    
12227                    String sql = query.toString();
12228    
12229                    Query q = session.createQuery(sql);
12230    
12231                    q.setFirstResult(0);
12232                    q.setMaxResults(2);
12233    
12234                    QueryPos qPos = QueryPos.getInstance(q);
12235    
12236                    qPos.add(groupId);
12237    
12238                    if (displayDate != null) {
12239                            qPos.add(CalendarUtil.getTimestamp(displayDate));
12240                    }
12241    
12242                    qPos.add(status);
12243    
12244                    if (orderByComparator != null) {
12245                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12246    
12247                            for (Object value : values) {
12248                                    qPos.add(value);
12249                            }
12250                    }
12251    
12252                    List<BlogsEntry> list = q.list();
12253    
12254                    if (list.size() == 2) {
12255                            return list.get(1);
12256                    }
12257                    else {
12258                            return null;
12259                    }
12260            }
12261    
12262            /**
12263             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12264             *
12265             * @param groupId the group ID
12266             * @param displayDate the display date
12267             * @param status the status
12268             * @return the matching blogs entries that the user has permission to view
12269             * @throws SystemException if a system exception occurred
12270             */
12271            public List<BlogsEntry> filterFindByG_LtD_NeS(long groupId,
12272                    Date displayDate, int status) throws SystemException {
12273                    return filterFindByG_LtD_NeS(groupId, displayDate, status,
12274                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12275            }
12276    
12277            /**
12278             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12279             *
12280             * <p>
12281             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12282             * </p>
12283             *
12284             * @param groupId the group ID
12285             * @param displayDate the display date
12286             * @param status the status
12287             * @param start the lower bound of the range of blogs entries
12288             * @param end the upper bound of the range of blogs entries (not inclusive)
12289             * @return the range of matching blogs entries that the user has permission to view
12290             * @throws SystemException if a system exception occurred
12291             */
12292            public List<BlogsEntry> filterFindByG_LtD_NeS(long groupId,
12293                    Date displayDate, int status, int start, int end)
12294                    throws SystemException {
12295                    return filterFindByG_LtD_NeS(groupId, displayDate, status, start, end,
12296                            null);
12297            }
12298    
12299            /**
12300             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12301             *
12302             * <p>
12303             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12304             * </p>
12305             *
12306             * @param groupId the group ID
12307             * @param displayDate the display date
12308             * @param status the status
12309             * @param start the lower bound of the range of blogs entries
12310             * @param end the upper bound of the range of blogs entries (not inclusive)
12311             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12312             * @return the ordered range of matching blogs entries that the user has permission to view
12313             * @throws SystemException if a system exception occurred
12314             */
12315            public List<BlogsEntry> filterFindByG_LtD_NeS(long groupId,
12316                    Date displayDate, int status, int start, int end,
12317                    OrderByComparator orderByComparator) throws SystemException {
12318                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12319                            return findByG_LtD_NeS(groupId, displayDate, status, start, end,
12320                                    orderByComparator);
12321                    }
12322    
12323                    StringBundler query = null;
12324    
12325                    if (orderByComparator != null) {
12326                            query = new StringBundler(5 +
12327                                            (orderByComparator.getOrderByFields().length * 3));
12328                    }
12329                    else {
12330                            query = new StringBundler(5);
12331                    }
12332    
12333                    if (getDB().isSupportsInlineDistinct()) {
12334                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12335                    }
12336                    else {
12337                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12338                    }
12339    
12340                    query.append(_FINDER_COLUMN_G_LTD_NES_GROUPID_2);
12341    
12342                    if (displayDate == null) {
12343                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_1);
12344                    }
12345                    else {
12346                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_2);
12347                    }
12348    
12349                    query.append(_FINDER_COLUMN_G_LTD_NES_STATUS_2);
12350    
12351                    if (!getDB().isSupportsInlineDistinct()) {
12352                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12353                    }
12354    
12355                    if (orderByComparator != null) {
12356                            if (getDB().isSupportsInlineDistinct()) {
12357                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12358                                            orderByComparator);
12359                            }
12360                            else {
12361                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12362                                            orderByComparator);
12363                            }
12364                    }
12365    
12366                    else {
12367                            if (getDB().isSupportsInlineDistinct()) {
12368                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12369                            }
12370                            else {
12371                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12372                            }
12373                    }
12374    
12375                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12376                                    BlogsEntry.class.getName(),
12377                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12378    
12379                    Session session = null;
12380    
12381                    try {
12382                            session = openSession();
12383    
12384                            SQLQuery q = session.createSQLQuery(sql);
12385    
12386                            if (getDB().isSupportsInlineDistinct()) {
12387                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12388                            }
12389                            else {
12390                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12391                            }
12392    
12393                            QueryPos qPos = QueryPos.getInstance(q);
12394    
12395                            qPos.add(groupId);
12396    
12397                            if (displayDate != null) {
12398                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
12399                            }
12400    
12401                            qPos.add(status);
12402    
12403                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12404                    }
12405                    catch (Exception e) {
12406                            throw processException(e);
12407                    }
12408                    finally {
12409                            closeSession(session);
12410                    }
12411            }
12412    
12413            /**
12414             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12415             *
12416             * @param entryId the primary key of the current blogs entry
12417             * @param groupId the group ID
12418             * @param displayDate the display date
12419             * @param status the status
12420             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12421             * @return the previous, current, and next blogs entry
12422             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12423             * @throws SystemException if a system exception occurred
12424             */
12425            public BlogsEntry[] filterFindByG_LtD_NeS_PrevAndNext(long entryId,
12426                    long groupId, Date displayDate, int status,
12427                    OrderByComparator orderByComparator)
12428                    throws NoSuchEntryException, SystemException {
12429                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12430                            return findByG_LtD_NeS_PrevAndNext(entryId, groupId, displayDate,
12431                                    status, orderByComparator);
12432                    }
12433    
12434                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12435    
12436                    Session session = null;
12437    
12438                    try {
12439                            session = openSession();
12440    
12441                            BlogsEntry[] array = new BlogsEntryImpl[3];
12442    
12443                            array[0] = filterGetByG_LtD_NeS_PrevAndNext(session, blogsEntry,
12444                                            groupId, displayDate, status, orderByComparator, true);
12445    
12446                            array[1] = blogsEntry;
12447    
12448                            array[2] = filterGetByG_LtD_NeS_PrevAndNext(session, blogsEntry,
12449                                            groupId, displayDate, status, orderByComparator, false);
12450    
12451                            return array;
12452                    }
12453                    catch (Exception e) {
12454                            throw processException(e);
12455                    }
12456                    finally {
12457                            closeSession(session);
12458                    }
12459            }
12460    
12461            protected BlogsEntry filterGetByG_LtD_NeS_PrevAndNext(Session session,
12462                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12463                    OrderByComparator orderByComparator, boolean previous) {
12464                    StringBundler query = null;
12465    
12466                    if (orderByComparator != null) {
12467                            query = new StringBundler(6 +
12468                                            (orderByComparator.getOrderByFields().length * 6));
12469                    }
12470                    else {
12471                            query = new StringBundler(3);
12472                    }
12473    
12474                    if (getDB().isSupportsInlineDistinct()) {
12475                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12476                    }
12477                    else {
12478                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12479                    }
12480    
12481                    query.append(_FINDER_COLUMN_G_LTD_NES_GROUPID_2);
12482    
12483                    if (displayDate == null) {
12484                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_1);
12485                    }
12486                    else {
12487                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_2);
12488                    }
12489    
12490                    query.append(_FINDER_COLUMN_G_LTD_NES_STATUS_2);
12491    
12492                    if (!getDB().isSupportsInlineDistinct()) {
12493                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12494                    }
12495    
12496                    if (orderByComparator != null) {
12497                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12498    
12499                            if (orderByConditionFields.length > 0) {
12500                                    query.append(WHERE_AND);
12501                            }
12502    
12503                            for (int i = 0; i < orderByConditionFields.length; i++) {
12504                                    if (getDB().isSupportsInlineDistinct()) {
12505                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12506                                    }
12507                                    else {
12508                                            query.append(_ORDER_BY_ENTITY_TABLE);
12509                                    }
12510    
12511                                    query.append(orderByConditionFields[i]);
12512    
12513                                    if ((i + 1) < orderByConditionFields.length) {
12514                                            if (orderByComparator.isAscending() ^ previous) {
12515                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12516                                            }
12517                                            else {
12518                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12519                                            }
12520                                    }
12521                                    else {
12522                                            if (orderByComparator.isAscending() ^ previous) {
12523                                                    query.append(WHERE_GREATER_THAN);
12524                                            }
12525                                            else {
12526                                                    query.append(WHERE_LESSER_THAN);
12527                                            }
12528                                    }
12529                            }
12530    
12531                            query.append(ORDER_BY_CLAUSE);
12532    
12533                            String[] orderByFields = orderByComparator.getOrderByFields();
12534    
12535                            for (int i = 0; i < orderByFields.length; i++) {
12536                                    if (getDB().isSupportsInlineDistinct()) {
12537                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12538                                    }
12539                                    else {
12540                                            query.append(_ORDER_BY_ENTITY_TABLE);
12541                                    }
12542    
12543                                    query.append(orderByFields[i]);
12544    
12545                                    if ((i + 1) < orderByFields.length) {
12546                                            if (orderByComparator.isAscending() ^ previous) {
12547                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12548                                            }
12549                                            else {
12550                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12551                                            }
12552                                    }
12553                                    else {
12554                                            if (orderByComparator.isAscending() ^ previous) {
12555                                                    query.append(ORDER_BY_ASC);
12556                                            }
12557                                            else {
12558                                                    query.append(ORDER_BY_DESC);
12559                                            }
12560                                    }
12561                            }
12562                    }
12563    
12564                    else {
12565                            if (getDB().isSupportsInlineDistinct()) {
12566                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12567                            }
12568                            else {
12569                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12570                            }
12571                    }
12572    
12573                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12574                                    BlogsEntry.class.getName(),
12575                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12576    
12577                    SQLQuery q = session.createSQLQuery(sql);
12578    
12579                    q.setFirstResult(0);
12580                    q.setMaxResults(2);
12581    
12582                    if (getDB().isSupportsInlineDistinct()) {
12583                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12584                    }
12585                    else {
12586                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12587                    }
12588    
12589                    QueryPos qPos = QueryPos.getInstance(q);
12590    
12591                    qPos.add(groupId);
12592    
12593                    if (displayDate != null) {
12594                            qPos.add(CalendarUtil.getTimestamp(displayDate));
12595                    }
12596    
12597                    qPos.add(status);
12598    
12599                    if (orderByComparator != null) {
12600                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12601    
12602                            for (Object value : values) {
12603                                    qPos.add(value);
12604                            }
12605                    }
12606    
12607                    List<BlogsEntry> list = q.list();
12608    
12609                    if (list.size() == 2) {
12610                            return list.get(1);
12611                    }
12612                    else {
12613                            return null;
12614                    }
12615            }
12616    
12617            /**
12618             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12619             *
12620             * @param groupId the group ID
12621             * @param displayDate the display date
12622             * @param status the status
12623             * @return the matching blogs entries
12624             * @throws SystemException if a system exception occurred
12625             */
12626            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12627                    int status) throws SystemException {
12628                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
12629                            QueryUtil.ALL_POS, null);
12630            }
12631    
12632            /**
12633             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12634             *
12635             * <p>
12636             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12637             * </p>
12638             *
12639             * @param groupId the group ID
12640             * @param displayDate the display date
12641             * @param status the status
12642             * @param start the lower bound of the range of blogs entries
12643             * @param end the upper bound of the range of blogs entries (not inclusive)
12644             * @return the range of matching blogs entries
12645             * @throws SystemException if a system exception occurred
12646             */
12647            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12648                    int status, int start, int end) throws SystemException {
12649                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
12650            }
12651    
12652            /**
12653             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12654             *
12655             * <p>
12656             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
12657             * </p>
12658             *
12659             * @param groupId the group ID
12660             * @param displayDate the display date
12661             * @param status the status
12662             * @param start the lower bound of the range of blogs entries
12663             * @param end the upper bound of the range of blogs entries (not inclusive)
12664             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12665             * @return the ordered range of matching blogs entries
12666             * @throws SystemException if a system exception occurred
12667             */
12668            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12669                    int status, int start, int end, OrderByComparator orderByComparator)
12670                    throws SystemException {
12671                    FinderPath finderPath = null;
12672                    Object[] finderArgs = null;
12673    
12674                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
12675                    finderArgs = new Object[] {
12676                                    groupId, displayDate, status,
12677                                    
12678                                    start, end, orderByComparator
12679                            };
12680    
12681                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
12682                                    finderArgs, this);
12683    
12684                    if ((list != null) && !list.isEmpty()) {
12685                            for (BlogsEntry blogsEntry : list) {
12686                                    if ((groupId != blogsEntry.getGroupId()) ||
12687                                                    !Validator.equals(displayDate,
12688                                                            blogsEntry.getDisplayDate()) ||
12689                                                    (status != blogsEntry.getStatus())) {
12690                                            list = null;
12691    
12692                                            break;
12693                                    }
12694                            }
12695                    }
12696    
12697                    if (list == null) {
12698                            StringBundler query = null;
12699    
12700                            if (orderByComparator != null) {
12701                                    query = new StringBundler(5 +
12702                                                    (orderByComparator.getOrderByFields().length * 3));
12703                            }
12704                            else {
12705                                    query = new StringBundler(5);
12706                            }
12707    
12708                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12709    
12710                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12711    
12712                            if (displayDate == null) {
12713                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12714                            }
12715                            else {
12716                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12717                            }
12718    
12719                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12720    
12721                            if (orderByComparator != null) {
12722                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12723                                            orderByComparator);
12724                            }
12725    
12726                            else {
12727                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12728                            }
12729    
12730                            String sql = query.toString();
12731    
12732                            Session session = null;
12733    
12734                            try {
12735                                    session = openSession();
12736    
12737                                    Query q = session.createQuery(sql);
12738    
12739                                    QueryPos qPos = QueryPos.getInstance(q);
12740    
12741                                    qPos.add(groupId);
12742    
12743                                    if (displayDate != null) {
12744                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
12745                                    }
12746    
12747                                    qPos.add(status);
12748    
12749                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
12750                                                    end);
12751                            }
12752                            catch (Exception e) {
12753                                    throw processException(e);
12754                            }
12755                            finally {
12756                                    if (list == null) {
12757                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
12758                                    }
12759                                    else {
12760                                            cacheResult(list);
12761    
12762                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
12763                                    }
12764    
12765                                    closeSession(session);
12766                            }
12767                    }
12768    
12769                    return list;
12770            }
12771    
12772            /**
12773             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12774             *
12775             * @param groupId the group ID
12776             * @param displayDate the display date
12777             * @param status the status
12778             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12779             * @return the first matching blogs entry
12780             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12781             * @throws SystemException if a system exception occurred
12782             */
12783            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
12784                    int status, OrderByComparator orderByComparator)
12785                    throws NoSuchEntryException, SystemException {
12786                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
12787                                    status, orderByComparator);
12788    
12789                    if (blogsEntry != null) {
12790                            return blogsEntry;
12791                    }
12792    
12793                    StringBundler msg = new StringBundler(8);
12794    
12795                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12796    
12797                    msg.append("groupId=");
12798                    msg.append(groupId);
12799    
12800                    msg.append(", displayDate=");
12801                    msg.append(displayDate);
12802    
12803                    msg.append(", status=");
12804                    msg.append(status);
12805    
12806                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12807    
12808                    throw new NoSuchEntryException(msg.toString());
12809            }
12810    
12811            /**
12812             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12813             *
12814             * @param groupId the group ID
12815             * @param displayDate the display date
12816             * @param status the status
12817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12818             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12819             * @throws SystemException if a system exception occurred
12820             */
12821            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
12822                    int status, OrderByComparator orderByComparator)
12823                    throws SystemException {
12824                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
12825                                    1, orderByComparator);
12826    
12827                    if (!list.isEmpty()) {
12828                            return list.get(0);
12829                    }
12830    
12831                    return null;
12832            }
12833    
12834            /**
12835             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12836             *
12837             * @param groupId the group ID
12838             * @param displayDate the display date
12839             * @param status the status
12840             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12841             * @return the last matching blogs entry
12842             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12843             * @throws SystemException if a system exception occurred
12844             */
12845            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
12846                    int status, OrderByComparator orderByComparator)
12847                    throws NoSuchEntryException, SystemException {
12848                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
12849                                    status, orderByComparator);
12850    
12851                    if (blogsEntry != null) {
12852                            return blogsEntry;
12853                    }
12854    
12855                    StringBundler msg = new StringBundler(8);
12856    
12857                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12858    
12859                    msg.append("groupId=");
12860                    msg.append(groupId);
12861    
12862                    msg.append(", displayDate=");
12863                    msg.append(displayDate);
12864    
12865                    msg.append(", status=");
12866                    msg.append(status);
12867    
12868                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12869    
12870                    throw new NoSuchEntryException(msg.toString());
12871            }
12872    
12873            /**
12874             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12875             *
12876             * @param groupId the group ID
12877             * @param displayDate the display date
12878             * @param status the status
12879             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12880             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12881             * @throws SystemException if a system exception occurred
12882             */
12883            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
12884                    int status, OrderByComparator orderByComparator)
12885                    throws SystemException {
12886                    int count = countByG_LtD_S(groupId, displayDate, status);
12887    
12888                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
12889                                    count - 1, count, orderByComparator);
12890    
12891                    if (!list.isEmpty()) {
12892                            return list.get(0);
12893                    }
12894    
12895                    return null;
12896            }
12897    
12898            /**
12899             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12900             *
12901             * @param entryId the primary key of the current blogs entry
12902             * @param groupId the group ID
12903             * @param displayDate the display date
12904             * @param status the status
12905             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12906             * @return the previous, current, and next blogs entry
12907             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12908             * @throws SystemException if a system exception occurred
12909             */
12910            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
12911                    Date displayDate, int status, OrderByComparator orderByComparator)
12912                    throws NoSuchEntryException, SystemException {
12913                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12914    
12915                    Session session = null;
12916    
12917                    try {
12918                            session = openSession();
12919    
12920                            BlogsEntry[] array = new BlogsEntryImpl[3];
12921    
12922                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12923                                            displayDate, status, orderByComparator, true);
12924    
12925                            array[1] = blogsEntry;
12926    
12927                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12928                                            displayDate, status, orderByComparator, false);
12929    
12930                            return array;
12931                    }
12932                    catch (Exception e) {
12933                            throw processException(e);
12934                    }
12935                    finally {
12936                            closeSession(session);
12937                    }
12938            }
12939    
12940            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
12941                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12942                    OrderByComparator orderByComparator, boolean previous) {
12943                    StringBundler query = null;
12944    
12945                    if (orderByComparator != null) {
12946                            query = new StringBundler(6 +
12947                                            (orderByComparator.getOrderByFields().length * 6));
12948                    }
12949                    else {
12950                            query = new StringBundler(3);
12951                    }
12952    
12953                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12954    
12955                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12956    
12957                    if (displayDate == null) {
12958                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12959                    }
12960                    else {
12961                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12962                    }
12963    
12964                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12965    
12966                    if (orderByComparator != null) {
12967                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12968    
12969                            if (orderByConditionFields.length > 0) {
12970                                    query.append(WHERE_AND);
12971                            }
12972    
12973                            for (int i = 0; i < orderByConditionFields.length; i++) {
12974                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12975                                    query.append(orderByConditionFields[i]);
12976    
12977                                    if ((i + 1) < orderByConditionFields.length) {
12978                                            if (orderByComparator.isAscending() ^ previous) {
12979                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12980                                            }
12981                                            else {
12982                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12983                                            }
12984                                    }
12985                                    else {
12986                                            if (orderByComparator.isAscending() ^ previous) {
12987                                                    query.append(WHERE_GREATER_THAN);
12988                                            }
12989                                            else {
12990                                                    query.append(WHERE_LESSER_THAN);
12991                                            }
12992                                    }
12993                            }
12994    
12995                            query.append(ORDER_BY_CLAUSE);
12996    
12997                            String[] orderByFields = orderByComparator.getOrderByFields();
12998    
12999                            for (int i = 0; i < orderByFields.length; i++) {
13000                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13001                                    query.append(orderByFields[i]);
13002    
13003                                    if ((i + 1) < orderByFields.length) {
13004                                            if (orderByComparator.isAscending() ^ previous) {
13005                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13006                                            }
13007                                            else {
13008                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13009                                            }
13010                                    }
13011                                    else {
13012                                            if (orderByComparator.isAscending() ^ previous) {
13013                                                    query.append(ORDER_BY_ASC);
13014                                            }
13015                                            else {
13016                                                    query.append(ORDER_BY_DESC);
13017                                            }
13018                                    }
13019                            }
13020                    }
13021    
13022                    else {
13023                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13024                    }
13025    
13026                    String sql = query.toString();
13027    
13028                    Query q = session.createQuery(sql);
13029    
13030                    q.setFirstResult(0);
13031                    q.setMaxResults(2);
13032    
13033                    QueryPos qPos = QueryPos.getInstance(q);
13034    
13035                    qPos.add(groupId);
13036    
13037                    if (displayDate != null) {
13038                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13039                    }
13040    
13041                    qPos.add(status);
13042    
13043                    if (orderByComparator != null) {
13044                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13045    
13046                            for (Object value : values) {
13047                                    qPos.add(value);
13048                            }
13049                    }
13050    
13051                    List<BlogsEntry> list = q.list();
13052    
13053                    if (list.size() == 2) {
13054                            return list.get(1);
13055                    }
13056                    else {
13057                            return null;
13058                    }
13059            }
13060    
13061            /**
13062             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13063             *
13064             * @param groupId the group ID
13065             * @param displayDate the display date
13066             * @param status the status
13067             * @return the matching blogs entries that the user has permission to view
13068             * @throws SystemException if a system exception occurred
13069             */
13070            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
13071                    int status) throws SystemException {
13072                    return filterFindByG_LtD_S(groupId, displayDate, status,
13073                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13074            }
13075    
13076            /**
13077             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13078             *
13079             * <p>
13080             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13081             * </p>
13082             *
13083             * @param groupId the group ID
13084             * @param displayDate the display date
13085             * @param status the status
13086             * @param start the lower bound of the range of blogs entries
13087             * @param end the upper bound of the range of blogs entries (not inclusive)
13088             * @return the range of matching blogs entries that the user has permission to view
13089             * @throws SystemException if a system exception occurred
13090             */
13091            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
13092                    int status, int start, int end) throws SystemException {
13093                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
13094                            null);
13095            }
13096    
13097            /**
13098             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13099             *
13100             * <p>
13101             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13102             * </p>
13103             *
13104             * @param groupId the group ID
13105             * @param displayDate the display date
13106             * @param status the status
13107             * @param start the lower bound of the range of blogs entries
13108             * @param end the upper bound of the range of blogs entries (not inclusive)
13109             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13110             * @return the ordered range of matching blogs entries that the user has permission to view
13111             * @throws SystemException if a system exception occurred
13112             */
13113            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
13114                    int status, int start, int end, OrderByComparator orderByComparator)
13115                    throws SystemException {
13116                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13117                            return findByG_LtD_S(groupId, displayDate, status, start, end,
13118                                    orderByComparator);
13119                    }
13120    
13121                    StringBundler query = null;
13122    
13123                    if (orderByComparator != null) {
13124                            query = new StringBundler(5 +
13125                                            (orderByComparator.getOrderByFields().length * 3));
13126                    }
13127                    else {
13128                            query = new StringBundler(5);
13129                    }
13130    
13131                    if (getDB().isSupportsInlineDistinct()) {
13132                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13133                    }
13134                    else {
13135                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13136                    }
13137    
13138                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13139    
13140                    if (displayDate == null) {
13141                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13142                    }
13143                    else {
13144                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13145                    }
13146    
13147                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13148    
13149                    if (!getDB().isSupportsInlineDistinct()) {
13150                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13151                    }
13152    
13153                    if (orderByComparator != null) {
13154                            if (getDB().isSupportsInlineDistinct()) {
13155                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13156                                            orderByComparator);
13157                            }
13158                            else {
13159                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13160                                            orderByComparator);
13161                            }
13162                    }
13163    
13164                    else {
13165                            if (getDB().isSupportsInlineDistinct()) {
13166                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13167                            }
13168                            else {
13169                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13170                            }
13171                    }
13172    
13173                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13174                                    BlogsEntry.class.getName(),
13175                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13176    
13177                    Session session = null;
13178    
13179                    try {
13180                            session = openSession();
13181    
13182                            SQLQuery q = session.createSQLQuery(sql);
13183    
13184                            if (getDB().isSupportsInlineDistinct()) {
13185                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13186                            }
13187                            else {
13188                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13189                            }
13190    
13191                            QueryPos qPos = QueryPos.getInstance(q);
13192    
13193                            qPos.add(groupId);
13194    
13195                            if (displayDate != null) {
13196                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
13197                            }
13198    
13199                            qPos.add(status);
13200    
13201                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13202                    }
13203                    catch (Exception e) {
13204                            throw processException(e);
13205                    }
13206                    finally {
13207                            closeSession(session);
13208                    }
13209            }
13210    
13211            /**
13212             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13213             *
13214             * @param entryId the primary key of the current blogs entry
13215             * @param groupId the group ID
13216             * @param displayDate the display date
13217             * @param status the status
13218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13219             * @return the previous, current, and next blogs entry
13220             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13221             * @throws SystemException if a system exception occurred
13222             */
13223            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
13224                    long groupId, Date displayDate, int status,
13225                    OrderByComparator orderByComparator)
13226                    throws NoSuchEntryException, SystemException {
13227                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13228                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
13229                                    status, orderByComparator);
13230                    }
13231    
13232                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13233    
13234                    Session session = null;
13235    
13236                    try {
13237                            session = openSession();
13238    
13239                            BlogsEntry[] array = new BlogsEntryImpl[3];
13240    
13241                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
13242                                            groupId, displayDate, status, orderByComparator, true);
13243    
13244                            array[1] = blogsEntry;
13245    
13246                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
13247                                            groupId, displayDate, status, orderByComparator, false);
13248    
13249                            return array;
13250                    }
13251                    catch (Exception e) {
13252                            throw processException(e);
13253                    }
13254                    finally {
13255                            closeSession(session);
13256                    }
13257            }
13258    
13259            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
13260                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13261                    OrderByComparator orderByComparator, boolean previous) {
13262                    StringBundler query = null;
13263    
13264                    if (orderByComparator != null) {
13265                            query = new StringBundler(6 +
13266                                            (orderByComparator.getOrderByFields().length * 6));
13267                    }
13268                    else {
13269                            query = new StringBundler(3);
13270                    }
13271    
13272                    if (getDB().isSupportsInlineDistinct()) {
13273                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13274                    }
13275                    else {
13276                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13277                    }
13278    
13279                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13280    
13281                    if (displayDate == null) {
13282                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13283                    }
13284                    else {
13285                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13286                    }
13287    
13288                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13289    
13290                    if (!getDB().isSupportsInlineDistinct()) {
13291                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13292                    }
13293    
13294                    if (orderByComparator != null) {
13295                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13296    
13297                            if (orderByConditionFields.length > 0) {
13298                                    query.append(WHERE_AND);
13299                            }
13300    
13301                            for (int i = 0; i < orderByConditionFields.length; i++) {
13302                                    if (getDB().isSupportsInlineDistinct()) {
13303                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13304                                    }
13305                                    else {
13306                                            query.append(_ORDER_BY_ENTITY_TABLE);
13307                                    }
13308    
13309                                    query.append(orderByConditionFields[i]);
13310    
13311                                    if ((i + 1) < orderByConditionFields.length) {
13312                                            if (orderByComparator.isAscending() ^ previous) {
13313                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13314                                            }
13315                                            else {
13316                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13317                                            }
13318                                    }
13319                                    else {
13320                                            if (orderByComparator.isAscending() ^ previous) {
13321                                                    query.append(WHERE_GREATER_THAN);
13322                                            }
13323                                            else {
13324                                                    query.append(WHERE_LESSER_THAN);
13325                                            }
13326                                    }
13327                            }
13328    
13329                            query.append(ORDER_BY_CLAUSE);
13330    
13331                            String[] orderByFields = orderByComparator.getOrderByFields();
13332    
13333                            for (int i = 0; i < orderByFields.length; i++) {
13334                                    if (getDB().isSupportsInlineDistinct()) {
13335                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13336                                    }
13337                                    else {
13338                                            query.append(_ORDER_BY_ENTITY_TABLE);
13339                                    }
13340    
13341                                    query.append(orderByFields[i]);
13342    
13343                                    if ((i + 1) < orderByFields.length) {
13344                                            if (orderByComparator.isAscending() ^ previous) {
13345                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13346                                            }
13347                                            else {
13348                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13349                                            }
13350                                    }
13351                                    else {
13352                                            if (orderByComparator.isAscending() ^ previous) {
13353                                                    query.append(ORDER_BY_ASC);
13354                                            }
13355                                            else {
13356                                                    query.append(ORDER_BY_DESC);
13357                                            }
13358                                    }
13359                            }
13360                    }
13361    
13362                    else {
13363                            if (getDB().isSupportsInlineDistinct()) {
13364                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13365                            }
13366                            else {
13367                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13368                            }
13369                    }
13370    
13371                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13372                                    BlogsEntry.class.getName(),
13373                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13374    
13375                    SQLQuery q = session.createSQLQuery(sql);
13376    
13377                    q.setFirstResult(0);
13378                    q.setMaxResults(2);
13379    
13380                    if (getDB().isSupportsInlineDistinct()) {
13381                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13382                    }
13383                    else {
13384                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13385                    }
13386    
13387                    QueryPos qPos = QueryPos.getInstance(q);
13388    
13389                    qPos.add(groupId);
13390    
13391                    if (displayDate != null) {
13392                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13393                    }
13394    
13395                    qPos.add(status);
13396    
13397                    if (orderByComparator != null) {
13398                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13399    
13400                            for (Object value : values) {
13401                                    qPos.add(value);
13402                            }
13403                    }
13404    
13405                    List<BlogsEntry> list = q.list();
13406    
13407                    if (list.size() == 2) {
13408                            return list.get(1);
13409                    }
13410                    else {
13411                            return null;
13412                    }
13413            }
13414    
13415            /**
13416             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13417             *
13418             * @param groupId the group ID
13419             * @param userId the user ID
13420             * @param displayDate the display date
13421             * @param status the status
13422             * @return the matching blogs entries
13423             * @throws SystemException if a system exception occurred
13424             */
13425            public List<BlogsEntry> findByG_U_LtD_NeS(long groupId, long userId,
13426                    Date displayDate, int status) throws SystemException {
13427                    return findByG_U_LtD_NeS(groupId, userId, displayDate, status,
13428                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13429            }
13430    
13431            /**
13432             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13433             *
13434             * <p>
13435             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13436             * </p>
13437             *
13438             * @param groupId the group ID
13439             * @param userId the user ID
13440             * @param displayDate the display date
13441             * @param status the status
13442             * @param start the lower bound of the range of blogs entries
13443             * @param end the upper bound of the range of blogs entries (not inclusive)
13444             * @return the range of matching blogs entries
13445             * @throws SystemException if a system exception occurred
13446             */
13447            public List<BlogsEntry> findByG_U_LtD_NeS(long groupId, long userId,
13448                    Date displayDate, int status, int start, int end)
13449                    throws SystemException {
13450                    return findByG_U_LtD_NeS(groupId, userId, displayDate, status, start,
13451                            end, null);
13452            }
13453    
13454            /**
13455             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13456             *
13457             * <p>
13458             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13459             * </p>
13460             *
13461             * @param groupId the group ID
13462             * @param userId the user ID
13463             * @param displayDate the display date
13464             * @param status the status
13465             * @param start the lower bound of the range of blogs entries
13466             * @param end the upper bound of the range of blogs entries (not inclusive)
13467             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13468             * @return the ordered range of matching blogs entries
13469             * @throws SystemException if a system exception occurred
13470             */
13471            public List<BlogsEntry> findByG_U_LtD_NeS(long groupId, long userId,
13472                    Date displayDate, int status, int start, int end,
13473                    OrderByComparator orderByComparator) throws SystemException {
13474                    FinderPath finderPath = null;
13475                    Object[] finderArgs = null;
13476    
13477                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NES;
13478                    finderArgs = new Object[] {
13479                                    groupId, userId, displayDate, status,
13480                                    
13481                                    start, end, orderByComparator
13482                            };
13483    
13484                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13485                                    finderArgs, this);
13486    
13487                    if ((list != null) && !list.isEmpty()) {
13488                            for (BlogsEntry blogsEntry : list) {
13489                                    if ((groupId != blogsEntry.getGroupId()) ||
13490                                                    (userId != blogsEntry.getUserId()) ||
13491                                                    !Validator.equals(displayDate,
13492                                                            blogsEntry.getDisplayDate()) ||
13493                                                    (status != blogsEntry.getStatus())) {
13494                                            list = null;
13495    
13496                                            break;
13497                                    }
13498                            }
13499                    }
13500    
13501                    if (list == null) {
13502                            StringBundler query = null;
13503    
13504                            if (orderByComparator != null) {
13505                                    query = new StringBundler(6 +
13506                                                    (orderByComparator.getOrderByFields().length * 3));
13507                            }
13508                            else {
13509                                    query = new StringBundler(6);
13510                            }
13511    
13512                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13513    
13514                            query.append(_FINDER_COLUMN_G_U_LTD_NES_GROUPID_2);
13515    
13516                            query.append(_FINDER_COLUMN_G_U_LTD_NES_USERID_2);
13517    
13518                            if (displayDate == null) {
13519                                    query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_1);
13520                            }
13521                            else {
13522                                    query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_2);
13523                            }
13524    
13525                            query.append(_FINDER_COLUMN_G_U_LTD_NES_STATUS_2);
13526    
13527                            if (orderByComparator != null) {
13528                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13529                                            orderByComparator);
13530                            }
13531    
13532                            else {
13533                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13534                            }
13535    
13536                            String sql = query.toString();
13537    
13538                            Session session = null;
13539    
13540                            try {
13541                                    session = openSession();
13542    
13543                                    Query q = session.createQuery(sql);
13544    
13545                                    QueryPos qPos = QueryPos.getInstance(q);
13546    
13547                                    qPos.add(groupId);
13548    
13549                                    qPos.add(userId);
13550    
13551                                    if (displayDate != null) {
13552                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13553                                    }
13554    
13555                                    qPos.add(status);
13556    
13557                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
13558                                                    end);
13559                            }
13560                            catch (Exception e) {
13561                                    throw processException(e);
13562                            }
13563                            finally {
13564                                    if (list == null) {
13565                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
13566                                    }
13567                                    else {
13568                                            cacheResult(list);
13569    
13570                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
13571                                    }
13572    
13573                                    closeSession(session);
13574                            }
13575                    }
13576    
13577                    return list;
13578            }
13579    
13580            /**
13581             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13582             *
13583             * @param groupId the group ID
13584             * @param userId the user ID
13585             * @param displayDate the display date
13586             * @param status the status
13587             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13588             * @return the first matching blogs entry
13589             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13590             * @throws SystemException if a system exception occurred
13591             */
13592            public BlogsEntry findByG_U_LtD_NeS_First(long groupId, long userId,
13593                    Date displayDate, int status, OrderByComparator orderByComparator)
13594                    throws NoSuchEntryException, SystemException {
13595                    BlogsEntry blogsEntry = fetchByG_U_LtD_NeS_First(groupId, userId,
13596                                    displayDate, status, orderByComparator);
13597    
13598                    if (blogsEntry != null) {
13599                            return blogsEntry;
13600                    }
13601    
13602                    StringBundler msg = new StringBundler(10);
13603    
13604                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13605    
13606                    msg.append("groupId=");
13607                    msg.append(groupId);
13608    
13609                    msg.append(", userId=");
13610                    msg.append(userId);
13611    
13612                    msg.append(", displayDate=");
13613                    msg.append(displayDate);
13614    
13615                    msg.append(", status=");
13616                    msg.append(status);
13617    
13618                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13619    
13620                    throw new NoSuchEntryException(msg.toString());
13621            }
13622    
13623            /**
13624             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13625             *
13626             * @param groupId the group ID
13627             * @param userId the user ID
13628             * @param displayDate the display date
13629             * @param status the status
13630             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13631             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13632             * @throws SystemException if a system exception occurred
13633             */
13634            public BlogsEntry fetchByG_U_LtD_NeS_First(long groupId, long userId,
13635                    Date displayDate, int status, OrderByComparator orderByComparator)
13636                    throws SystemException {
13637                    List<BlogsEntry> list = findByG_U_LtD_NeS(groupId, userId, displayDate,
13638                                    status, 0, 1, orderByComparator);
13639    
13640                    if (!list.isEmpty()) {
13641                            return list.get(0);
13642                    }
13643    
13644                    return null;
13645            }
13646    
13647            /**
13648             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13649             *
13650             * @param groupId the group ID
13651             * @param userId the user ID
13652             * @param displayDate the display date
13653             * @param status the status
13654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13655             * @return the last matching blogs entry
13656             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13657             * @throws SystemException if a system exception occurred
13658             */
13659            public BlogsEntry findByG_U_LtD_NeS_Last(long groupId, long userId,
13660                    Date displayDate, int status, OrderByComparator orderByComparator)
13661                    throws NoSuchEntryException, SystemException {
13662                    BlogsEntry blogsEntry = fetchByG_U_LtD_NeS_Last(groupId, userId,
13663                                    displayDate, status, orderByComparator);
13664    
13665                    if (blogsEntry != null) {
13666                            return blogsEntry;
13667                    }
13668    
13669                    StringBundler msg = new StringBundler(10);
13670    
13671                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13672    
13673                    msg.append("groupId=");
13674                    msg.append(groupId);
13675    
13676                    msg.append(", userId=");
13677                    msg.append(userId);
13678    
13679                    msg.append(", displayDate=");
13680                    msg.append(displayDate);
13681    
13682                    msg.append(", status=");
13683                    msg.append(status);
13684    
13685                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13686    
13687                    throw new NoSuchEntryException(msg.toString());
13688            }
13689    
13690            /**
13691             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13692             *
13693             * @param groupId the group ID
13694             * @param userId the user ID
13695             * @param displayDate the display date
13696             * @param status the status
13697             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13698             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13699             * @throws SystemException if a system exception occurred
13700             */
13701            public BlogsEntry fetchByG_U_LtD_NeS_Last(long groupId, long userId,
13702                    Date displayDate, int status, OrderByComparator orderByComparator)
13703                    throws SystemException {
13704                    int count = countByG_U_LtD_NeS(groupId, userId, displayDate, status);
13705    
13706                    List<BlogsEntry> list = findByG_U_LtD_NeS(groupId, userId, displayDate,
13707                                    status, count - 1, count, orderByComparator);
13708    
13709                    if (!list.isEmpty()) {
13710                            return list.get(0);
13711                    }
13712    
13713                    return null;
13714            }
13715    
13716            /**
13717             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13718             *
13719             * @param entryId the primary key of the current blogs entry
13720             * @param groupId the group ID
13721             * @param userId the user ID
13722             * @param displayDate the display date
13723             * @param status the status
13724             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13725             * @return the previous, current, and next blogs entry
13726             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13727             * @throws SystemException if a system exception occurred
13728             */
13729            public BlogsEntry[] findByG_U_LtD_NeS_PrevAndNext(long entryId,
13730                    long groupId, long userId, Date displayDate, int status,
13731                    OrderByComparator orderByComparator)
13732                    throws NoSuchEntryException, SystemException {
13733                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13734    
13735                    Session session = null;
13736    
13737                    try {
13738                            session = openSession();
13739    
13740                            BlogsEntry[] array = new BlogsEntryImpl[3];
13741    
13742                            array[0] = getByG_U_LtD_NeS_PrevAndNext(session, blogsEntry,
13743                                            groupId, userId, displayDate, status, orderByComparator,
13744                                            true);
13745    
13746                            array[1] = blogsEntry;
13747    
13748                            array[2] = getByG_U_LtD_NeS_PrevAndNext(session, blogsEntry,
13749                                            groupId, userId, displayDate, status, orderByComparator,
13750                                            false);
13751    
13752                            return array;
13753                    }
13754                    catch (Exception e) {
13755                            throw processException(e);
13756                    }
13757                    finally {
13758                            closeSession(session);
13759                    }
13760            }
13761    
13762            protected BlogsEntry getByG_U_LtD_NeS_PrevAndNext(Session session,
13763                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
13764                    int status, OrderByComparator orderByComparator, boolean previous) {
13765                    StringBundler query = null;
13766    
13767                    if (orderByComparator != null) {
13768                            query = new StringBundler(6 +
13769                                            (orderByComparator.getOrderByFields().length * 6));
13770                    }
13771                    else {
13772                            query = new StringBundler(3);
13773                    }
13774    
13775                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13776    
13777                    query.append(_FINDER_COLUMN_G_U_LTD_NES_GROUPID_2);
13778    
13779                    query.append(_FINDER_COLUMN_G_U_LTD_NES_USERID_2);
13780    
13781                    if (displayDate == null) {
13782                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_1);
13783                    }
13784                    else {
13785                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_2);
13786                    }
13787    
13788                    query.append(_FINDER_COLUMN_G_U_LTD_NES_STATUS_2);
13789    
13790                    if (orderByComparator != null) {
13791                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13792    
13793                            if (orderByConditionFields.length > 0) {
13794                                    query.append(WHERE_AND);
13795                            }
13796    
13797                            for (int i = 0; i < orderByConditionFields.length; i++) {
13798                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13799                                    query.append(orderByConditionFields[i]);
13800    
13801                                    if ((i + 1) < orderByConditionFields.length) {
13802                                            if (orderByComparator.isAscending() ^ previous) {
13803                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13804                                            }
13805                                            else {
13806                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13807                                            }
13808                                    }
13809                                    else {
13810                                            if (orderByComparator.isAscending() ^ previous) {
13811                                                    query.append(WHERE_GREATER_THAN);
13812                                            }
13813                                            else {
13814                                                    query.append(WHERE_LESSER_THAN);
13815                                            }
13816                                    }
13817                            }
13818    
13819                            query.append(ORDER_BY_CLAUSE);
13820    
13821                            String[] orderByFields = orderByComparator.getOrderByFields();
13822    
13823                            for (int i = 0; i < orderByFields.length; i++) {
13824                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13825                                    query.append(orderByFields[i]);
13826    
13827                                    if ((i + 1) < orderByFields.length) {
13828                                            if (orderByComparator.isAscending() ^ previous) {
13829                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13830                                            }
13831                                            else {
13832                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13833                                            }
13834                                    }
13835                                    else {
13836                                            if (orderByComparator.isAscending() ^ previous) {
13837                                                    query.append(ORDER_BY_ASC);
13838                                            }
13839                                            else {
13840                                                    query.append(ORDER_BY_DESC);
13841                                            }
13842                                    }
13843                            }
13844                    }
13845    
13846                    else {
13847                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13848                    }
13849    
13850                    String sql = query.toString();
13851    
13852                    Query q = session.createQuery(sql);
13853    
13854                    q.setFirstResult(0);
13855                    q.setMaxResults(2);
13856    
13857                    QueryPos qPos = QueryPos.getInstance(q);
13858    
13859                    qPos.add(groupId);
13860    
13861                    qPos.add(userId);
13862    
13863                    if (displayDate != null) {
13864                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13865                    }
13866    
13867                    qPos.add(status);
13868    
13869                    if (orderByComparator != null) {
13870                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13871    
13872                            for (Object value : values) {
13873                                    qPos.add(value);
13874                            }
13875                    }
13876    
13877                    List<BlogsEntry> list = q.list();
13878    
13879                    if (list.size() == 2) {
13880                            return list.get(1);
13881                    }
13882                    else {
13883                            return null;
13884                    }
13885            }
13886    
13887            /**
13888             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13889             *
13890             * @param groupId the group ID
13891             * @param userId the user ID
13892             * @param displayDate the display date
13893             * @param status the status
13894             * @return the matching blogs entries that the user has permission to view
13895             * @throws SystemException if a system exception occurred
13896             */
13897            public List<BlogsEntry> filterFindByG_U_LtD_NeS(long groupId, long userId,
13898                    Date displayDate, int status) throws SystemException {
13899                    return filterFindByG_U_LtD_NeS(groupId, userId, displayDate, status,
13900                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13901            }
13902    
13903            /**
13904             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13905             *
13906             * <p>
13907             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13908             * </p>
13909             *
13910             * @param groupId the group ID
13911             * @param userId the user ID
13912             * @param displayDate the display date
13913             * @param status the status
13914             * @param start the lower bound of the range of blogs entries
13915             * @param end the upper bound of the range of blogs entries (not inclusive)
13916             * @return the range of matching blogs entries that the user has permission to view
13917             * @throws SystemException if a system exception occurred
13918             */
13919            public List<BlogsEntry> filterFindByG_U_LtD_NeS(long groupId, long userId,
13920                    Date displayDate, int status, int start, int end)
13921                    throws SystemException {
13922                    return filterFindByG_U_LtD_NeS(groupId, userId, displayDate, status,
13923                            start, end, null);
13924            }
13925    
13926            /**
13927             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13928             *
13929             * <p>
13930             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
13931             * </p>
13932             *
13933             * @param groupId the group ID
13934             * @param userId the user ID
13935             * @param displayDate the display date
13936             * @param status the status
13937             * @param start the lower bound of the range of blogs entries
13938             * @param end the upper bound of the range of blogs entries (not inclusive)
13939             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13940             * @return the ordered range of matching blogs entries that the user has permission to view
13941             * @throws SystemException if a system exception occurred
13942             */
13943            public List<BlogsEntry> filterFindByG_U_LtD_NeS(long groupId, long userId,
13944                    Date displayDate, int status, int start, int end,
13945                    OrderByComparator orderByComparator) throws SystemException {
13946                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13947                            return findByG_U_LtD_NeS(groupId, userId, displayDate, status,
13948                                    start, end, orderByComparator);
13949                    }
13950    
13951                    StringBundler query = null;
13952    
13953                    if (orderByComparator != null) {
13954                            query = new StringBundler(6 +
13955                                            (orderByComparator.getOrderByFields().length * 3));
13956                    }
13957                    else {
13958                            query = new StringBundler(6);
13959                    }
13960    
13961                    if (getDB().isSupportsInlineDistinct()) {
13962                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13963                    }
13964                    else {
13965                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13966                    }
13967    
13968                    query.append(_FINDER_COLUMN_G_U_LTD_NES_GROUPID_2);
13969    
13970                    query.append(_FINDER_COLUMN_G_U_LTD_NES_USERID_2);
13971    
13972                    if (displayDate == null) {
13973                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_1);
13974                    }
13975                    else {
13976                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_2);
13977                    }
13978    
13979                    query.append(_FINDER_COLUMN_G_U_LTD_NES_STATUS_2);
13980    
13981                    if (!getDB().isSupportsInlineDistinct()) {
13982                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13983                    }
13984    
13985                    if (orderByComparator != null) {
13986                            if (getDB().isSupportsInlineDistinct()) {
13987                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13988                                            orderByComparator);
13989                            }
13990                            else {
13991                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13992                                            orderByComparator);
13993                            }
13994                    }
13995    
13996                    else {
13997                            if (getDB().isSupportsInlineDistinct()) {
13998                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13999                            }
14000                            else {
14001                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14002                            }
14003                    }
14004    
14005                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14006                                    BlogsEntry.class.getName(),
14007                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14008    
14009                    Session session = null;
14010    
14011                    try {
14012                            session = openSession();
14013    
14014                            SQLQuery q = session.createSQLQuery(sql);
14015    
14016                            if (getDB().isSupportsInlineDistinct()) {
14017                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14018                            }
14019                            else {
14020                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14021                            }
14022    
14023                            QueryPos qPos = QueryPos.getInstance(q);
14024    
14025                            qPos.add(groupId);
14026    
14027                            qPos.add(userId);
14028    
14029                            if (displayDate != null) {
14030                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14031                            }
14032    
14033                            qPos.add(status);
14034    
14035                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
14036                    }
14037                    catch (Exception e) {
14038                            throw processException(e);
14039                    }
14040                    finally {
14041                            closeSession(session);
14042                    }
14043            }
14044    
14045            /**
14046             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14047             *
14048             * @param entryId the primary key of the current blogs entry
14049             * @param groupId the group ID
14050             * @param userId the user ID
14051             * @param displayDate the display date
14052             * @param status the status
14053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14054             * @return the previous, current, and next blogs entry
14055             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14056             * @throws SystemException if a system exception occurred
14057             */
14058            public BlogsEntry[] filterFindByG_U_LtD_NeS_PrevAndNext(long entryId,
14059                    long groupId, long userId, Date displayDate, int status,
14060                    OrderByComparator orderByComparator)
14061                    throws NoSuchEntryException, SystemException {
14062                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14063                            return findByG_U_LtD_NeS_PrevAndNext(entryId, groupId, userId,
14064                                    displayDate, status, orderByComparator);
14065                    }
14066    
14067                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14068    
14069                    Session session = null;
14070    
14071                    try {
14072                            session = openSession();
14073    
14074                            BlogsEntry[] array = new BlogsEntryImpl[3];
14075    
14076                            array[0] = filterGetByG_U_LtD_NeS_PrevAndNext(session, blogsEntry,
14077                                            groupId, userId, displayDate, status, orderByComparator,
14078                                            true);
14079    
14080                            array[1] = blogsEntry;
14081    
14082                            array[2] = filterGetByG_U_LtD_NeS_PrevAndNext(session, blogsEntry,
14083                                            groupId, userId, displayDate, status, orderByComparator,
14084                                            false);
14085    
14086                            return array;
14087                    }
14088                    catch (Exception e) {
14089                            throw processException(e);
14090                    }
14091                    finally {
14092                            closeSession(session);
14093                    }
14094            }
14095    
14096            protected BlogsEntry filterGetByG_U_LtD_NeS_PrevAndNext(Session session,
14097                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
14098                    int status, OrderByComparator orderByComparator, boolean previous) {
14099                    StringBundler query = null;
14100    
14101                    if (orderByComparator != null) {
14102                            query = new StringBundler(6 +
14103                                            (orderByComparator.getOrderByFields().length * 6));
14104                    }
14105                    else {
14106                            query = new StringBundler(3);
14107                    }
14108    
14109                    if (getDB().isSupportsInlineDistinct()) {
14110                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14111                    }
14112                    else {
14113                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14114                    }
14115    
14116                    query.append(_FINDER_COLUMN_G_U_LTD_NES_GROUPID_2);
14117    
14118                    query.append(_FINDER_COLUMN_G_U_LTD_NES_USERID_2);
14119    
14120                    if (displayDate == null) {
14121                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_1);
14122                    }
14123                    else {
14124                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_2);
14125                    }
14126    
14127                    query.append(_FINDER_COLUMN_G_U_LTD_NES_STATUS_2);
14128    
14129                    if (!getDB().isSupportsInlineDistinct()) {
14130                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14131                    }
14132    
14133                    if (orderByComparator != null) {
14134                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14135    
14136                            if (orderByConditionFields.length > 0) {
14137                                    query.append(WHERE_AND);
14138                            }
14139    
14140                            for (int i = 0; i < orderByConditionFields.length; i++) {
14141                                    if (getDB().isSupportsInlineDistinct()) {
14142                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14143                                    }
14144                                    else {
14145                                            query.append(_ORDER_BY_ENTITY_TABLE);
14146                                    }
14147    
14148                                    query.append(orderByConditionFields[i]);
14149    
14150                                    if ((i + 1) < orderByConditionFields.length) {
14151                                            if (orderByComparator.isAscending() ^ previous) {
14152                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14153                                            }
14154                                            else {
14155                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14156                                            }
14157                                    }
14158                                    else {
14159                                            if (orderByComparator.isAscending() ^ previous) {
14160                                                    query.append(WHERE_GREATER_THAN);
14161                                            }
14162                                            else {
14163                                                    query.append(WHERE_LESSER_THAN);
14164                                            }
14165                                    }
14166                            }
14167    
14168                            query.append(ORDER_BY_CLAUSE);
14169    
14170                            String[] orderByFields = orderByComparator.getOrderByFields();
14171    
14172                            for (int i = 0; i < orderByFields.length; i++) {
14173                                    if (getDB().isSupportsInlineDistinct()) {
14174                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14175                                    }
14176                                    else {
14177                                            query.append(_ORDER_BY_ENTITY_TABLE);
14178                                    }
14179    
14180                                    query.append(orderByFields[i]);
14181    
14182                                    if ((i + 1) < orderByFields.length) {
14183                                            if (orderByComparator.isAscending() ^ previous) {
14184                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14185                                            }
14186                                            else {
14187                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14188                                            }
14189                                    }
14190                                    else {
14191                                            if (orderByComparator.isAscending() ^ previous) {
14192                                                    query.append(ORDER_BY_ASC);
14193                                            }
14194                                            else {
14195                                                    query.append(ORDER_BY_DESC);
14196                                            }
14197                                    }
14198                            }
14199                    }
14200    
14201                    else {
14202                            if (getDB().isSupportsInlineDistinct()) {
14203                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14204                            }
14205                            else {
14206                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14207                            }
14208                    }
14209    
14210                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14211                                    BlogsEntry.class.getName(),
14212                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14213    
14214                    SQLQuery q = session.createSQLQuery(sql);
14215    
14216                    q.setFirstResult(0);
14217                    q.setMaxResults(2);
14218    
14219                    if (getDB().isSupportsInlineDistinct()) {
14220                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14221                    }
14222                    else {
14223                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14224                    }
14225    
14226                    QueryPos qPos = QueryPos.getInstance(q);
14227    
14228                    qPos.add(groupId);
14229    
14230                    qPos.add(userId);
14231    
14232                    if (displayDate != null) {
14233                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14234                    }
14235    
14236                    qPos.add(status);
14237    
14238                    if (orderByComparator != null) {
14239                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14240    
14241                            for (Object value : values) {
14242                                    qPos.add(value);
14243                            }
14244                    }
14245    
14246                    List<BlogsEntry> list = q.list();
14247    
14248                    if (list.size() == 2) {
14249                            return list.get(1);
14250                    }
14251                    else {
14252                            return null;
14253                    }
14254            }
14255    
14256            /**
14257             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14258             *
14259             * @param groupId the group ID
14260             * @param userId the user ID
14261             * @param displayDate the display date
14262             * @param status the status
14263             * @return the matching blogs entries
14264             * @throws SystemException if a system exception occurred
14265             */
14266            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
14267                    Date displayDate, int status) throws SystemException {
14268                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
14269                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14270            }
14271    
14272            /**
14273             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14274             *
14275             * <p>
14276             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14277             * </p>
14278             *
14279             * @param groupId the group ID
14280             * @param userId the user ID
14281             * @param displayDate the display date
14282             * @param status the status
14283             * @param start the lower bound of the range of blogs entries
14284             * @param end the upper bound of the range of blogs entries (not inclusive)
14285             * @return the range of matching blogs entries
14286             * @throws SystemException if a system exception occurred
14287             */
14288            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
14289                    Date displayDate, int status, int start, int end)
14290                    throws SystemException {
14291                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
14292                            end, null);
14293            }
14294    
14295            /**
14296             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14297             *
14298             * <p>
14299             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14300             * </p>
14301             *
14302             * @param groupId the group ID
14303             * @param userId the user ID
14304             * @param displayDate the display date
14305             * @param status the status
14306             * @param start the lower bound of the range of blogs entries
14307             * @param end the upper bound of the range of blogs entries (not inclusive)
14308             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14309             * @return the ordered range of matching blogs entries
14310             * @throws SystemException if a system exception occurred
14311             */
14312            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
14313                    Date displayDate, int status, int start, int end,
14314                    OrderByComparator orderByComparator) throws SystemException {
14315                    FinderPath finderPath = null;
14316                    Object[] finderArgs = null;
14317    
14318                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
14319                    finderArgs = new Object[] {
14320                                    groupId, userId, displayDate, status,
14321                                    
14322                                    start, end, orderByComparator
14323                            };
14324    
14325                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14326                                    finderArgs, this);
14327    
14328                    if ((list != null) && !list.isEmpty()) {
14329                            for (BlogsEntry blogsEntry : list) {
14330                                    if ((groupId != blogsEntry.getGroupId()) ||
14331                                                    (userId != blogsEntry.getUserId()) ||
14332                                                    !Validator.equals(displayDate,
14333                                                            blogsEntry.getDisplayDate()) ||
14334                                                    (status != blogsEntry.getStatus())) {
14335                                            list = null;
14336    
14337                                            break;
14338                                    }
14339                            }
14340                    }
14341    
14342                    if (list == null) {
14343                            StringBundler query = null;
14344    
14345                            if (orderByComparator != null) {
14346                                    query = new StringBundler(6 +
14347                                                    (orderByComparator.getOrderByFields().length * 3));
14348                            }
14349                            else {
14350                                    query = new StringBundler(6);
14351                            }
14352    
14353                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14354    
14355                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
14356    
14357                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
14358    
14359                            if (displayDate == null) {
14360                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
14361                            }
14362                            else {
14363                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
14364                            }
14365    
14366                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
14367    
14368                            if (orderByComparator != null) {
14369                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14370                                            orderByComparator);
14371                            }
14372    
14373                            else {
14374                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14375                            }
14376    
14377                            String sql = query.toString();
14378    
14379                            Session session = null;
14380    
14381                            try {
14382                                    session = openSession();
14383    
14384                                    Query q = session.createQuery(sql);
14385    
14386                                    QueryPos qPos = QueryPos.getInstance(q);
14387    
14388                                    qPos.add(groupId);
14389    
14390                                    qPos.add(userId);
14391    
14392                                    if (displayDate != null) {
14393                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14394                                    }
14395    
14396                                    qPos.add(status);
14397    
14398                                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start,
14399                                                    end);
14400                            }
14401                            catch (Exception e) {
14402                                    throw processException(e);
14403                            }
14404                            finally {
14405                                    if (list == null) {
14406                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
14407                                    }
14408                                    else {
14409                                            cacheResult(list);
14410    
14411                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
14412                                    }
14413    
14414                                    closeSession(session);
14415                            }
14416                    }
14417    
14418                    return list;
14419            }
14420    
14421            /**
14422             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14423             *
14424             * @param groupId the group ID
14425             * @param userId the user ID
14426             * @param displayDate the display date
14427             * @param status the status
14428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14429             * @return the first matching blogs entry
14430             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14431             * @throws SystemException if a system exception occurred
14432             */
14433            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
14434                    Date displayDate, int status, OrderByComparator orderByComparator)
14435                    throws NoSuchEntryException, SystemException {
14436                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
14437                                    displayDate, status, orderByComparator);
14438    
14439                    if (blogsEntry != null) {
14440                            return blogsEntry;
14441                    }
14442    
14443                    StringBundler msg = new StringBundler(10);
14444    
14445                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14446    
14447                    msg.append("groupId=");
14448                    msg.append(groupId);
14449    
14450                    msg.append(", userId=");
14451                    msg.append(userId);
14452    
14453                    msg.append(", displayDate=");
14454                    msg.append(displayDate);
14455    
14456                    msg.append(", status=");
14457                    msg.append(status);
14458    
14459                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14460    
14461                    throw new NoSuchEntryException(msg.toString());
14462            }
14463    
14464            /**
14465             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14466             *
14467             * @param groupId the group ID
14468             * @param userId the user ID
14469             * @param displayDate the display date
14470             * @param status the status
14471             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14472             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14473             * @throws SystemException if a system exception occurred
14474             */
14475            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
14476                    Date displayDate, int status, OrderByComparator orderByComparator)
14477                    throws SystemException {
14478                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
14479                                    status, 0, 1, orderByComparator);
14480    
14481                    if (!list.isEmpty()) {
14482                            return list.get(0);
14483                    }
14484    
14485                    return null;
14486            }
14487    
14488            /**
14489             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14490             *
14491             * @param groupId the group ID
14492             * @param userId the user ID
14493             * @param displayDate the display date
14494             * @param status the status
14495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14496             * @return the last matching blogs entry
14497             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14498             * @throws SystemException if a system exception occurred
14499             */
14500            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
14501                    Date displayDate, int status, OrderByComparator orderByComparator)
14502                    throws NoSuchEntryException, SystemException {
14503                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
14504                                    displayDate, status, orderByComparator);
14505    
14506                    if (blogsEntry != null) {
14507                            return blogsEntry;
14508                    }
14509    
14510                    StringBundler msg = new StringBundler(10);
14511    
14512                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14513    
14514                    msg.append("groupId=");
14515                    msg.append(groupId);
14516    
14517                    msg.append(", userId=");
14518                    msg.append(userId);
14519    
14520                    msg.append(", displayDate=");
14521                    msg.append(displayDate);
14522    
14523                    msg.append(", status=");
14524                    msg.append(status);
14525    
14526                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14527    
14528                    throw new NoSuchEntryException(msg.toString());
14529            }
14530    
14531            /**
14532             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14533             *
14534             * @param groupId the group ID
14535             * @param userId the user ID
14536             * @param displayDate the display date
14537             * @param status the status
14538             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14539             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14540             * @throws SystemException if a system exception occurred
14541             */
14542            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
14543                    Date displayDate, int status, OrderByComparator orderByComparator)
14544                    throws SystemException {
14545                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
14546    
14547                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
14548                                    status, count - 1, count, orderByComparator);
14549    
14550                    if (!list.isEmpty()) {
14551                            return list.get(0);
14552                    }
14553    
14554                    return null;
14555            }
14556    
14557            /**
14558             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14559             *
14560             * @param entryId the primary key of the current blogs entry
14561             * @param groupId the group ID
14562             * @param userId the user ID
14563             * @param displayDate the display date
14564             * @param status the status
14565             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14566             * @return the previous, current, and next blogs entry
14567             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14568             * @throws SystemException if a system exception occurred
14569             */
14570            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
14571                    long userId, Date displayDate, int status,
14572                    OrderByComparator orderByComparator)
14573                    throws NoSuchEntryException, SystemException {
14574                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14575    
14576                    Session session = null;
14577    
14578                    try {
14579                            session = openSession();
14580    
14581                            BlogsEntry[] array = new BlogsEntryImpl[3];
14582    
14583                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
14584                                            userId, displayDate, status, orderByComparator, true);
14585    
14586                            array[1] = blogsEntry;
14587    
14588                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
14589                                            userId, displayDate, status, orderByComparator, false);
14590    
14591                            return array;
14592                    }
14593                    catch (Exception e) {
14594                            throw processException(e);
14595                    }
14596                    finally {
14597                            closeSession(session);
14598                    }
14599            }
14600    
14601            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
14602                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
14603                    int status, OrderByComparator orderByComparator, boolean previous) {
14604                    StringBundler query = null;
14605    
14606                    if (orderByComparator != null) {
14607                            query = new StringBundler(6 +
14608                                            (orderByComparator.getOrderByFields().length * 6));
14609                    }
14610                    else {
14611                            query = new StringBundler(3);
14612                    }
14613    
14614                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14615    
14616                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
14617    
14618                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
14619    
14620                    if (displayDate == null) {
14621                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
14622                    }
14623                    else {
14624                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
14625                    }
14626    
14627                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
14628    
14629                    if (orderByComparator != null) {
14630                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14631    
14632                            if (orderByConditionFields.length > 0) {
14633                                    query.append(WHERE_AND);
14634                            }
14635    
14636                            for (int i = 0; i < orderByConditionFields.length; i++) {
14637                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14638                                    query.append(orderByConditionFields[i]);
14639    
14640                                    if ((i + 1) < orderByConditionFields.length) {
14641                                            if (orderByComparator.isAscending() ^ previous) {
14642                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14643                                            }
14644                                            else {
14645                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14646                                            }
14647                                    }
14648                                    else {
14649                                            if (orderByComparator.isAscending() ^ previous) {
14650                                                    query.append(WHERE_GREATER_THAN);
14651                                            }
14652                                            else {
14653                                                    query.append(WHERE_LESSER_THAN);
14654                                            }
14655                                    }
14656                            }
14657    
14658                            query.append(ORDER_BY_CLAUSE);
14659    
14660                            String[] orderByFields = orderByComparator.getOrderByFields();
14661    
14662                            for (int i = 0; i < orderByFields.length; i++) {
14663                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14664                                    query.append(orderByFields[i]);
14665    
14666                                    if ((i + 1) < orderByFields.length) {
14667                                            if (orderByComparator.isAscending() ^ previous) {
14668                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14669                                            }
14670                                            else {
14671                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14672                                            }
14673                                    }
14674                                    else {
14675                                            if (orderByComparator.isAscending() ^ previous) {
14676                                                    query.append(ORDER_BY_ASC);
14677                                            }
14678                                            else {
14679                                                    query.append(ORDER_BY_DESC);
14680                                            }
14681                                    }
14682                            }
14683                    }
14684    
14685                    else {
14686                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14687                    }
14688    
14689                    String sql = query.toString();
14690    
14691                    Query q = session.createQuery(sql);
14692    
14693                    q.setFirstResult(0);
14694                    q.setMaxResults(2);
14695    
14696                    QueryPos qPos = QueryPos.getInstance(q);
14697    
14698                    qPos.add(groupId);
14699    
14700                    qPos.add(userId);
14701    
14702                    if (displayDate != null) {
14703                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14704                    }
14705    
14706                    qPos.add(status);
14707    
14708                    if (orderByComparator != null) {
14709                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14710    
14711                            for (Object value : values) {
14712                                    qPos.add(value);
14713                            }
14714                    }
14715    
14716                    List<BlogsEntry> list = q.list();
14717    
14718                    if (list.size() == 2) {
14719                            return list.get(1);
14720                    }
14721                    else {
14722                            return null;
14723                    }
14724            }
14725    
14726            /**
14727             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14728             *
14729             * @param groupId the group ID
14730             * @param userId the user ID
14731             * @param displayDate the display date
14732             * @param status the status
14733             * @return the matching blogs entries that the user has permission to view
14734             * @throws SystemException if a system exception occurred
14735             */
14736            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
14737                    Date displayDate, int status) throws SystemException {
14738                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
14739                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14740            }
14741    
14742            /**
14743             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14744             *
14745             * <p>
14746             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14747             * </p>
14748             *
14749             * @param groupId the group ID
14750             * @param userId the user ID
14751             * @param displayDate the display date
14752             * @param status the status
14753             * @param start the lower bound of the range of blogs entries
14754             * @param end the upper bound of the range of blogs entries (not inclusive)
14755             * @return the range of matching blogs entries that the user has permission to view
14756             * @throws SystemException if a system exception occurred
14757             */
14758            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
14759                    Date displayDate, int status, int start, int end)
14760                    throws SystemException {
14761                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
14762                            start, end, null);
14763            }
14764    
14765            /**
14766             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14767             *
14768             * <p>
14769             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
14770             * </p>
14771             *
14772             * @param groupId the group ID
14773             * @param userId the user ID
14774             * @param displayDate the display date
14775             * @param status the status
14776             * @param start the lower bound of the range of blogs entries
14777             * @param end the upper bound of the range of blogs entries (not inclusive)
14778             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14779             * @return the ordered range of matching blogs entries that the user has permission to view
14780             * @throws SystemException if a system exception occurred
14781             */
14782            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
14783                    Date displayDate, int status, int start, int end,
14784                    OrderByComparator orderByComparator) throws SystemException {
14785                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14786                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
14787                                    end, orderByComparator);
14788                    }
14789    
14790                    StringBundler query = null;
14791    
14792                    if (orderByComparator != null) {
14793                            query = new StringBundler(6 +
14794                                            (orderByComparator.getOrderByFields().length * 3));
14795                    }
14796                    else {
14797                            query = new StringBundler(6);
14798                    }
14799    
14800                    if (getDB().isSupportsInlineDistinct()) {
14801                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14802                    }
14803                    else {
14804                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14805                    }
14806    
14807                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
14808    
14809                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
14810    
14811                    if (displayDate == null) {
14812                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
14813                    }
14814                    else {
14815                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
14816                    }
14817    
14818                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
14819    
14820                    if (!getDB().isSupportsInlineDistinct()) {
14821                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14822                    }
14823    
14824                    if (orderByComparator != null) {
14825                            if (getDB().isSupportsInlineDistinct()) {
14826                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14827                                            orderByComparator);
14828                            }
14829                            else {
14830                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14831                                            orderByComparator);
14832                            }
14833                    }
14834    
14835                    else {
14836                            if (getDB().isSupportsInlineDistinct()) {
14837                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14838                            }
14839                            else {
14840                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14841                            }
14842                    }
14843    
14844                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14845                                    BlogsEntry.class.getName(),
14846                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14847    
14848                    Session session = null;
14849    
14850                    try {
14851                            session = openSession();
14852    
14853                            SQLQuery q = session.createSQLQuery(sql);
14854    
14855                            if (getDB().isSupportsInlineDistinct()) {
14856                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14857                            }
14858                            else {
14859                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14860                            }
14861    
14862                            QueryPos qPos = QueryPos.getInstance(q);
14863    
14864                            qPos.add(groupId);
14865    
14866                            qPos.add(userId);
14867    
14868                            if (displayDate != null) {
14869                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14870                            }
14871    
14872                            qPos.add(status);
14873    
14874                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
14875                    }
14876                    catch (Exception e) {
14877                            throw processException(e);
14878                    }
14879                    finally {
14880                            closeSession(session);
14881                    }
14882            }
14883    
14884            /**
14885             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
14886             *
14887             * @param entryId the primary key of the current blogs entry
14888             * @param groupId the group ID
14889             * @param userId the user ID
14890             * @param displayDate the display date
14891             * @param status the status
14892             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14893             * @return the previous, current, and next blogs entry
14894             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14895             * @throws SystemException if a system exception occurred
14896             */
14897            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
14898                    long groupId, long userId, Date displayDate, int status,
14899                    OrderByComparator orderByComparator)
14900                    throws NoSuchEntryException, SystemException {
14901                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14902                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
14903                                    displayDate, status, orderByComparator);
14904                    }
14905    
14906                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14907    
14908                    Session session = null;
14909    
14910                    try {
14911                            session = openSession();
14912    
14913                            BlogsEntry[] array = new BlogsEntryImpl[3];
14914    
14915                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
14916                                            groupId, userId, displayDate, status, orderByComparator,
14917                                            true);
14918    
14919                            array[1] = blogsEntry;
14920    
14921                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
14922                                            groupId, userId, displayDate, status, orderByComparator,
14923                                            false);
14924    
14925                            return array;
14926                    }
14927                    catch (Exception e) {
14928                            throw processException(e);
14929                    }
14930                    finally {
14931                            closeSession(session);
14932                    }
14933            }
14934    
14935            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
14936                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
14937                    int status, OrderByComparator orderByComparator, boolean previous) {
14938                    StringBundler query = null;
14939    
14940                    if (orderByComparator != null) {
14941                            query = new StringBundler(6 +
14942                                            (orderByComparator.getOrderByFields().length * 6));
14943                    }
14944                    else {
14945                            query = new StringBundler(3);
14946                    }
14947    
14948                    if (getDB().isSupportsInlineDistinct()) {
14949                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14950                    }
14951                    else {
14952                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14953                    }
14954    
14955                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
14956    
14957                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
14958    
14959                    if (displayDate == null) {
14960                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
14961                    }
14962                    else {
14963                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
14964                    }
14965    
14966                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
14967    
14968                    if (!getDB().isSupportsInlineDistinct()) {
14969                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14970                    }
14971    
14972                    if (orderByComparator != null) {
14973                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14974    
14975                            if (orderByConditionFields.length > 0) {
14976                                    query.append(WHERE_AND);
14977                            }
14978    
14979                            for (int i = 0; i < orderByConditionFields.length; i++) {
14980                                    if (getDB().isSupportsInlineDistinct()) {
14981                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14982                                    }
14983                                    else {
14984                                            query.append(_ORDER_BY_ENTITY_TABLE);
14985                                    }
14986    
14987                                    query.append(orderByConditionFields[i]);
14988    
14989                                    if ((i + 1) < orderByConditionFields.length) {
14990                                            if (orderByComparator.isAscending() ^ previous) {
14991                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14992                                            }
14993                                            else {
14994                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14995                                            }
14996                                    }
14997                                    else {
14998                                            if (orderByComparator.isAscending() ^ previous) {
14999                                                    query.append(WHERE_GREATER_THAN);
15000                                            }
15001                                            else {
15002                                                    query.append(WHERE_LESSER_THAN);
15003                                            }
15004                                    }
15005                            }
15006    
15007                            query.append(ORDER_BY_CLAUSE);
15008    
15009                            String[] orderByFields = orderByComparator.getOrderByFields();
15010    
15011                            for (int i = 0; i < orderByFields.length; i++) {
15012                                    if (getDB().isSupportsInlineDistinct()) {
15013                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15014                                    }
15015                                    else {
15016                                            query.append(_ORDER_BY_ENTITY_TABLE);
15017                                    }
15018    
15019                                    query.append(orderByFields[i]);
15020    
15021                                    if ((i + 1) < orderByFields.length) {
15022                                            if (orderByComparator.isAscending() ^ previous) {
15023                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15024                                            }
15025                                            else {
15026                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15027                                            }
15028                                    }
15029                                    else {
15030                                            if (orderByComparator.isAscending() ^ previous) {
15031                                                    query.append(ORDER_BY_ASC);
15032                                            }
15033                                            else {
15034                                                    query.append(ORDER_BY_DESC);
15035                                            }
15036                                    }
15037                            }
15038                    }
15039    
15040                    else {
15041                            if (getDB().isSupportsInlineDistinct()) {
15042                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15043                            }
15044                            else {
15045                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15046                            }
15047                    }
15048    
15049                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15050                                    BlogsEntry.class.getName(),
15051                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15052    
15053                    SQLQuery q = session.createSQLQuery(sql);
15054    
15055                    q.setFirstResult(0);
15056                    q.setMaxResults(2);
15057    
15058                    if (getDB().isSupportsInlineDistinct()) {
15059                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15060                    }
15061                    else {
15062                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15063                    }
15064    
15065                    QueryPos qPos = QueryPos.getInstance(q);
15066    
15067                    qPos.add(groupId);
15068    
15069                    qPos.add(userId);
15070    
15071                    if (displayDate != null) {
15072                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15073                    }
15074    
15075                    qPos.add(status);
15076    
15077                    if (orderByComparator != null) {
15078                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15079    
15080                            for (Object value : values) {
15081                                    qPos.add(value);
15082                            }
15083                    }
15084    
15085                    List<BlogsEntry> list = q.list();
15086    
15087                    if (list.size() == 2) {
15088                            return list.get(1);
15089                    }
15090                    else {
15091                            return null;
15092                    }
15093            }
15094    
15095            /**
15096             * Returns all the blogs entries.
15097             *
15098             * @return the blogs entries
15099             * @throws SystemException if a system exception occurred
15100             */
15101            public List<BlogsEntry> findAll() throws SystemException {
15102                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15103            }
15104    
15105            /**
15106             * Returns a range of all the blogs entries.
15107             *
15108             * <p>
15109             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15110             * </p>
15111             *
15112             * @param start the lower bound of the range of blogs entries
15113             * @param end the upper bound of the range of blogs entries (not inclusive)
15114             * @return the range of blogs entries
15115             * @throws SystemException if a system exception occurred
15116             */
15117            public List<BlogsEntry> findAll(int start, int end)
15118                    throws SystemException {
15119                    return findAll(start, end, null);
15120            }
15121    
15122            /**
15123             * Returns an ordered range of all the blogs entries.
15124             *
15125             * <p>
15126             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
15127             * </p>
15128             *
15129             * @param start the lower bound of the range of blogs entries
15130             * @param end the upper bound of the range of blogs entries (not inclusive)
15131             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15132             * @return the ordered range of blogs entries
15133             * @throws SystemException if a system exception occurred
15134             */
15135            public List<BlogsEntry> findAll(int start, int end,
15136                    OrderByComparator orderByComparator) throws SystemException {
15137                    FinderPath finderPath = null;
15138                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
15139    
15140                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
15141                                    (orderByComparator == null)) {
15142                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
15143                            finderArgs = FINDER_ARGS_EMPTY;
15144                    }
15145                    else {
15146                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
15147                            finderArgs = new Object[] { start, end, orderByComparator };
15148                    }
15149    
15150                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
15151                                    finderArgs, this);
15152    
15153                    if (list == null) {
15154                            StringBundler query = null;
15155                            String sql = null;
15156    
15157                            if (orderByComparator != null) {
15158                                    query = new StringBundler(2 +
15159                                                    (orderByComparator.getOrderByFields().length * 3));
15160    
15161                                    query.append(_SQL_SELECT_BLOGSENTRY);
15162    
15163                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15164                                            orderByComparator);
15165    
15166                                    sql = query.toString();
15167                            }
15168                            else {
15169                                    sql = _SQL_SELECT_BLOGSENTRY.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
15170                            }
15171    
15172                            Session session = null;
15173    
15174                            try {
15175                                    session = openSession();
15176    
15177                                    Query q = session.createQuery(sql);
15178    
15179                                    if (orderByComparator == null) {
15180                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15181                                                            start, end, false);
15182    
15183                                            Collections.sort(list);
15184                                    }
15185                                    else {
15186                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15187                                                            start, end);
15188                                    }
15189                            }
15190                            catch (Exception e) {
15191                                    throw processException(e);
15192                            }
15193                            finally {
15194                                    if (list == null) {
15195                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
15196                                    }
15197                                    else {
15198                                            cacheResult(list);
15199    
15200                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
15201                                    }
15202    
15203                                    closeSession(session);
15204                            }
15205                    }
15206    
15207                    return list;
15208            }
15209    
15210            /**
15211             * Removes all the blogs entries where uuid = &#63; from the database.
15212             *
15213             * @param uuid the uuid
15214             * @throws SystemException if a system exception occurred
15215             */
15216            public void removeByUuid(String uuid) throws SystemException {
15217                    for (BlogsEntry blogsEntry : findByUuid(uuid)) {
15218                            remove(blogsEntry);
15219                    }
15220            }
15221    
15222            /**
15223             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
15224             *
15225             * @param uuid the uuid
15226             * @param groupId the group ID
15227             * @return the blogs entry that was removed
15228             * @throws SystemException if a system exception occurred
15229             */
15230            public BlogsEntry removeByUUID_G(String uuid, long groupId)
15231                    throws NoSuchEntryException, SystemException {
15232                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
15233    
15234                    return remove(blogsEntry);
15235            }
15236    
15237            /**
15238             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
15239             *
15240             * @param uuid the uuid
15241             * @param companyId the company ID
15242             * @throws SystemException if a system exception occurred
15243             */
15244            public void removeByUuid_C(String uuid, long companyId)
15245                    throws SystemException {
15246                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId)) {
15247                            remove(blogsEntry);
15248                    }
15249            }
15250    
15251            /**
15252             * Removes all the blogs entries where groupId = &#63; from the database.
15253             *
15254             * @param groupId the group ID
15255             * @throws SystemException if a system exception occurred
15256             */
15257            public void removeByGroupId(long groupId) throws SystemException {
15258                    for (BlogsEntry blogsEntry : findByGroupId(groupId)) {
15259                            remove(blogsEntry);
15260                    }
15261            }
15262    
15263            /**
15264             * Removes all the blogs entries where companyId = &#63; from the database.
15265             *
15266             * @param companyId the company ID
15267             * @throws SystemException if a system exception occurred
15268             */
15269            public void removeByCompanyId(long companyId) throws SystemException {
15270                    for (BlogsEntry blogsEntry : findByCompanyId(companyId)) {
15271                            remove(blogsEntry);
15272                    }
15273            }
15274    
15275            /**
15276             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
15277             *
15278             * @param companyId the company ID
15279             * @param userId the user ID
15280             * @throws SystemException if a system exception occurred
15281             */
15282            public void removeByC_U(long companyId, long userId)
15283                    throws SystemException {
15284                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId)) {
15285                            remove(blogsEntry);
15286                    }
15287            }
15288    
15289            /**
15290             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
15291             *
15292             * @param companyId the company ID
15293             * @param displayDate the display date
15294             * @throws SystemException if a system exception occurred
15295             */
15296            public void removeByC_LtD(long companyId, Date displayDate)
15297                    throws SystemException {
15298                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate)) {
15299                            remove(blogsEntry);
15300                    }
15301            }
15302    
15303            /**
15304             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
15305             *
15306             * @param companyId the company ID
15307             * @param status the status
15308             * @throws SystemException if a system exception occurred
15309             */
15310            public void removeByC_NeS(long companyId, int status)
15311                    throws SystemException {
15312                    for (BlogsEntry blogsEntry : findByC_NeS(companyId, status)) {
15313                            remove(blogsEntry);
15314                    }
15315            }
15316    
15317            /**
15318             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
15319             *
15320             * @param companyId the company ID
15321             * @param status the status
15322             * @throws SystemException if a system exception occurred
15323             */
15324            public void removeByC_S(long companyId, int status)
15325                    throws SystemException {
15326                    for (BlogsEntry blogsEntry : findByC_S(companyId, status)) {
15327                            remove(blogsEntry);
15328                    }
15329            }
15330    
15331            /**
15332             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
15333             *
15334             * @param groupId the group ID
15335             * @param urlTitle the url title
15336             * @return the blogs entry that was removed
15337             * @throws SystemException if a system exception occurred
15338             */
15339            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
15340                    throws NoSuchEntryException, SystemException {
15341                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
15342    
15343                    return remove(blogsEntry);
15344            }
15345    
15346            /**
15347             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
15348             *
15349             * @param groupId the group ID
15350             * @param displayDate the display date
15351             * @throws SystemException if a system exception occurred
15352             */
15353            public void removeByG_LtD(long groupId, Date displayDate)
15354                    throws SystemException {
15355                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate)) {
15356                            remove(blogsEntry);
15357                    }
15358            }
15359    
15360            /**
15361             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
15362             *
15363             * @param groupId the group ID
15364             * @param status the status
15365             * @throws SystemException if a system exception occurred
15366             */
15367            public void removeByG_NeS(long groupId, int status)
15368                    throws SystemException {
15369                    for (BlogsEntry blogsEntry : findByG_NeS(groupId, status)) {
15370                            remove(blogsEntry);
15371                    }
15372            }
15373    
15374            /**
15375             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
15376             *
15377             * @param groupId the group ID
15378             * @param status the status
15379             * @throws SystemException if a system exception occurred
15380             */
15381            public void removeByG_S(long groupId, int status) throws SystemException {
15382                    for (BlogsEntry blogsEntry : findByG_S(groupId, status)) {
15383                            remove(blogsEntry);
15384                    }
15385            }
15386    
15387            /**
15388             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
15389             *
15390             * @param displayDate the display date
15391             * @param status the status
15392             * @throws SystemException if a system exception occurred
15393             */
15394            public void removeByLtD_S(Date displayDate, int status)
15395                    throws SystemException {
15396                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status)) {
15397                            remove(blogsEntry);
15398                    }
15399            }
15400    
15401            /**
15402             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
15403             *
15404             * @param companyId the company ID
15405             * @param userId the user ID
15406             * @param status the status
15407             * @throws SystemException if a system exception occurred
15408             */
15409            public void removeByC_U_NeS(long companyId, long userId, int status)
15410                    throws SystemException {
15411                    for (BlogsEntry blogsEntry : findByC_U_NeS(companyId, userId, status)) {
15412                            remove(blogsEntry);
15413                    }
15414            }
15415    
15416            /**
15417             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
15418             *
15419             * @param companyId the company ID
15420             * @param userId the user ID
15421             * @param status the status
15422             * @throws SystemException if a system exception occurred
15423             */
15424            public void removeByC_U_S(long companyId, long userId, int status)
15425                    throws SystemException {
15426                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status)) {
15427                            remove(blogsEntry);
15428                    }
15429            }
15430    
15431            /**
15432             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15433             *
15434             * @param companyId the company ID
15435             * @param displayDate the display date
15436             * @param status the status
15437             * @throws SystemException if a system exception occurred
15438             */
15439            public void removeByC_LtD_NeS(long companyId, Date displayDate, int status)
15440                    throws SystemException {
15441                    for (BlogsEntry blogsEntry : findByC_LtD_NeS(companyId, displayDate,
15442                                    status)) {
15443                            remove(blogsEntry);
15444                    }
15445            }
15446    
15447            /**
15448             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15449             *
15450             * @param companyId the company ID
15451             * @param displayDate the display date
15452             * @param status the status
15453             * @throws SystemException if a system exception occurred
15454             */
15455            public void removeByC_LtD_S(long companyId, Date displayDate, int status)
15456                    throws SystemException {
15457                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
15458                                    status)) {
15459                            remove(blogsEntry);
15460                    }
15461            }
15462    
15463            /**
15464             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
15465             *
15466             * @param groupId the group ID
15467             * @param userId the user ID
15468             * @param displayDate the display date
15469             * @throws SystemException if a system exception occurred
15470             */
15471            public void removeByG_U_LtD(long groupId, long userId, Date displayDate)
15472                    throws SystemException {
15473                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId, displayDate)) {
15474                            remove(blogsEntry);
15475                    }
15476            }
15477    
15478            /**
15479             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
15480             *
15481             * @param groupId the group ID
15482             * @param userId the user ID
15483             * @param status the status
15484             * @throws SystemException if a system exception occurred
15485             */
15486            public void removeByG_U_NeS(long groupId, long userId, int status)
15487                    throws SystemException {
15488                    for (BlogsEntry blogsEntry : findByG_U_NeS(groupId, userId, status)) {
15489                            remove(blogsEntry);
15490                    }
15491            }
15492    
15493            /**
15494             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
15495             *
15496             * @param groupId the group ID
15497             * @param userId the user ID
15498             * @param status the status
15499             * @throws SystemException if a system exception occurred
15500             */
15501            public void removeByG_U_S(long groupId, long userId, int status)
15502                    throws SystemException {
15503                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status)) {
15504                            remove(blogsEntry);
15505                    }
15506            }
15507    
15508            /**
15509             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15510             *
15511             * @param groupId the group ID
15512             * @param displayDate the display date
15513             * @param status the status
15514             * @throws SystemException if a system exception occurred
15515             */
15516            public void removeByG_LtD_NeS(long groupId, Date displayDate, int status)
15517                    throws SystemException {
15518                    for (BlogsEntry blogsEntry : findByG_LtD_NeS(groupId, displayDate,
15519                                    status)) {
15520                            remove(blogsEntry);
15521                    }
15522            }
15523    
15524            /**
15525             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15526             *
15527             * @param groupId the group ID
15528             * @param displayDate the display date
15529             * @param status the status
15530             * @throws SystemException if a system exception occurred
15531             */
15532            public void removeByG_LtD_S(long groupId, Date displayDate, int status)
15533                    throws SystemException {
15534                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate, status)) {
15535                            remove(blogsEntry);
15536                    }
15537            }
15538    
15539            /**
15540             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15541             *
15542             * @param groupId the group ID
15543             * @param userId the user ID
15544             * @param displayDate the display date
15545             * @param status the status
15546             * @throws SystemException if a system exception occurred
15547             */
15548            public void removeByG_U_LtD_NeS(long groupId, long userId,
15549                    Date displayDate, int status) throws SystemException {
15550                    for (BlogsEntry blogsEntry : findByG_U_LtD_NeS(groupId, userId,
15551                                    displayDate, status)) {
15552                            remove(blogsEntry);
15553                    }
15554            }
15555    
15556            /**
15557             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15558             *
15559             * @param groupId the group ID
15560             * @param userId the user ID
15561             * @param displayDate the display date
15562             * @param status the status
15563             * @throws SystemException if a system exception occurred
15564             */
15565            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
15566                    int status) throws SystemException {
15567                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
15568                                    displayDate, status)) {
15569                            remove(blogsEntry);
15570                    }
15571            }
15572    
15573            /**
15574             * Removes all the blogs entries from the database.
15575             *
15576             * @throws SystemException if a system exception occurred
15577             */
15578            public void removeAll() throws SystemException {
15579                    for (BlogsEntry blogsEntry : findAll()) {
15580                            remove(blogsEntry);
15581                    }
15582            }
15583    
15584            /**
15585             * Returns the number of blogs entries where uuid = &#63;.
15586             *
15587             * @param uuid the uuid
15588             * @return the number of matching blogs entries
15589             * @throws SystemException if a system exception occurred
15590             */
15591            public int countByUuid(String uuid) throws SystemException {
15592                    Object[] finderArgs = new Object[] { uuid };
15593    
15594                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
15595                                    finderArgs, this);
15596    
15597                    if (count == null) {
15598                            StringBundler query = new StringBundler(2);
15599    
15600                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15601    
15602                            if (uuid == null) {
15603                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
15604                            }
15605                            else {
15606                                    if (uuid.equals(StringPool.BLANK)) {
15607                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
15608                                    }
15609                                    else {
15610                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
15611                                    }
15612                            }
15613    
15614                            String sql = query.toString();
15615    
15616                            Session session = null;
15617    
15618                            try {
15619                                    session = openSession();
15620    
15621                                    Query q = session.createQuery(sql);
15622    
15623                                    QueryPos qPos = QueryPos.getInstance(q);
15624    
15625                                    if (uuid != null) {
15626                                            qPos.add(uuid);
15627                                    }
15628    
15629                                    count = (Long)q.uniqueResult();
15630                            }
15631                            catch (Exception e) {
15632                                    throw processException(e);
15633                            }
15634                            finally {
15635                                    if (count == null) {
15636                                            count = Long.valueOf(0);
15637                                    }
15638    
15639                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
15640                                            finderArgs, count);
15641    
15642                                    closeSession(session);
15643                            }
15644                    }
15645    
15646                    return count.intValue();
15647            }
15648    
15649            /**
15650             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
15651             *
15652             * @param uuid the uuid
15653             * @param groupId the group ID
15654             * @return the number of matching blogs entries
15655             * @throws SystemException if a system exception occurred
15656             */
15657            public int countByUUID_G(String uuid, long groupId)
15658                    throws SystemException {
15659                    Object[] finderArgs = new Object[] { uuid, groupId };
15660    
15661                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
15662                                    finderArgs, this);
15663    
15664                    if (count == null) {
15665                            StringBundler query = new StringBundler(3);
15666    
15667                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15668    
15669                            if (uuid == null) {
15670                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
15671                            }
15672                            else {
15673                                    if (uuid.equals(StringPool.BLANK)) {
15674                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
15675                                    }
15676                                    else {
15677                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
15678                                    }
15679                            }
15680    
15681                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
15682    
15683                            String sql = query.toString();
15684    
15685                            Session session = null;
15686    
15687                            try {
15688                                    session = openSession();
15689    
15690                                    Query q = session.createQuery(sql);
15691    
15692                                    QueryPos qPos = QueryPos.getInstance(q);
15693    
15694                                    if (uuid != null) {
15695                                            qPos.add(uuid);
15696                                    }
15697    
15698                                    qPos.add(groupId);
15699    
15700                                    count = (Long)q.uniqueResult();
15701                            }
15702                            catch (Exception e) {
15703                                    throw processException(e);
15704                            }
15705                            finally {
15706                                    if (count == null) {
15707                                            count = Long.valueOf(0);
15708                                    }
15709    
15710                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
15711                                            finderArgs, count);
15712    
15713                                    closeSession(session);
15714                            }
15715                    }
15716    
15717                    return count.intValue();
15718            }
15719    
15720            /**
15721             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
15722             *
15723             * @param uuid the uuid
15724             * @param companyId the company ID
15725             * @return the number of matching blogs entries
15726             * @throws SystemException if a system exception occurred
15727             */
15728            public int countByUuid_C(String uuid, long companyId)
15729                    throws SystemException {
15730                    Object[] finderArgs = new Object[] { uuid, companyId };
15731    
15732                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
15733                                    finderArgs, this);
15734    
15735                    if (count == null) {
15736                            StringBundler query = new StringBundler(3);
15737    
15738                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15739    
15740                            if (uuid == null) {
15741                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
15742                            }
15743                            else {
15744                                    if (uuid.equals(StringPool.BLANK)) {
15745                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
15746                                    }
15747                                    else {
15748                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
15749                                    }
15750                            }
15751    
15752                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
15753    
15754                            String sql = query.toString();
15755    
15756                            Session session = null;
15757    
15758                            try {
15759                                    session = openSession();
15760    
15761                                    Query q = session.createQuery(sql);
15762    
15763                                    QueryPos qPos = QueryPos.getInstance(q);
15764    
15765                                    if (uuid != null) {
15766                                            qPos.add(uuid);
15767                                    }
15768    
15769                                    qPos.add(companyId);
15770    
15771                                    count = (Long)q.uniqueResult();
15772                            }
15773                            catch (Exception e) {
15774                                    throw processException(e);
15775                            }
15776                            finally {
15777                                    if (count == null) {
15778                                            count = Long.valueOf(0);
15779                                    }
15780    
15781                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
15782                                            finderArgs, count);
15783    
15784                                    closeSession(session);
15785                            }
15786                    }
15787    
15788                    return count.intValue();
15789            }
15790    
15791            /**
15792             * Returns the number of blogs entries where groupId = &#63;.
15793             *
15794             * @param groupId the group ID
15795             * @return the number of matching blogs entries
15796             * @throws SystemException if a system exception occurred
15797             */
15798            public int countByGroupId(long groupId) throws SystemException {
15799                    Object[] finderArgs = new Object[] { groupId };
15800    
15801                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
15802                                    finderArgs, this);
15803    
15804                    if (count == null) {
15805                            StringBundler query = new StringBundler(2);
15806    
15807                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15808    
15809                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
15810    
15811                            String sql = query.toString();
15812    
15813                            Session session = null;
15814    
15815                            try {
15816                                    session = openSession();
15817    
15818                                    Query q = session.createQuery(sql);
15819    
15820                                    QueryPos qPos = QueryPos.getInstance(q);
15821    
15822                                    qPos.add(groupId);
15823    
15824                                    count = (Long)q.uniqueResult();
15825                            }
15826                            catch (Exception e) {
15827                                    throw processException(e);
15828                            }
15829                            finally {
15830                                    if (count == null) {
15831                                            count = Long.valueOf(0);
15832                                    }
15833    
15834                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
15835                                            finderArgs, count);
15836    
15837                                    closeSession(session);
15838                            }
15839                    }
15840    
15841                    return count.intValue();
15842            }
15843    
15844            /**
15845             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
15846             *
15847             * @param groupId the group ID
15848             * @return the number of matching blogs entries that the user has permission to view
15849             * @throws SystemException if a system exception occurred
15850             */
15851            public int filterCountByGroupId(long groupId) throws SystemException {
15852                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15853                            return countByGroupId(groupId);
15854                    }
15855    
15856                    StringBundler query = new StringBundler(2);
15857    
15858                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
15859    
15860                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
15861    
15862                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15863                                    BlogsEntry.class.getName(),
15864                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15865    
15866                    Session session = null;
15867    
15868                    try {
15869                            session = openSession();
15870    
15871                            SQLQuery q = session.createSQLQuery(sql);
15872    
15873                            q.addScalar(COUNT_COLUMN_NAME,
15874                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15875    
15876                            QueryPos qPos = QueryPos.getInstance(q);
15877    
15878                            qPos.add(groupId);
15879    
15880                            Long count = (Long)q.uniqueResult();
15881    
15882                            return count.intValue();
15883                    }
15884                    catch (Exception e) {
15885                            throw processException(e);
15886                    }
15887                    finally {
15888                            closeSession(session);
15889                    }
15890            }
15891    
15892            /**
15893             * Returns the number of blogs entries where companyId = &#63;.
15894             *
15895             * @param companyId the company ID
15896             * @return the number of matching blogs entries
15897             * @throws SystemException if a system exception occurred
15898             */
15899            public int countByCompanyId(long companyId) throws SystemException {
15900                    Object[] finderArgs = new Object[] { companyId };
15901    
15902                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
15903                                    finderArgs, this);
15904    
15905                    if (count == null) {
15906                            StringBundler query = new StringBundler(2);
15907    
15908                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15909    
15910                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
15911    
15912                            String sql = query.toString();
15913    
15914                            Session session = null;
15915    
15916                            try {
15917                                    session = openSession();
15918    
15919                                    Query q = session.createQuery(sql);
15920    
15921                                    QueryPos qPos = QueryPos.getInstance(q);
15922    
15923                                    qPos.add(companyId);
15924    
15925                                    count = (Long)q.uniqueResult();
15926                            }
15927                            catch (Exception e) {
15928                                    throw processException(e);
15929                            }
15930                            finally {
15931                                    if (count == null) {
15932                                            count = Long.valueOf(0);
15933                                    }
15934    
15935                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
15936                                            finderArgs, count);
15937    
15938                                    closeSession(session);
15939                            }
15940                    }
15941    
15942                    return count.intValue();
15943            }
15944    
15945            /**
15946             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
15947             *
15948             * @param companyId the company ID
15949             * @param userId the user ID
15950             * @return the number of matching blogs entries
15951             * @throws SystemException if a system exception occurred
15952             */
15953            public int countByC_U(long companyId, long userId)
15954                    throws SystemException {
15955                    Object[] finderArgs = new Object[] { companyId, userId };
15956    
15957                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U,
15958                                    finderArgs, this);
15959    
15960                    if (count == null) {
15961                            StringBundler query = new StringBundler(3);
15962    
15963                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15964    
15965                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
15966    
15967                            query.append(_FINDER_COLUMN_C_U_USERID_2);
15968    
15969                            String sql = query.toString();
15970    
15971                            Session session = null;
15972    
15973                            try {
15974                                    session = openSession();
15975    
15976                                    Query q = session.createQuery(sql);
15977    
15978                                    QueryPos qPos = QueryPos.getInstance(q);
15979    
15980                                    qPos.add(companyId);
15981    
15982                                    qPos.add(userId);
15983    
15984                                    count = (Long)q.uniqueResult();
15985                            }
15986                            catch (Exception e) {
15987                                    throw processException(e);
15988                            }
15989                            finally {
15990                                    if (count == null) {
15991                                            count = Long.valueOf(0);
15992                                    }
15993    
15994                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, finderArgs,
15995                                            count);
15996    
15997                                    closeSession(session);
15998                            }
15999                    }
16000    
16001                    return count.intValue();
16002            }
16003    
16004            /**
16005             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
16006             *
16007             * @param companyId the company ID
16008             * @param displayDate the display date
16009             * @return the number of matching blogs entries
16010             * @throws SystemException if a system exception occurred
16011             */
16012            public int countByC_LtD(long companyId, Date displayDate)
16013                    throws SystemException {
16014                    Object[] finderArgs = new Object[] { companyId, displayDate };
16015    
16016                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD,
16017                                    finderArgs, this);
16018    
16019                    if (count == null) {
16020                            StringBundler query = new StringBundler(3);
16021    
16022                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16023    
16024                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
16025    
16026                            if (displayDate == null) {
16027                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
16028                            }
16029                            else {
16030                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
16031                            }
16032    
16033                            String sql = query.toString();
16034    
16035                            Session session = null;
16036    
16037                            try {
16038                                    session = openSession();
16039    
16040                                    Query q = session.createQuery(sql);
16041    
16042                                    QueryPos qPos = QueryPos.getInstance(q);
16043    
16044                                    qPos.add(companyId);
16045    
16046                                    if (displayDate != null) {
16047                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16048                                    }
16049    
16050                                    count = (Long)q.uniqueResult();
16051                            }
16052                            catch (Exception e) {
16053                                    throw processException(e);
16054                            }
16055                            finally {
16056                                    if (count == null) {
16057                                            count = Long.valueOf(0);
16058                                    }
16059    
16060                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD,
16061                                            finderArgs, count);
16062    
16063                                    closeSession(session);
16064                            }
16065                    }
16066    
16067                    return count.intValue();
16068            }
16069    
16070            /**
16071             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
16072             *
16073             * @param companyId the company ID
16074             * @param status the status
16075             * @return the number of matching blogs entries
16076             * @throws SystemException if a system exception occurred
16077             */
16078            public int countByC_NeS(long companyId, int status)
16079                    throws SystemException {
16080                    Object[] finderArgs = new Object[] { companyId, status };
16081    
16082                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NES,
16083                                    finderArgs, this);
16084    
16085                    if (count == null) {
16086                            StringBundler query = new StringBundler(3);
16087    
16088                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16089    
16090                            query.append(_FINDER_COLUMN_C_NES_COMPANYID_2);
16091    
16092                            query.append(_FINDER_COLUMN_C_NES_STATUS_2);
16093    
16094                            String sql = query.toString();
16095    
16096                            Session session = null;
16097    
16098                            try {
16099                                    session = openSession();
16100    
16101                                    Query q = session.createQuery(sql);
16102    
16103                                    QueryPos qPos = QueryPos.getInstance(q);
16104    
16105                                    qPos.add(companyId);
16106    
16107                                    qPos.add(status);
16108    
16109                                    count = (Long)q.uniqueResult();
16110                            }
16111                            catch (Exception e) {
16112                                    throw processException(e);
16113                            }
16114                            finally {
16115                                    if (count == null) {
16116                                            count = Long.valueOf(0);
16117                                    }
16118    
16119                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NES,
16120                                            finderArgs, count);
16121    
16122                                    closeSession(session);
16123                            }
16124                    }
16125    
16126                    return count.intValue();
16127            }
16128    
16129            /**
16130             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
16131             *
16132             * @param companyId the company ID
16133             * @param status the status
16134             * @return the number of matching blogs entries
16135             * @throws SystemException if a system exception occurred
16136             */
16137            public int countByC_S(long companyId, int status) throws SystemException {
16138                    Object[] finderArgs = new Object[] { companyId, status };
16139    
16140                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
16141                                    finderArgs, this);
16142    
16143                    if (count == null) {
16144                            StringBundler query = new StringBundler(3);
16145    
16146                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16147    
16148                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
16149    
16150                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
16151    
16152                            String sql = query.toString();
16153    
16154                            Session session = null;
16155    
16156                            try {
16157                                    session = openSession();
16158    
16159                                    Query q = session.createQuery(sql);
16160    
16161                                    QueryPos qPos = QueryPos.getInstance(q);
16162    
16163                                    qPos.add(companyId);
16164    
16165                                    qPos.add(status);
16166    
16167                                    count = (Long)q.uniqueResult();
16168                            }
16169                            catch (Exception e) {
16170                                    throw processException(e);
16171                            }
16172                            finally {
16173                                    if (count == null) {
16174                                            count = Long.valueOf(0);
16175                                    }
16176    
16177                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
16178                                            count);
16179    
16180                                    closeSession(session);
16181                            }
16182                    }
16183    
16184                    return count.intValue();
16185            }
16186    
16187            /**
16188             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
16189             *
16190             * @param groupId the group ID
16191             * @param urlTitle the url title
16192             * @return the number of matching blogs entries
16193             * @throws SystemException if a system exception occurred
16194             */
16195            public int countByG_UT(long groupId, String urlTitle)
16196                    throws SystemException {
16197                    Object[] finderArgs = new Object[] { groupId, urlTitle };
16198    
16199                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_UT,
16200                                    finderArgs, this);
16201    
16202                    if (count == null) {
16203                            StringBundler query = new StringBundler(3);
16204    
16205                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16206    
16207                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
16208    
16209                            if (urlTitle == null) {
16210                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
16211                            }
16212                            else {
16213                                    if (urlTitle.equals(StringPool.BLANK)) {
16214                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
16215                                    }
16216                                    else {
16217                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
16218                                    }
16219                            }
16220    
16221                            String sql = query.toString();
16222    
16223                            Session session = null;
16224    
16225                            try {
16226                                    session = openSession();
16227    
16228                                    Query q = session.createQuery(sql);
16229    
16230                                    QueryPos qPos = QueryPos.getInstance(q);
16231    
16232                                    qPos.add(groupId);
16233    
16234                                    if (urlTitle != null) {
16235                                            qPos.add(urlTitle);
16236                                    }
16237    
16238                                    count = (Long)q.uniqueResult();
16239                            }
16240                            catch (Exception e) {
16241                                    throw processException(e);
16242                            }
16243                            finally {
16244                                    if (count == null) {
16245                                            count = Long.valueOf(0);
16246                                    }
16247    
16248                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT,
16249                                            finderArgs, count);
16250    
16251                                    closeSession(session);
16252                            }
16253                    }
16254    
16255                    return count.intValue();
16256            }
16257    
16258            /**
16259             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
16260             *
16261             * @param groupId the group ID
16262             * @param displayDate the display date
16263             * @return the number of matching blogs entries
16264             * @throws SystemException if a system exception occurred
16265             */
16266            public int countByG_LtD(long groupId, Date displayDate)
16267                    throws SystemException {
16268                    Object[] finderArgs = new Object[] { groupId, displayDate };
16269    
16270                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD,
16271                                    finderArgs, this);
16272    
16273                    if (count == null) {
16274                            StringBundler query = new StringBundler(3);
16275    
16276                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16277    
16278                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
16279    
16280                            if (displayDate == null) {
16281                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
16282                            }
16283                            else {
16284                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
16285                            }
16286    
16287                            String sql = query.toString();
16288    
16289                            Session session = null;
16290    
16291                            try {
16292                                    session = openSession();
16293    
16294                                    Query q = session.createQuery(sql);
16295    
16296                                    QueryPos qPos = QueryPos.getInstance(q);
16297    
16298                                    qPos.add(groupId);
16299    
16300                                    if (displayDate != null) {
16301                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16302                                    }
16303    
16304                                    count = (Long)q.uniqueResult();
16305                            }
16306                            catch (Exception e) {
16307                                    throw processException(e);
16308                            }
16309                            finally {
16310                                    if (count == null) {
16311                                            count = Long.valueOf(0);
16312                                    }
16313    
16314                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD,
16315                                            finderArgs, count);
16316    
16317                                    closeSession(session);
16318                            }
16319                    }
16320    
16321                    return count.intValue();
16322            }
16323    
16324            /**
16325             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
16326             *
16327             * @param groupId the group ID
16328             * @param displayDate the display date
16329             * @return the number of matching blogs entries that the user has permission to view
16330             * @throws SystemException if a system exception occurred
16331             */
16332            public int filterCountByG_LtD(long groupId, Date displayDate)
16333                    throws SystemException {
16334                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16335                            return countByG_LtD(groupId, displayDate);
16336                    }
16337    
16338                    StringBundler query = new StringBundler(3);
16339    
16340                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16341    
16342                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
16343    
16344                    if (displayDate == null) {
16345                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
16346                    }
16347                    else {
16348                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
16349                    }
16350    
16351                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16352                                    BlogsEntry.class.getName(),
16353                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16354    
16355                    Session session = null;
16356    
16357                    try {
16358                            session = openSession();
16359    
16360                            SQLQuery q = session.createSQLQuery(sql);
16361    
16362                            q.addScalar(COUNT_COLUMN_NAME,
16363                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16364    
16365                            QueryPos qPos = QueryPos.getInstance(q);
16366    
16367                            qPos.add(groupId);
16368    
16369                            if (displayDate != null) {
16370                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
16371                            }
16372    
16373                            Long count = (Long)q.uniqueResult();
16374    
16375                            return count.intValue();
16376                    }
16377                    catch (Exception e) {
16378                            throw processException(e);
16379                    }
16380                    finally {
16381                            closeSession(session);
16382                    }
16383            }
16384    
16385            /**
16386             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
16387             *
16388             * @param groupId the group ID
16389             * @param status the status
16390             * @return the number of matching blogs entries
16391             * @throws SystemException if a system exception occurred
16392             */
16393            public int countByG_NeS(long groupId, int status) throws SystemException {
16394                    Object[] finderArgs = new Object[] { groupId, status };
16395    
16396                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NES,
16397                                    finderArgs, this);
16398    
16399                    if (count == null) {
16400                            StringBundler query = new StringBundler(3);
16401    
16402                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16403    
16404                            query.append(_FINDER_COLUMN_G_NES_GROUPID_2);
16405    
16406                            query.append(_FINDER_COLUMN_G_NES_STATUS_2);
16407    
16408                            String sql = query.toString();
16409    
16410                            Session session = null;
16411    
16412                            try {
16413                                    session = openSession();
16414    
16415                                    Query q = session.createQuery(sql);
16416    
16417                                    QueryPos qPos = QueryPos.getInstance(q);
16418    
16419                                    qPos.add(groupId);
16420    
16421                                    qPos.add(status);
16422    
16423                                    count = (Long)q.uniqueResult();
16424                            }
16425                            catch (Exception e) {
16426                                    throw processException(e);
16427                            }
16428                            finally {
16429                                    if (count == null) {
16430                                            count = Long.valueOf(0);
16431                                    }
16432    
16433                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NES,
16434                                            finderArgs, count);
16435    
16436                                    closeSession(session);
16437                            }
16438                    }
16439    
16440                    return count.intValue();
16441            }
16442    
16443            /**
16444             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
16445             *
16446             * @param groupId the group ID
16447             * @param status the status
16448             * @return the number of matching blogs entries that the user has permission to view
16449             * @throws SystemException if a system exception occurred
16450             */
16451            public int filterCountByG_NeS(long groupId, int status)
16452                    throws SystemException {
16453                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16454                            return countByG_NeS(groupId, status);
16455                    }
16456    
16457                    StringBundler query = new StringBundler(3);
16458    
16459                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16460    
16461                    query.append(_FINDER_COLUMN_G_NES_GROUPID_2);
16462    
16463                    query.append(_FINDER_COLUMN_G_NES_STATUS_2);
16464    
16465                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16466                                    BlogsEntry.class.getName(),
16467                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16468    
16469                    Session session = null;
16470    
16471                    try {
16472                            session = openSession();
16473    
16474                            SQLQuery q = session.createSQLQuery(sql);
16475    
16476                            q.addScalar(COUNT_COLUMN_NAME,
16477                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16478    
16479                            QueryPos qPos = QueryPos.getInstance(q);
16480    
16481                            qPos.add(groupId);
16482    
16483                            qPos.add(status);
16484    
16485                            Long count = (Long)q.uniqueResult();
16486    
16487                            return count.intValue();
16488                    }
16489                    catch (Exception e) {
16490                            throw processException(e);
16491                    }
16492                    finally {
16493                            closeSession(session);
16494                    }
16495            }
16496    
16497            /**
16498             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
16499             *
16500             * @param groupId the group ID
16501             * @param status the status
16502             * @return the number of matching blogs entries
16503             * @throws SystemException if a system exception occurred
16504             */
16505            public int countByG_S(long groupId, int status) throws SystemException {
16506                    Object[] finderArgs = new Object[] { groupId, status };
16507    
16508                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
16509                                    finderArgs, this);
16510    
16511                    if (count == null) {
16512                            StringBundler query = new StringBundler(3);
16513    
16514                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16515    
16516                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
16517    
16518                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
16519    
16520                            String sql = query.toString();
16521    
16522                            Session session = null;
16523    
16524                            try {
16525                                    session = openSession();
16526    
16527                                    Query q = session.createQuery(sql);
16528    
16529                                    QueryPos qPos = QueryPos.getInstance(q);
16530    
16531                                    qPos.add(groupId);
16532    
16533                                    qPos.add(status);
16534    
16535                                    count = (Long)q.uniqueResult();
16536                            }
16537                            catch (Exception e) {
16538                                    throw processException(e);
16539                            }
16540                            finally {
16541                                    if (count == null) {
16542                                            count = Long.valueOf(0);
16543                                    }
16544    
16545                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
16546                                            count);
16547    
16548                                    closeSession(session);
16549                            }
16550                    }
16551    
16552                    return count.intValue();
16553            }
16554    
16555            /**
16556             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
16557             *
16558             * @param groupId the group ID
16559             * @param status the status
16560             * @return the number of matching blogs entries that the user has permission to view
16561             * @throws SystemException if a system exception occurred
16562             */
16563            public int filterCountByG_S(long groupId, int status)
16564                    throws SystemException {
16565                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16566                            return countByG_S(groupId, status);
16567                    }
16568    
16569                    StringBundler query = new StringBundler(3);
16570    
16571                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16572    
16573                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
16574    
16575                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
16576    
16577                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16578                                    BlogsEntry.class.getName(),
16579                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16580    
16581                    Session session = null;
16582    
16583                    try {
16584                            session = openSession();
16585    
16586                            SQLQuery q = session.createSQLQuery(sql);
16587    
16588                            q.addScalar(COUNT_COLUMN_NAME,
16589                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16590    
16591                            QueryPos qPos = QueryPos.getInstance(q);
16592    
16593                            qPos.add(groupId);
16594    
16595                            qPos.add(status);
16596    
16597                            Long count = (Long)q.uniqueResult();
16598    
16599                            return count.intValue();
16600                    }
16601                    catch (Exception e) {
16602                            throw processException(e);
16603                    }
16604                    finally {
16605                            closeSession(session);
16606                    }
16607            }
16608    
16609            /**
16610             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
16611             *
16612             * @param displayDate the display date
16613             * @param status the status
16614             * @return the number of matching blogs entries
16615             * @throws SystemException if a system exception occurred
16616             */
16617            public int countByLtD_S(Date displayDate, int status)
16618                    throws SystemException {
16619                    Object[] finderArgs = new Object[] { displayDate, status };
16620    
16621                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S,
16622                                    finderArgs, this);
16623    
16624                    if (count == null) {
16625                            StringBundler query = new StringBundler(3);
16626    
16627                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16628    
16629                            if (displayDate == null) {
16630                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
16631                            }
16632                            else {
16633                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
16634                            }
16635    
16636                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
16637    
16638                            String sql = query.toString();
16639    
16640                            Session session = null;
16641    
16642                            try {
16643                                    session = openSession();
16644    
16645                                    Query q = session.createQuery(sql);
16646    
16647                                    QueryPos qPos = QueryPos.getInstance(q);
16648    
16649                                    if (displayDate != null) {
16650                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16651                                    }
16652    
16653                                    qPos.add(status);
16654    
16655                                    count = (Long)q.uniqueResult();
16656                            }
16657                            catch (Exception e) {
16658                                    throw processException(e);
16659                            }
16660                            finally {
16661                                    if (count == null) {
16662                                            count = Long.valueOf(0);
16663                                    }
16664    
16665                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S,
16666                                            finderArgs, count);
16667    
16668                                    closeSession(session);
16669                            }
16670                    }
16671    
16672                    return count.intValue();
16673            }
16674    
16675            /**
16676             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
16677             *
16678             * @param companyId the company ID
16679             * @param userId the user ID
16680             * @param status the status
16681             * @return the number of matching blogs entries
16682             * @throws SystemException if a system exception occurred
16683             */
16684            public int countByC_U_NeS(long companyId, long userId, int status)
16685                    throws SystemException {
16686                    Object[] finderArgs = new Object[] { companyId, userId, status };
16687    
16688                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NES,
16689                                    finderArgs, this);
16690    
16691                    if (count == null) {
16692                            StringBundler query = new StringBundler(4);
16693    
16694                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16695    
16696                            query.append(_FINDER_COLUMN_C_U_NES_COMPANYID_2);
16697    
16698                            query.append(_FINDER_COLUMN_C_U_NES_USERID_2);
16699    
16700                            query.append(_FINDER_COLUMN_C_U_NES_STATUS_2);
16701    
16702                            String sql = query.toString();
16703    
16704                            Session session = null;
16705    
16706                            try {
16707                                    session = openSession();
16708    
16709                                    Query q = session.createQuery(sql);
16710    
16711                                    QueryPos qPos = QueryPos.getInstance(q);
16712    
16713                                    qPos.add(companyId);
16714    
16715                                    qPos.add(userId);
16716    
16717                                    qPos.add(status);
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_WITH_PAGINATION_COUNT_BY_C_U_NES,
16730                                            finderArgs, count);
16731    
16732                                    closeSession(session);
16733                            }
16734                    }
16735    
16736                    return count.intValue();
16737            }
16738    
16739            /**
16740             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
16741             *
16742             * @param companyId the company ID
16743             * @param userId the user ID
16744             * @param status the status
16745             * @return the number of matching blogs entries
16746             * @throws SystemException if a system exception occurred
16747             */
16748            public int countByC_U_S(long companyId, long userId, int status)
16749                    throws SystemException {
16750                    Object[] finderArgs = new Object[] { companyId, userId, status };
16751    
16752                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_S,
16753                                    finderArgs, this);
16754    
16755                    if (count == null) {
16756                            StringBundler query = new StringBundler(4);
16757    
16758                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16759    
16760                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
16761    
16762                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
16763    
16764                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
16765    
16766                            String sql = query.toString();
16767    
16768                            Session session = null;
16769    
16770                            try {
16771                                    session = openSession();
16772    
16773                                    Query q = session.createQuery(sql);
16774    
16775                                    QueryPos qPos = QueryPos.getInstance(q);
16776    
16777                                    qPos.add(companyId);
16778    
16779                                    qPos.add(userId);
16780    
16781                                    qPos.add(status);
16782    
16783                                    count = (Long)q.uniqueResult();
16784                            }
16785                            catch (Exception e) {
16786                                    throw processException(e);
16787                            }
16788                            finally {
16789                                    if (count == null) {
16790                                            count = Long.valueOf(0);
16791                                    }
16792    
16793                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_S,
16794                                            finderArgs, count);
16795    
16796                                    closeSession(session);
16797                            }
16798                    }
16799    
16800                    return count.intValue();
16801            }
16802    
16803            /**
16804             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16805             *
16806             * @param companyId the company ID
16807             * @param displayDate the display date
16808             * @param status the status
16809             * @return the number of matching blogs entries
16810             * @throws SystemException if a system exception occurred
16811             */
16812            public int countByC_LtD_NeS(long companyId, Date displayDate, int status)
16813                    throws SystemException {
16814                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
16815    
16816                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NES,
16817                                    finderArgs, this);
16818    
16819                    if (count == null) {
16820                            StringBundler query = new StringBundler(4);
16821    
16822                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16823    
16824                            query.append(_FINDER_COLUMN_C_LTD_NES_COMPANYID_2);
16825    
16826                            if (displayDate == null) {
16827                                    query.append(_FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_1);
16828                            }
16829                            else {
16830                                    query.append(_FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_2);
16831                            }
16832    
16833                            query.append(_FINDER_COLUMN_C_LTD_NES_STATUS_2);
16834    
16835                            String sql = query.toString();
16836    
16837                            Session session = null;
16838    
16839                            try {
16840                                    session = openSession();
16841    
16842                                    Query q = session.createQuery(sql);
16843    
16844                                    QueryPos qPos = QueryPos.getInstance(q);
16845    
16846                                    qPos.add(companyId);
16847    
16848                                    if (displayDate != null) {
16849                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16850                                    }
16851    
16852                                    qPos.add(status);
16853    
16854                                    count = (Long)q.uniqueResult();
16855                            }
16856                            catch (Exception e) {
16857                                    throw processException(e);
16858                            }
16859                            finally {
16860                                    if (count == null) {
16861                                            count = Long.valueOf(0);
16862                                    }
16863    
16864                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NES,
16865                                            finderArgs, count);
16866    
16867                                    closeSession(session);
16868                            }
16869                    }
16870    
16871                    return count.intValue();
16872            }
16873    
16874            /**
16875             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
16876             *
16877             * @param companyId the company ID
16878             * @param displayDate the display date
16879             * @param status the status
16880             * @return the number of matching blogs entries
16881             * @throws SystemException if a system exception occurred
16882             */
16883            public int countByC_LtD_S(long companyId, Date displayDate, int status)
16884                    throws SystemException {
16885                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
16886    
16887                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S,
16888                                    finderArgs, this);
16889    
16890                    if (count == null) {
16891                            StringBundler query = new StringBundler(4);
16892    
16893                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16894    
16895                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
16896    
16897                            if (displayDate == null) {
16898                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
16899                            }
16900                            else {
16901                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
16902                            }
16903    
16904                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
16905    
16906                            String sql = query.toString();
16907    
16908                            Session session = null;
16909    
16910                            try {
16911                                    session = openSession();
16912    
16913                                    Query q = session.createQuery(sql);
16914    
16915                                    QueryPos qPos = QueryPos.getInstance(q);
16916    
16917                                    qPos.add(companyId);
16918    
16919                                    if (displayDate != null) {
16920                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16921                                    }
16922    
16923                                    qPos.add(status);
16924    
16925                                    count = (Long)q.uniqueResult();
16926                            }
16927                            catch (Exception e) {
16928                                    throw processException(e);
16929                            }
16930                            finally {
16931                                    if (count == null) {
16932                                            count = Long.valueOf(0);
16933                                    }
16934    
16935                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S,
16936                                            finderArgs, count);
16937    
16938                                    closeSession(session);
16939                            }
16940                    }
16941    
16942                    return count.intValue();
16943            }
16944    
16945            /**
16946             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
16947             *
16948             * @param groupId the group ID
16949             * @param userId the user ID
16950             * @param displayDate the display date
16951             * @return the number of matching blogs entries
16952             * @throws SystemException if a system exception occurred
16953             */
16954            public int countByG_U_LtD(long groupId, long userId, Date displayDate)
16955                    throws SystemException {
16956                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
16957    
16958                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD,
16959                                    finderArgs, this);
16960    
16961                    if (count == null) {
16962                            StringBundler query = new StringBundler(4);
16963    
16964                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16965    
16966                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
16967    
16968                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
16969    
16970                            if (displayDate == null) {
16971                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
16972                            }
16973                            else {
16974                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
16975                            }
16976    
16977                            String sql = query.toString();
16978    
16979                            Session session = null;
16980    
16981                            try {
16982                                    session = openSession();
16983    
16984                                    Query q = session.createQuery(sql);
16985    
16986                                    QueryPos qPos = QueryPos.getInstance(q);
16987    
16988                                    qPos.add(groupId);
16989    
16990                                    qPos.add(userId);
16991    
16992                                    if (displayDate != null) {
16993                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16994                                    }
16995    
16996                                    count = (Long)q.uniqueResult();
16997                            }
16998                            catch (Exception e) {
16999                                    throw processException(e);
17000                            }
17001                            finally {
17002                                    if (count == null) {
17003                                            count = Long.valueOf(0);
17004                                    }
17005    
17006                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD,
17007                                            finderArgs, count);
17008    
17009                                    closeSession(session);
17010                            }
17011                    }
17012    
17013                    return count.intValue();
17014            }
17015    
17016            /**
17017             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
17018             *
17019             * @param groupId the group ID
17020             * @param userId the user ID
17021             * @param displayDate the display date
17022             * @return the number of matching blogs entries that the user has permission to view
17023             * @throws SystemException if a system exception occurred
17024             */
17025            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate)
17026                    throws SystemException {
17027                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17028                            return countByG_U_LtD(groupId, userId, displayDate);
17029                    }
17030    
17031                    StringBundler query = new StringBundler(4);
17032    
17033                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17034    
17035                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
17036    
17037                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
17038    
17039                    if (displayDate == null) {
17040                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
17041                    }
17042                    else {
17043                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
17044                    }
17045    
17046                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17047                                    BlogsEntry.class.getName(),
17048                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17049    
17050                    Session session = null;
17051    
17052                    try {
17053                            session = openSession();
17054    
17055                            SQLQuery q = session.createSQLQuery(sql);
17056    
17057                            q.addScalar(COUNT_COLUMN_NAME,
17058                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17059    
17060                            QueryPos qPos = QueryPos.getInstance(q);
17061    
17062                            qPos.add(groupId);
17063    
17064                            qPos.add(userId);
17065    
17066                            if (displayDate != null) {
17067                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17068                            }
17069    
17070                            Long count = (Long)q.uniqueResult();
17071    
17072                            return count.intValue();
17073                    }
17074                    catch (Exception e) {
17075                            throw processException(e);
17076                    }
17077                    finally {
17078                            closeSession(session);
17079                    }
17080            }
17081    
17082            /**
17083             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
17084             *
17085             * @param groupId the group ID
17086             * @param userId the user ID
17087             * @param status the status
17088             * @return the number of matching blogs entries
17089             * @throws SystemException if a system exception occurred
17090             */
17091            public int countByG_U_NeS(long groupId, long userId, int status)
17092                    throws SystemException {
17093                    Object[] finderArgs = new Object[] { groupId, userId, status };
17094    
17095                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NES,
17096                                    finderArgs, this);
17097    
17098                    if (count == null) {
17099                            StringBundler query = new StringBundler(4);
17100    
17101                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17102    
17103                            query.append(_FINDER_COLUMN_G_U_NES_GROUPID_2);
17104    
17105                            query.append(_FINDER_COLUMN_G_U_NES_USERID_2);
17106    
17107                            query.append(_FINDER_COLUMN_G_U_NES_STATUS_2);
17108    
17109                            String sql = query.toString();
17110    
17111                            Session session = null;
17112    
17113                            try {
17114                                    session = openSession();
17115    
17116                                    Query q = session.createQuery(sql);
17117    
17118                                    QueryPos qPos = QueryPos.getInstance(q);
17119    
17120                                    qPos.add(groupId);
17121    
17122                                    qPos.add(userId);
17123    
17124                                    qPos.add(status);
17125    
17126                                    count = (Long)q.uniqueResult();
17127                            }
17128                            catch (Exception e) {
17129                                    throw processException(e);
17130                            }
17131                            finally {
17132                                    if (count == null) {
17133                                            count = Long.valueOf(0);
17134                                    }
17135    
17136                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NES,
17137                                            finderArgs, count);
17138    
17139                                    closeSession(session);
17140                            }
17141                    }
17142    
17143                    return count.intValue();
17144            }
17145    
17146            /**
17147             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
17148             *
17149             * @param groupId the group ID
17150             * @param userId the user ID
17151             * @param status the status
17152             * @return the number of matching blogs entries that the user has permission to view
17153             * @throws SystemException if a system exception occurred
17154             */
17155            public int filterCountByG_U_NeS(long groupId, long userId, int status)
17156                    throws SystemException {
17157                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17158                            return countByG_U_NeS(groupId, userId, status);
17159                    }
17160    
17161                    StringBundler query = new StringBundler(4);
17162    
17163                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17164    
17165                    query.append(_FINDER_COLUMN_G_U_NES_GROUPID_2);
17166    
17167                    query.append(_FINDER_COLUMN_G_U_NES_USERID_2);
17168    
17169                    query.append(_FINDER_COLUMN_G_U_NES_STATUS_2);
17170    
17171                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17172                                    BlogsEntry.class.getName(),
17173                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17174    
17175                    Session session = null;
17176    
17177                    try {
17178                            session = openSession();
17179    
17180                            SQLQuery q = session.createSQLQuery(sql);
17181    
17182                            q.addScalar(COUNT_COLUMN_NAME,
17183                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17184    
17185                            QueryPos qPos = QueryPos.getInstance(q);
17186    
17187                            qPos.add(groupId);
17188    
17189                            qPos.add(userId);
17190    
17191                            qPos.add(status);
17192    
17193                            Long count = (Long)q.uniqueResult();
17194    
17195                            return count.intValue();
17196                    }
17197                    catch (Exception e) {
17198                            throw processException(e);
17199                    }
17200                    finally {
17201                            closeSession(session);
17202                    }
17203            }
17204    
17205            /**
17206             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
17207             *
17208             * @param groupId the group ID
17209             * @param userId the user ID
17210             * @param status the status
17211             * @return the number of matching blogs entries
17212             * @throws SystemException if a system exception occurred
17213             */
17214            public int countByG_U_S(long groupId, long userId, int status)
17215                    throws SystemException {
17216                    Object[] finderArgs = new Object[] { groupId, userId, status };
17217    
17218                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_S,
17219                                    finderArgs, this);
17220    
17221                    if (count == null) {
17222                            StringBundler query = new StringBundler(4);
17223    
17224                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17225    
17226                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
17227    
17228                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
17229    
17230                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
17231    
17232                            String sql = query.toString();
17233    
17234                            Session session = null;
17235    
17236                            try {
17237                                    session = openSession();
17238    
17239                                    Query q = session.createQuery(sql);
17240    
17241                                    QueryPos qPos = QueryPos.getInstance(q);
17242    
17243                                    qPos.add(groupId);
17244    
17245                                    qPos.add(userId);
17246    
17247                                    qPos.add(status);
17248    
17249                                    count = (Long)q.uniqueResult();
17250                            }
17251                            catch (Exception e) {
17252                                    throw processException(e);
17253                            }
17254                            finally {
17255                                    if (count == null) {
17256                                            count = Long.valueOf(0);
17257                                    }
17258    
17259                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_S,
17260                                            finderArgs, count);
17261    
17262                                    closeSession(session);
17263                            }
17264                    }
17265    
17266                    return count.intValue();
17267            }
17268    
17269            /**
17270             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
17271             *
17272             * @param groupId the group ID
17273             * @param userId the user ID
17274             * @param status the status
17275             * @return the number of matching blogs entries that the user has permission to view
17276             * @throws SystemException if a system exception occurred
17277             */
17278            public int filterCountByG_U_S(long groupId, long userId, int status)
17279                    throws SystemException {
17280                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17281                            return countByG_U_S(groupId, userId, status);
17282                    }
17283    
17284                    StringBundler query = new StringBundler(4);
17285    
17286                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17287    
17288                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
17289    
17290                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
17291    
17292                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
17293    
17294                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17295                                    BlogsEntry.class.getName(),
17296                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17297    
17298                    Session session = null;
17299    
17300                    try {
17301                            session = openSession();
17302    
17303                            SQLQuery q = session.createSQLQuery(sql);
17304    
17305                            q.addScalar(COUNT_COLUMN_NAME,
17306                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17307    
17308                            QueryPos qPos = QueryPos.getInstance(q);
17309    
17310                            qPos.add(groupId);
17311    
17312                            qPos.add(userId);
17313    
17314                            qPos.add(status);
17315    
17316                            Long count = (Long)q.uniqueResult();
17317    
17318                            return count.intValue();
17319                    }
17320                    catch (Exception e) {
17321                            throw processException(e);
17322                    }
17323                    finally {
17324                            closeSession(session);
17325                    }
17326            }
17327    
17328            /**
17329             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17330             *
17331             * @param groupId the group ID
17332             * @param displayDate the display date
17333             * @param status the status
17334             * @return the number of matching blogs entries
17335             * @throws SystemException if a system exception occurred
17336             */
17337            public int countByG_LtD_NeS(long groupId, Date displayDate, int status)
17338                    throws SystemException {
17339                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
17340    
17341                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NES,
17342                                    finderArgs, this);
17343    
17344                    if (count == null) {
17345                            StringBundler query = new StringBundler(4);
17346    
17347                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17348    
17349                            query.append(_FINDER_COLUMN_G_LTD_NES_GROUPID_2);
17350    
17351                            if (displayDate == null) {
17352                                    query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_1);
17353                            }
17354                            else {
17355                                    query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_2);
17356                            }
17357    
17358                            query.append(_FINDER_COLUMN_G_LTD_NES_STATUS_2);
17359    
17360                            String sql = query.toString();
17361    
17362                            Session session = null;
17363    
17364                            try {
17365                                    session = openSession();
17366    
17367                                    Query q = session.createQuery(sql);
17368    
17369                                    QueryPos qPos = QueryPos.getInstance(q);
17370    
17371                                    qPos.add(groupId);
17372    
17373                                    if (displayDate != null) {
17374                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17375                                    }
17376    
17377                                    qPos.add(status);
17378    
17379                                    count = (Long)q.uniqueResult();
17380                            }
17381                            catch (Exception e) {
17382                                    throw processException(e);
17383                            }
17384                            finally {
17385                                    if (count == null) {
17386                                            count = Long.valueOf(0);
17387                                    }
17388    
17389                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NES,
17390                                            finderArgs, count);
17391    
17392                                    closeSession(session);
17393                            }
17394                    }
17395    
17396                    return count.intValue();
17397            }
17398    
17399            /**
17400             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17401             *
17402             * @param groupId the group ID
17403             * @param displayDate the display date
17404             * @param status the status
17405             * @return the number of matching blogs entries that the user has permission to view
17406             * @throws SystemException if a system exception occurred
17407             */
17408            public int filterCountByG_LtD_NeS(long groupId, Date displayDate, int status)
17409                    throws SystemException {
17410                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17411                            return countByG_LtD_NeS(groupId, displayDate, status);
17412                    }
17413    
17414                    StringBundler query = new StringBundler(4);
17415    
17416                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17417    
17418                    query.append(_FINDER_COLUMN_G_LTD_NES_GROUPID_2);
17419    
17420                    if (displayDate == null) {
17421                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_1);
17422                    }
17423                    else {
17424                            query.append(_FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_2);
17425                    }
17426    
17427                    query.append(_FINDER_COLUMN_G_LTD_NES_STATUS_2);
17428    
17429                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17430                                    BlogsEntry.class.getName(),
17431                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17432    
17433                    Session session = null;
17434    
17435                    try {
17436                            session = openSession();
17437    
17438                            SQLQuery q = session.createSQLQuery(sql);
17439    
17440                            q.addScalar(COUNT_COLUMN_NAME,
17441                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17442    
17443                            QueryPos qPos = QueryPos.getInstance(q);
17444    
17445                            qPos.add(groupId);
17446    
17447                            if (displayDate != null) {
17448                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17449                            }
17450    
17451                            qPos.add(status);
17452    
17453                            Long count = (Long)q.uniqueResult();
17454    
17455                            return count.intValue();
17456                    }
17457                    catch (Exception e) {
17458                            throw processException(e);
17459                    }
17460                    finally {
17461                            closeSession(session);
17462                    }
17463            }
17464    
17465            /**
17466             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
17467             *
17468             * @param groupId the group ID
17469             * @param displayDate the display date
17470             * @param status the status
17471             * @return the number of matching blogs entries
17472             * @throws SystemException if a system exception occurred
17473             */
17474            public int countByG_LtD_S(long groupId, Date displayDate, int status)
17475                    throws SystemException {
17476                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
17477    
17478                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S,
17479                                    finderArgs, this);
17480    
17481                    if (count == null) {
17482                            StringBundler query = new StringBundler(4);
17483    
17484                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17485    
17486                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
17487    
17488                            if (displayDate == null) {
17489                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
17490                            }
17491                            else {
17492                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
17493                            }
17494    
17495                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
17496    
17497                            String sql = query.toString();
17498    
17499                            Session session = null;
17500    
17501                            try {
17502                                    session = openSession();
17503    
17504                                    Query q = session.createQuery(sql);
17505    
17506                                    QueryPos qPos = QueryPos.getInstance(q);
17507    
17508                                    qPos.add(groupId);
17509    
17510                                    if (displayDate != null) {
17511                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17512                                    }
17513    
17514                                    qPos.add(status);
17515    
17516                                    count = (Long)q.uniqueResult();
17517                            }
17518                            catch (Exception e) {
17519                                    throw processException(e);
17520                            }
17521                            finally {
17522                                    if (count == null) {
17523                                            count = Long.valueOf(0);
17524                                    }
17525    
17526                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S,
17527                                            finderArgs, count);
17528    
17529                                    closeSession(session);
17530                            }
17531                    }
17532    
17533                    return count.intValue();
17534            }
17535    
17536            /**
17537             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
17538             *
17539             * @param groupId the group ID
17540             * @param displayDate the display date
17541             * @param status the status
17542             * @return the number of matching blogs entries that the user has permission to view
17543             * @throws SystemException if a system exception occurred
17544             */
17545            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status)
17546                    throws SystemException {
17547                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17548                            return countByG_LtD_S(groupId, displayDate, status);
17549                    }
17550    
17551                    StringBundler query = new StringBundler(4);
17552    
17553                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17554    
17555                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
17556    
17557                    if (displayDate == null) {
17558                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
17559                    }
17560                    else {
17561                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
17562                    }
17563    
17564                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
17565    
17566                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17567                                    BlogsEntry.class.getName(),
17568                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17569    
17570                    Session session = null;
17571    
17572                    try {
17573                            session = openSession();
17574    
17575                            SQLQuery q = session.createSQLQuery(sql);
17576    
17577                            q.addScalar(COUNT_COLUMN_NAME,
17578                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17579    
17580                            QueryPos qPos = QueryPos.getInstance(q);
17581    
17582                            qPos.add(groupId);
17583    
17584                            if (displayDate != null) {
17585                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17586                            }
17587    
17588                            qPos.add(status);
17589    
17590                            Long count = (Long)q.uniqueResult();
17591    
17592                            return count.intValue();
17593                    }
17594                    catch (Exception e) {
17595                            throw processException(e);
17596                    }
17597                    finally {
17598                            closeSession(session);
17599                    }
17600            }
17601    
17602            /**
17603             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17604             *
17605             * @param groupId the group ID
17606             * @param userId the user ID
17607             * @param displayDate the display date
17608             * @param status the status
17609             * @return the number of matching blogs entries
17610             * @throws SystemException if a system exception occurred
17611             */
17612            public int countByG_U_LtD_NeS(long groupId, long userId, Date displayDate,
17613                    int status) throws SystemException {
17614                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17615    
17616                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NES,
17617                                    finderArgs, this);
17618    
17619                    if (count == null) {
17620                            StringBundler query = new StringBundler(5);
17621    
17622                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17623    
17624                            query.append(_FINDER_COLUMN_G_U_LTD_NES_GROUPID_2);
17625    
17626                            query.append(_FINDER_COLUMN_G_U_LTD_NES_USERID_2);
17627    
17628                            if (displayDate == null) {
17629                                    query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_1);
17630                            }
17631                            else {
17632                                    query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_2);
17633                            }
17634    
17635                            query.append(_FINDER_COLUMN_G_U_LTD_NES_STATUS_2);
17636    
17637                            String sql = query.toString();
17638    
17639                            Session session = null;
17640    
17641                            try {
17642                                    session = openSession();
17643    
17644                                    Query q = session.createQuery(sql);
17645    
17646                                    QueryPos qPos = QueryPos.getInstance(q);
17647    
17648                                    qPos.add(groupId);
17649    
17650                                    qPos.add(userId);
17651    
17652                                    if (displayDate != null) {
17653                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17654                                    }
17655    
17656                                    qPos.add(status);
17657    
17658                                    count = (Long)q.uniqueResult();
17659                            }
17660                            catch (Exception e) {
17661                                    throw processException(e);
17662                            }
17663                            finally {
17664                                    if (count == null) {
17665                                            count = Long.valueOf(0);
17666                                    }
17667    
17668                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NES,
17669                                            finderArgs, count);
17670    
17671                                    closeSession(session);
17672                            }
17673                    }
17674    
17675                    return count.intValue();
17676            }
17677    
17678            /**
17679             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17680             *
17681             * @param groupId the group ID
17682             * @param userId the user ID
17683             * @param displayDate the display date
17684             * @param status the status
17685             * @return the number of matching blogs entries that the user has permission to view
17686             * @throws SystemException if a system exception occurred
17687             */
17688            public int filterCountByG_U_LtD_NeS(long groupId, long userId,
17689                    Date displayDate, int status) throws SystemException {
17690                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17691                            return countByG_U_LtD_NeS(groupId, userId, displayDate, status);
17692                    }
17693    
17694                    StringBundler query = new StringBundler(5);
17695    
17696                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17697    
17698                    query.append(_FINDER_COLUMN_G_U_LTD_NES_GROUPID_2);
17699    
17700                    query.append(_FINDER_COLUMN_G_U_LTD_NES_USERID_2);
17701    
17702                    if (displayDate == null) {
17703                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_1);
17704                    }
17705                    else {
17706                            query.append(_FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_2);
17707                    }
17708    
17709                    query.append(_FINDER_COLUMN_G_U_LTD_NES_STATUS_2);
17710    
17711                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17712                                    BlogsEntry.class.getName(),
17713                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17714    
17715                    Session session = null;
17716    
17717                    try {
17718                            session = openSession();
17719    
17720                            SQLQuery q = session.createSQLQuery(sql);
17721    
17722                            q.addScalar(COUNT_COLUMN_NAME,
17723                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17724    
17725                            QueryPos qPos = QueryPos.getInstance(q);
17726    
17727                            qPos.add(groupId);
17728    
17729                            qPos.add(userId);
17730    
17731                            if (displayDate != null) {
17732                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17733                            }
17734    
17735                            qPos.add(status);
17736    
17737                            Long count = (Long)q.uniqueResult();
17738    
17739                            return count.intValue();
17740                    }
17741                    catch (Exception e) {
17742                            throw processException(e);
17743                    }
17744                    finally {
17745                            closeSession(session);
17746                    }
17747            }
17748    
17749            /**
17750             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17751             *
17752             * @param groupId the group ID
17753             * @param userId the user ID
17754             * @param displayDate the display date
17755             * @param status the status
17756             * @return the number of matching blogs entries
17757             * @throws SystemException if a system exception occurred
17758             */
17759            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17760                    int status) throws SystemException {
17761                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17762    
17763                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S,
17764                                    finderArgs, this);
17765    
17766                    if (count == null) {
17767                            StringBundler query = new StringBundler(5);
17768    
17769                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17770    
17771                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17772    
17773                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17774    
17775                            if (displayDate == null) {
17776                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17777                            }
17778                            else {
17779                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17780                            }
17781    
17782                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17783    
17784                            String sql = query.toString();
17785    
17786                            Session session = null;
17787    
17788                            try {
17789                                    session = openSession();
17790    
17791                                    Query q = session.createQuery(sql);
17792    
17793                                    QueryPos qPos = QueryPos.getInstance(q);
17794    
17795                                    qPos.add(groupId);
17796    
17797                                    qPos.add(userId);
17798    
17799                                    if (displayDate != null) {
17800                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17801                                    }
17802    
17803                                    qPos.add(status);
17804    
17805                                    count = (Long)q.uniqueResult();
17806                            }
17807                            catch (Exception e) {
17808                                    throw processException(e);
17809                            }
17810                            finally {
17811                                    if (count == null) {
17812                                            count = Long.valueOf(0);
17813                                    }
17814    
17815                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S,
17816                                            finderArgs, count);
17817    
17818                                    closeSession(session);
17819                            }
17820                    }
17821    
17822                    return count.intValue();
17823            }
17824    
17825            /**
17826             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17827             *
17828             * @param groupId the group ID
17829             * @param userId the user ID
17830             * @param displayDate the display date
17831             * @param status the status
17832             * @return the number of matching blogs entries that the user has permission to view
17833             * @throws SystemException if a system exception occurred
17834             */
17835            public int filterCountByG_U_LtD_S(long groupId, long userId,
17836                    Date displayDate, int status) throws SystemException {
17837                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17838                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17839                    }
17840    
17841                    StringBundler query = new StringBundler(5);
17842    
17843                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17844    
17845                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17846    
17847                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17848    
17849                    if (displayDate == null) {
17850                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17851                    }
17852                    else {
17853                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17854                    }
17855    
17856                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17857    
17858                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17859                                    BlogsEntry.class.getName(),
17860                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17861    
17862                    Session session = null;
17863    
17864                    try {
17865                            session = openSession();
17866    
17867                            SQLQuery q = session.createSQLQuery(sql);
17868    
17869                            q.addScalar(COUNT_COLUMN_NAME,
17870                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17871    
17872                            QueryPos qPos = QueryPos.getInstance(q);
17873    
17874                            qPos.add(groupId);
17875    
17876                            qPos.add(userId);
17877    
17878                            if (displayDate != null) {
17879                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17880                            }
17881    
17882                            qPos.add(status);
17883    
17884                            Long count = (Long)q.uniqueResult();
17885    
17886                            return count.intValue();
17887                    }
17888                    catch (Exception e) {
17889                            throw processException(e);
17890                    }
17891                    finally {
17892                            closeSession(session);
17893                    }
17894            }
17895    
17896            /**
17897             * Returns the number of blogs entries.
17898             *
17899             * @return the number of blogs entries
17900             * @throws SystemException if a system exception occurred
17901             */
17902            public int countAll() throws SystemException {
17903                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
17904                                    FINDER_ARGS_EMPTY, this);
17905    
17906                    if (count == null) {
17907                            Session session = null;
17908    
17909                            try {
17910                                    session = openSession();
17911    
17912                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
17913    
17914                                    count = (Long)q.uniqueResult();
17915                            }
17916                            catch (Exception e) {
17917                                    throw processException(e);
17918                            }
17919                            finally {
17920                                    if (count == null) {
17921                                            count = Long.valueOf(0);
17922                                    }
17923    
17924                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
17925                                            FINDER_ARGS_EMPTY, count);
17926    
17927                                    closeSession(session);
17928                            }
17929                    }
17930    
17931                    return count.intValue();
17932            }
17933    
17934            /**
17935             * Initializes the blogs entry persistence.
17936             */
17937            public void afterPropertiesSet() {
17938                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
17939                                            com.liferay.portal.util.PropsUtil.get(
17940                                                    "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
17941    
17942                    if (listenerClassNames.length > 0) {
17943                            try {
17944                                    List<ModelListener<BlogsEntry>> listenersList = new ArrayList<ModelListener<BlogsEntry>>();
17945    
17946                                    for (String listenerClassName : listenerClassNames) {
17947                                            listenersList.add((ModelListener<BlogsEntry>)InstanceFactory.newInstance(
17948                                                            listenerClassName));
17949                                    }
17950    
17951                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
17952                            }
17953                            catch (Exception e) {
17954                                    _log.error(e);
17955                            }
17956                    }
17957            }
17958    
17959            public void destroy() {
17960                    EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
17961                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
17962                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17963            }
17964    
17965            @BeanReference(type = BlogsEntryPersistence.class)
17966            protected BlogsEntryPersistence blogsEntryPersistence;
17967            @BeanReference(type = BlogsStatsUserPersistence.class)
17968            protected BlogsStatsUserPersistence blogsStatsUserPersistence;
17969            @BeanReference(type = CompanyPersistence.class)
17970            protected CompanyPersistence companyPersistence;
17971            @BeanReference(type = GroupPersistence.class)
17972            protected GroupPersistence groupPersistence;
17973            @BeanReference(type = ImagePersistence.class)
17974            protected ImagePersistence imagePersistence;
17975            @BeanReference(type = OrganizationPersistence.class)
17976            protected OrganizationPersistence organizationPersistence;
17977            @BeanReference(type = PortletPreferencesPersistence.class)
17978            protected PortletPreferencesPersistence portletPreferencesPersistence;
17979            @BeanReference(type = SubscriptionPersistence.class)
17980            protected SubscriptionPersistence subscriptionPersistence;
17981            @BeanReference(type = UserPersistence.class)
17982            protected UserPersistence userPersistence;
17983            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
17984            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
17985            @BeanReference(type = AssetEntryPersistence.class)
17986            protected AssetEntryPersistence assetEntryPersistence;
17987            @BeanReference(type = AssetLinkPersistence.class)
17988            protected AssetLinkPersistence assetLinkPersistence;
17989            @BeanReference(type = AssetTagPersistence.class)
17990            protected AssetTagPersistence assetTagPersistence;
17991            @BeanReference(type = ExpandoValuePersistence.class)
17992            protected ExpandoValuePersistence expandoValuePersistence;
17993            @BeanReference(type = MBMessagePersistence.class)
17994            protected MBMessagePersistence mbMessagePersistence;
17995            @BeanReference(type = RatingsStatsPersistence.class)
17996            protected RatingsStatsPersistence ratingsStatsPersistence;
17997            @BeanReference(type = SocialActivityPersistence.class)
17998            protected SocialActivityPersistence socialActivityPersistence;
17999            @BeanReference(type = SocialActivityCounterPersistence.class)
18000            protected SocialActivityCounterPersistence socialActivityCounterPersistence;
18001            @BeanReference(type = TrashEntryPersistence.class)
18002            protected TrashEntryPersistence trashEntryPersistence;
18003            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
18004            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
18005            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
18006            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
18007            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
18008            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
18009            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?)";
18010            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
18011            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
18012            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?) AND ";
18013            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
18014            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
18015            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
18016            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?) AND ";
18017            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
18018            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
18019            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
18020            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18021            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
18022            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18023            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
18024            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
18025            private static final String _FINDER_COLUMN_C_NES_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18026            private static final String _FINDER_COLUMN_C_NES_STATUS_2 = "blogsEntry.status != ?";
18027            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18028            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
18029            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18030            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
18031            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
18032            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = ?)";
18033            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18034            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
18035            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
18036            private static final String _FINDER_COLUMN_G_NES_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18037            private static final String _FINDER_COLUMN_G_NES_STATUS_2 = "blogsEntry.status != ?";
18038            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18039            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
18040            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
18041            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18042            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
18043            private static final String _FINDER_COLUMN_C_U_NES_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18044            private static final String _FINDER_COLUMN_C_U_NES_USERID_2 = "blogsEntry.userId = ? AND ";
18045            private static final String _FINDER_COLUMN_C_U_NES_STATUS_2 = "blogsEntry.status != ?";
18046            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18047            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
18048            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
18049            private static final String _FINDER_COLUMN_C_LTD_NES_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18050            private static final String _FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
18051            private static final String _FINDER_COLUMN_C_LTD_NES_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18052            private static final String _FINDER_COLUMN_C_LTD_NES_STATUS_2 = "blogsEntry.status != ?";
18053            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
18054            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
18055            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18056            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
18057            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18058            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
18059            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
18060            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
18061            private static final String _FINDER_COLUMN_G_U_NES_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18062            private static final String _FINDER_COLUMN_G_U_NES_USERID_2 = "blogsEntry.userId = ? AND ";
18063            private static final String _FINDER_COLUMN_G_U_NES_STATUS_2 = "blogsEntry.status != ?";
18064            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18065            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
18066            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
18067            private static final String _FINDER_COLUMN_G_LTD_NES_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18068            private static final String _FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
18069            private static final String _FINDER_COLUMN_G_LTD_NES_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18070            private static final String _FINDER_COLUMN_G_LTD_NES_STATUS_2 = "blogsEntry.status != ?";
18071            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18072            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
18073            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18074            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
18075            private static final String _FINDER_COLUMN_G_U_LTD_NES_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18076            private static final String _FINDER_COLUMN_G_U_LTD_NES_USERID_2 = "blogsEntry.userId = ? AND ";
18077            private static final String _FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
18078            private static final String _FINDER_COLUMN_G_U_LTD_NES_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18079            private static final String _FINDER_COLUMN_G_U_LTD_NES_STATUS_2 = "blogsEntry.status != ?";
18080            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18081            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
18082            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
18083            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18084            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
18085            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
18086            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
18087            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
18088                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
18089            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
18090                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
18091            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
18092            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
18093            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
18094            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
18095            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
18096            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
18097            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
18098            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18099            private static Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
18100            private static BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
18101                            @Override
18102                            public Object clone() {
18103                                    return this;
18104                            }
18105    
18106                            @Override
18107                            public CacheModel<BlogsEntry> toCacheModel() {
18108                                    return _nullBlogsEntryCacheModel;
18109                            }
18110                    };
18111    
18112            private static CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
18113                            public BlogsEntry toEntityModel() {
18114                                    return _nullBlogsEntry;
18115                            }
18116                    };
18117    }