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