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