001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.sanitizer.Sanitizer;
031    import com.liferay.portal.kernel.sanitizer.SanitizerException;
032    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
033    import com.liferay.portal.kernel.util.CalendarUtil;
034    import com.liferay.portal.kernel.util.ContentTypes;
035    import com.liferay.portal.kernel.util.GetterUtil;
036    import com.liferay.portal.kernel.util.InstanceFactory;
037    import com.liferay.portal.kernel.util.OrderByComparator;
038    import com.liferay.portal.kernel.util.StringBundler;
039    import com.liferay.portal.kernel.util.StringPool;
040    import com.liferay.portal.kernel.util.StringUtil;
041    import com.liferay.portal.kernel.util.UnmodifiableList;
042    import com.liferay.portal.kernel.util.Validator;
043    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
044    import com.liferay.portal.model.CacheModel;
045    import com.liferay.portal.model.ModelListener;
046    import com.liferay.portal.security.auth.PrincipalThreadLocal;
047    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049    
050    import com.liferay.portlet.blogs.NoSuchEntryException;
051    import com.liferay.portlet.blogs.model.BlogsEntry;
052    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
053    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
054    
055    import java.io.Serializable;
056    
057    import java.util.ArrayList;
058    import java.util.Collections;
059    import java.util.Date;
060    import java.util.List;
061    
062    /**
063     * The persistence implementation for the blogs entry service.
064     *
065     * <p>
066     * Caching information and settings can be found in <code>portal.properties</code>
067     * </p>
068     *
069     * @author Brian Wing Shun Chan
070     * @see BlogsEntryPersistence
071     * @see BlogsEntryUtil
072     * @generated
073     */
074    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
075            implements BlogsEntryPersistence {
076            /*
077             * NOTE FOR DEVELOPERS:
078             *
079             * 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.
080             */
081            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
082            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List1";
084            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085                    ".List2";
086            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
087                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
088                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
089            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
090                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
092            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
093                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
096                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
098                            new String[] {
099                                    String.class.getName(),
100                                    
101                            Integer.class.getName(), Integer.class.getName(),
102                                    OrderByComparator.class.getName()
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
105                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
107                            new String[] { String.class.getName() },
108                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
109                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
110                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
111            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
112                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
114                            new String[] { String.class.getName() });
115    
116            /**
117             * Returns all the blogs entries where uuid = &#63;.
118             *
119             * @param uuid the uuid
120             * @return the matching blogs entries
121             * @throws SystemException if a system exception occurred
122             */
123            public List<BlogsEntry> findByUuid(String uuid) throws SystemException {
124                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
125            }
126    
127            /**
128             * Returns a range of all the blogs entries where uuid = &#63;.
129             *
130             * <p>
131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
132             * </p>
133             *
134             * @param uuid the uuid
135             * @param start the lower bound of the range of blogs entries
136             * @param end the upper bound of the range of blogs entries (not inclusive)
137             * @return the range of matching blogs entries
138             * @throws SystemException if a system exception occurred
139             */
140            public List<BlogsEntry> findByUuid(String uuid, int start, int end)
141                    throws SystemException {
142                    return findByUuid(uuid, start, end, null);
143            }
144    
145            /**
146             * Returns an ordered range of all the blogs entries where uuid = &#63;.
147             *
148             * <p>
149             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
150             * </p>
151             *
152             * @param uuid the uuid
153             * @param start the lower bound of the range of blogs entries
154             * @param end the upper bound of the range of blogs entries (not inclusive)
155             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
156             * @return the ordered range of matching blogs entries
157             * @throws SystemException if a system exception occurred
158             */
159            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
160                    OrderByComparator orderByComparator) throws SystemException {
161                    boolean pagination = true;
162                    FinderPath finderPath = null;
163                    Object[] finderArgs = null;
164    
165                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
166                                    (orderByComparator == null)) {
167                            pagination = false;
168                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
169                            finderArgs = new Object[] { uuid };
170                    }
171                    else {
172                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
173                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
174                    }
175    
176                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
177                                    finderArgs, this);
178    
179                    if ((list != null) && !list.isEmpty()) {
180                            for (BlogsEntry blogsEntry : list) {
181                                    if (!Validator.equals(uuid, blogsEntry.getUuid())) {
182                                            list = null;
183    
184                                            break;
185                                    }
186                            }
187                    }
188    
189                    if (list == null) {
190                            StringBundler query = null;
191    
192                            if (orderByComparator != null) {
193                                    query = new StringBundler(3 +
194                                                    (orderByComparator.getOrderByFields().length * 3));
195                            }
196                            else {
197                                    query = new StringBundler(3);
198                            }
199    
200                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
201    
202                            if (uuid == null) {
203                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
204                            }
205                            else {
206                                    if (uuid.equals(StringPool.BLANK)) {
207                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
208                                    }
209                                    else {
210                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
211                                    }
212                            }
213    
214                            if (orderByComparator != null) {
215                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216                                            orderByComparator);
217                            }
218                            else
219                             if (pagination) {
220                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
221                            }
222    
223                            String sql = query.toString();
224    
225                            Session session = null;
226    
227                            try {
228                                    session = openSession();
229    
230                                    Query q = session.createQuery(sql);
231    
232                                    QueryPos qPos = QueryPos.getInstance(q);
233    
234                                    if (uuid != null) {
235                                            qPos.add(uuid);
236                                    }
237    
238                                    if (!pagination) {
239                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
240                                                            start, end, false);
241    
242                                            Collections.sort(list);
243    
244                                            list = new UnmodifiableList<BlogsEntry>(list);
245                                    }
246                                    else {
247                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
248                                                            start, end);
249                                    }
250    
251                                    cacheResult(list);
252    
253                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
254                            }
255                            catch (Exception e) {
256                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
257    
258                                    throw processException(e);
259                            }
260                            finally {
261                                    closeSession(session);
262                            }
263                    }
264    
265                    return list;
266            }
267    
268            /**
269             * Returns the first blogs entry in the ordered set where uuid = &#63;.
270             *
271             * @param uuid the uuid
272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
273             * @return the first matching blogs entry
274             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
275             * @throws SystemException if a system exception occurred
276             */
277            public BlogsEntry findByUuid_First(String uuid,
278                    OrderByComparator orderByComparator)
279                    throws NoSuchEntryException, SystemException {
280                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
281    
282                    if (blogsEntry != null) {
283                            return blogsEntry;
284                    }
285    
286                    StringBundler msg = new StringBundler(4);
287    
288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289    
290                    msg.append("uuid=");
291                    msg.append(uuid);
292    
293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
294    
295                    throw new NoSuchEntryException(msg.toString());
296            }
297    
298            /**
299             * Returns the first blogs entry in the ordered set where uuid = &#63;.
300             *
301             * @param uuid the uuid
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
304             * @throws SystemException if a system exception occurred
305             */
306            public BlogsEntry fetchByUuid_First(String uuid,
307                    OrderByComparator orderByComparator) throws SystemException {
308                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
309    
310                    if (!list.isEmpty()) {
311                            return list.get(0);
312                    }
313    
314                    return null;
315            }
316    
317            /**
318             * Returns the last blogs entry in the ordered set where uuid = &#63;.
319             *
320             * @param uuid the uuid
321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
322             * @return the last matching blogs entry
323             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
324             * @throws SystemException if a system exception occurred
325             */
326            public BlogsEntry findByUuid_Last(String uuid,
327                    OrderByComparator orderByComparator)
328                    throws NoSuchEntryException, SystemException {
329                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
330    
331                    if (blogsEntry != null) {
332                            return blogsEntry;
333                    }
334    
335                    StringBundler msg = new StringBundler(4);
336    
337                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338    
339                    msg.append("uuid=");
340                    msg.append(uuid);
341    
342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
343    
344                    throw new NoSuchEntryException(msg.toString());
345            }
346    
347            /**
348             * Returns the last blogs entry in the ordered set where uuid = &#63;.
349             *
350             * @param uuid the uuid
351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
352             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
353             * @throws SystemException if a system exception occurred
354             */
355            public BlogsEntry fetchByUuid_Last(String uuid,
356                    OrderByComparator orderByComparator) throws SystemException {
357                    int count = countByUuid(uuid);
358    
359                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
360                                    orderByComparator);
361    
362                    if (!list.isEmpty()) {
363                            return list.get(0);
364                    }
365    
366                    return null;
367            }
368    
369            /**
370             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
371             *
372             * @param entryId the primary key of the current blogs entry
373             * @param uuid the uuid
374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
375             * @return the previous, current, and next blogs entry
376             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
377             * @throws SystemException if a system exception occurred
378             */
379            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
380                    OrderByComparator orderByComparator)
381                    throws NoSuchEntryException, SystemException {
382                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
383    
384                    Session session = null;
385    
386                    try {
387                            session = openSession();
388    
389                            BlogsEntry[] array = new BlogsEntryImpl[3];
390    
391                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
392                                            orderByComparator, true);
393    
394                            array[1] = blogsEntry;
395    
396                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
397                                            orderByComparator, false);
398    
399                            return array;
400                    }
401                    catch (Exception e) {
402                            throw processException(e);
403                    }
404                    finally {
405                            closeSession(session);
406                    }
407            }
408    
409            protected BlogsEntry getByUuid_PrevAndNext(Session session,
410                    BlogsEntry blogsEntry, String uuid,
411                    OrderByComparator orderByComparator, boolean previous) {
412                    StringBundler query = null;
413    
414                    if (orderByComparator != null) {
415                            query = new StringBundler(6 +
416                                            (orderByComparator.getOrderByFields().length * 6));
417                    }
418                    else {
419                            query = new StringBundler(3);
420                    }
421    
422                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
423    
424                    if (uuid == null) {
425                            query.append(_FINDER_COLUMN_UUID_UUID_1);
426                    }
427                    else {
428                            if (uuid.equals(StringPool.BLANK)) {
429                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
430                            }
431                            else {
432                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
433                            }
434                    }
435    
436                    if (orderByComparator != null) {
437                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
438    
439                            if (orderByConditionFields.length > 0) {
440                                    query.append(WHERE_AND);
441                            }
442    
443                            for (int i = 0; i < orderByConditionFields.length; i++) {
444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
445                                    query.append(orderByConditionFields[i]);
446    
447                                    if ((i + 1) < orderByConditionFields.length) {
448                                            if (orderByComparator.isAscending() ^ previous) {
449                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
450                                            }
451                                            else {
452                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
453                                            }
454                                    }
455                                    else {
456                                            if (orderByComparator.isAscending() ^ previous) {
457                                                    query.append(WHERE_GREATER_THAN);
458                                            }
459                                            else {
460                                                    query.append(WHERE_LESSER_THAN);
461                                            }
462                                    }
463                            }
464    
465                            query.append(ORDER_BY_CLAUSE);
466    
467                            String[] orderByFields = orderByComparator.getOrderByFields();
468    
469                            for (int i = 0; i < orderByFields.length; i++) {
470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
471                                    query.append(orderByFields[i]);
472    
473                                    if ((i + 1) < orderByFields.length) {
474                                            if (orderByComparator.isAscending() ^ previous) {
475                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
476                                            }
477                                            else {
478                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
479                                            }
480                                    }
481                                    else {
482                                            if (orderByComparator.isAscending() ^ previous) {
483                                                    query.append(ORDER_BY_ASC);
484                                            }
485                                            else {
486                                                    query.append(ORDER_BY_DESC);
487                                            }
488                                    }
489                            }
490                    }
491                    else {
492                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
493                    }
494    
495                    String sql = query.toString();
496    
497                    Query q = session.createQuery(sql);
498    
499                    q.setFirstResult(0);
500                    q.setMaxResults(2);
501    
502                    QueryPos qPos = QueryPos.getInstance(q);
503    
504                    if (uuid != null) {
505                            qPos.add(uuid);
506                    }
507    
508                    if (orderByComparator != null) {
509                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
510    
511                            for (Object value : values) {
512                                    qPos.add(value);
513                            }
514                    }
515    
516                    List<BlogsEntry> list = q.list();
517    
518                    if (list.size() == 2) {
519                            return list.get(1);
520                    }
521                    else {
522                            return null;
523                    }
524            }
525    
526            /**
527             * Removes all the blogs entries where uuid = &#63; from the database.
528             *
529             * @param uuid the uuid
530             * @throws SystemException if a system exception occurred
531             */
532            public void removeByUuid(String uuid) throws SystemException {
533                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
534                                    QueryUtil.ALL_POS, null)) {
535                            remove(blogsEntry);
536                    }
537            }
538    
539            /**
540             * Returns the number of blogs entries where uuid = &#63;.
541             *
542             * @param uuid the uuid
543             * @return the number of matching blogs entries
544             * @throws SystemException if a system exception occurred
545             */
546            public int countByUuid(String uuid) throws SystemException {
547                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
548    
549                    Object[] finderArgs = new Object[] { uuid };
550    
551                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
552                                    this);
553    
554                    if (count == null) {
555                            StringBundler query = new StringBundler(2);
556    
557                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
558    
559                            if (uuid == null) {
560                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
561                            }
562                            else {
563                                    if (uuid.equals(StringPool.BLANK)) {
564                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
565                                    }
566                                    else {
567                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
568                                    }
569                            }
570    
571                            String sql = query.toString();
572    
573                            Session session = null;
574    
575                            try {
576                                    session = openSession();
577    
578                                    Query q = session.createQuery(sql);
579    
580                                    QueryPos qPos = QueryPos.getInstance(q);
581    
582                                    if (uuid != null) {
583                                            qPos.add(uuid);
584                                    }
585    
586                                    count = (Long)q.uniqueResult();
587    
588                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
589                            }
590                            catch (Exception e) {
591                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
592    
593                                    throw processException(e);
594                            }
595                            finally {
596                                    closeSession(session);
597                            }
598                    }
599    
600                    return count.intValue();
601            }
602    
603            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
604            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
605            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?)";
606            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
607                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
608                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
609                            new String[] { String.class.getName(), Long.class.getName() },
610                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
611                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
612            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
613                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
614                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
615                            new String[] { String.class.getName(), Long.class.getName() });
616    
617            /**
618             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
619             *
620             * @param uuid the uuid
621             * @param groupId the group ID
622             * @return the matching blogs entry
623             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
624             * @throws SystemException if a system exception occurred
625             */
626            public BlogsEntry findByUUID_G(String uuid, long groupId)
627                    throws NoSuchEntryException, SystemException {
628                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
629    
630                    if (blogsEntry == null) {
631                            StringBundler msg = new StringBundler(6);
632    
633                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
634    
635                            msg.append("uuid=");
636                            msg.append(uuid);
637    
638                            msg.append(", groupId=");
639                            msg.append(groupId);
640    
641                            msg.append(StringPool.CLOSE_CURLY_BRACE);
642    
643                            if (_log.isWarnEnabled()) {
644                                    _log.warn(msg.toString());
645                            }
646    
647                            throw new NoSuchEntryException(msg.toString());
648                    }
649    
650                    return blogsEntry;
651            }
652    
653            /**
654             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
655             *
656             * @param uuid the uuid
657             * @param groupId the group ID
658             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
659             * @throws SystemException if a system exception occurred
660             */
661            public BlogsEntry fetchByUUID_G(String uuid, long groupId)
662                    throws SystemException {
663                    return fetchByUUID_G(uuid, groupId, true);
664            }
665    
666            /**
667             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
668             *
669             * @param uuid the uuid
670             * @param groupId the group ID
671             * @param retrieveFromCache whether to use the finder cache
672             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
673             * @throws SystemException if a system exception occurred
674             */
675            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
676                    boolean retrieveFromCache) throws SystemException {
677                    Object[] finderArgs = new Object[] { uuid, groupId };
678    
679                    Object result = null;
680    
681                    if (retrieveFromCache) {
682                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
683                                            finderArgs, this);
684                    }
685    
686                    if (result instanceof BlogsEntry) {
687                            BlogsEntry blogsEntry = (BlogsEntry)result;
688    
689                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
690                                            (groupId != blogsEntry.getGroupId())) {
691                                    result = null;
692                            }
693                    }
694    
695                    if (result == null) {
696                            StringBundler query = new StringBundler(4);
697    
698                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
699    
700                            if (uuid == null) {
701                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
702                            }
703                            else {
704                                    if (uuid.equals(StringPool.BLANK)) {
705                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
706                                    }
707                                    else {
708                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
709                                    }
710                            }
711    
712                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
713    
714                            String sql = query.toString();
715    
716                            Session session = null;
717    
718                            try {
719                                    session = openSession();
720    
721                                    Query q = session.createQuery(sql);
722    
723                                    QueryPos qPos = QueryPos.getInstance(q);
724    
725                                    if (uuid != null) {
726                                            qPos.add(uuid);
727                                    }
728    
729                                    qPos.add(groupId);
730    
731                                    List<BlogsEntry> list = q.list();
732    
733                                    if (list.isEmpty()) {
734                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
735                                                    finderArgs, list);
736                                    }
737                                    else {
738                                            BlogsEntry blogsEntry = list.get(0);
739    
740                                            result = blogsEntry;
741    
742                                            cacheResult(blogsEntry);
743    
744                                            if ((blogsEntry.getUuid() == null) ||
745                                                            !blogsEntry.getUuid().equals(uuid) ||
746                                                            (blogsEntry.getGroupId() != groupId)) {
747                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
748                                                            finderArgs, blogsEntry);
749                                            }
750                                    }
751                            }
752                            catch (Exception e) {
753                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
754                                            finderArgs);
755    
756                                    throw processException(e);
757                            }
758                            finally {
759                                    closeSession(session);
760                            }
761                    }
762    
763                    if (result instanceof List<?>) {
764                            return null;
765                    }
766                    else {
767                            return (BlogsEntry)result;
768                    }
769            }
770    
771            /**
772             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
773             *
774             * @param uuid the uuid
775             * @param groupId the group ID
776             * @return the blogs entry that was removed
777             * @throws SystemException if a system exception occurred
778             */
779            public BlogsEntry removeByUUID_G(String uuid, long groupId)
780                    throws NoSuchEntryException, SystemException {
781                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
782    
783                    return remove(blogsEntry);
784            }
785    
786            /**
787             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
788             *
789             * @param uuid the uuid
790             * @param groupId the group ID
791             * @return the number of matching blogs entries
792             * @throws SystemException if a system exception occurred
793             */
794            public int countByUUID_G(String uuid, long groupId)
795                    throws SystemException {
796                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
797    
798                    Object[] finderArgs = new Object[] { uuid, groupId };
799    
800                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
801                                    this);
802    
803                    if (count == null) {
804                            StringBundler query = new StringBundler(3);
805    
806                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
807    
808                            if (uuid == null) {
809                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
810                            }
811                            else {
812                                    if (uuid.equals(StringPool.BLANK)) {
813                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
814                                    }
815                                    else {
816                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
817                                    }
818                            }
819    
820                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
821    
822                            String sql = query.toString();
823    
824                            Session session = null;
825    
826                            try {
827                                    session = openSession();
828    
829                                    Query q = session.createQuery(sql);
830    
831                                    QueryPos qPos = QueryPos.getInstance(q);
832    
833                                    if (uuid != null) {
834                                            qPos.add(uuid);
835                                    }
836    
837                                    qPos.add(groupId);
838    
839                                    count = (Long)q.uniqueResult();
840    
841                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
842                            }
843                            catch (Exception e) {
844                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
845    
846                                    throw processException(e);
847                            }
848                            finally {
849                                    closeSession(session);
850                            }
851                    }
852    
853                    return count.intValue();
854            }
855    
856            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
857            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
858            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?) AND ";
859            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
860            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
861                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
862                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
863                            new String[] {
864                                    String.class.getName(), Long.class.getName(),
865                                    
866                            Integer.class.getName(), Integer.class.getName(),
867                                    OrderByComparator.class.getName()
868                            });
869            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
870                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
871                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
872                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
873                            new String[] { String.class.getName(), Long.class.getName() },
874                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
875                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
876                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
877                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
878            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
879                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
880                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
881                            new String[] { String.class.getName(), Long.class.getName() });
882    
883            /**
884             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
885             *
886             * @param uuid the uuid
887             * @param companyId the company ID
888             * @return the matching blogs entries
889             * @throws SystemException if a system exception occurred
890             */
891            public List<BlogsEntry> findByUuid_C(String uuid, long companyId)
892                    throws SystemException {
893                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
894                            QueryUtil.ALL_POS, null);
895            }
896    
897            /**
898             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
899             *
900             * <p>
901             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
902             * </p>
903             *
904             * @param uuid the uuid
905             * @param companyId the company ID
906             * @param start the lower bound of the range of blogs entries
907             * @param end the upper bound of the range of blogs entries (not inclusive)
908             * @return the range of matching blogs entries
909             * @throws SystemException if a system exception occurred
910             */
911            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
912                    int start, int end) throws SystemException {
913                    return findByUuid_C(uuid, companyId, start, end, null);
914            }
915    
916            /**
917             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
918             *
919             * <p>
920             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
921             * </p>
922             *
923             * @param uuid the uuid
924             * @param companyId the company ID
925             * @param start the lower bound of the range of blogs entries
926             * @param end the upper bound of the range of blogs entries (not inclusive)
927             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
928             * @return the ordered range of matching blogs entries
929             * @throws SystemException if a system exception occurred
930             */
931            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
932                    int start, int end, OrderByComparator orderByComparator)
933                    throws SystemException {
934                    boolean pagination = true;
935                    FinderPath finderPath = null;
936                    Object[] finderArgs = null;
937    
938                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
939                                    (orderByComparator == null)) {
940                            pagination = false;
941                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
942                            finderArgs = new Object[] { uuid, companyId };
943                    }
944                    else {
945                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
946                            finderArgs = new Object[] {
947                                            uuid, companyId,
948                                            
949                                            start, end, orderByComparator
950                                    };
951                    }
952    
953                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
954                                    finderArgs, this);
955    
956                    if ((list != null) && !list.isEmpty()) {
957                            for (BlogsEntry blogsEntry : list) {
958                                    if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
959                                                    (companyId != blogsEntry.getCompanyId())) {
960                                            list = null;
961    
962                                            break;
963                                    }
964                            }
965                    }
966    
967                    if (list == null) {
968                            StringBundler query = null;
969    
970                            if (orderByComparator != null) {
971                                    query = new StringBundler(4 +
972                                                    (orderByComparator.getOrderByFields().length * 3));
973                            }
974                            else {
975                                    query = new StringBundler(4);
976                            }
977    
978                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
979    
980                            if (uuid == null) {
981                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
982                            }
983                            else {
984                                    if (uuid.equals(StringPool.BLANK)) {
985                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
986                                    }
987                                    else {
988                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
989                                    }
990                            }
991    
992                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
993    
994                            if (orderByComparator != null) {
995                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
996                                            orderByComparator);
997                            }
998                            else
999                             if (pagination) {
1000                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1001                            }
1002    
1003                            String sql = query.toString();
1004    
1005                            Session session = null;
1006    
1007                            try {
1008                                    session = openSession();
1009    
1010                                    Query q = session.createQuery(sql);
1011    
1012                                    QueryPos qPos = QueryPos.getInstance(q);
1013    
1014                                    if (uuid != null) {
1015                                            qPos.add(uuid);
1016                                    }
1017    
1018                                    qPos.add(companyId);
1019    
1020                                    if (!pagination) {
1021                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1022                                                            start, end, false);
1023    
1024                                            Collections.sort(list);
1025    
1026                                            list = new UnmodifiableList<BlogsEntry>(list);
1027                                    }
1028                                    else {
1029                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1030                                                            start, end);
1031                                    }
1032    
1033                                    cacheResult(list);
1034    
1035                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1036                            }
1037                            catch (Exception e) {
1038                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1039    
1040                                    throw processException(e);
1041                            }
1042                            finally {
1043                                    closeSession(session);
1044                            }
1045                    }
1046    
1047                    return list;
1048            }
1049    
1050            /**
1051             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1052             *
1053             * @param uuid the uuid
1054             * @param companyId the company ID
1055             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1056             * @return the first matching blogs entry
1057             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1058             * @throws SystemException if a system exception occurred
1059             */
1060            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1061                    OrderByComparator orderByComparator)
1062                    throws NoSuchEntryException, SystemException {
1063                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1064                                    orderByComparator);
1065    
1066                    if (blogsEntry != null) {
1067                            return blogsEntry;
1068                    }
1069    
1070                    StringBundler msg = new StringBundler(6);
1071    
1072                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1073    
1074                    msg.append("uuid=");
1075                    msg.append(uuid);
1076    
1077                    msg.append(", companyId=");
1078                    msg.append(companyId);
1079    
1080                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1081    
1082                    throw new NoSuchEntryException(msg.toString());
1083            }
1084    
1085            /**
1086             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1087             *
1088             * @param uuid the uuid
1089             * @param companyId the company ID
1090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1091             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1092             * @throws SystemException if a system exception occurred
1093             */
1094            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1095                    OrderByComparator orderByComparator) throws SystemException {
1096                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1097                                    orderByComparator);
1098    
1099                    if (!list.isEmpty()) {
1100                            return list.get(0);
1101                    }
1102    
1103                    return null;
1104            }
1105    
1106            /**
1107             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1108             *
1109             * @param uuid the uuid
1110             * @param companyId the company ID
1111             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1112             * @return the last matching blogs entry
1113             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1114             * @throws SystemException if a system exception occurred
1115             */
1116            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1117                    OrderByComparator orderByComparator)
1118                    throws NoSuchEntryException, SystemException {
1119                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1120                                    orderByComparator);
1121    
1122                    if (blogsEntry != null) {
1123                            return blogsEntry;
1124                    }
1125    
1126                    StringBundler msg = new StringBundler(6);
1127    
1128                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1129    
1130                    msg.append("uuid=");
1131                    msg.append(uuid);
1132    
1133                    msg.append(", companyId=");
1134                    msg.append(companyId);
1135    
1136                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1137    
1138                    throw new NoSuchEntryException(msg.toString());
1139            }
1140    
1141            /**
1142             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1143             *
1144             * @param uuid the uuid
1145             * @param companyId the company ID
1146             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1147             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1148             * @throws SystemException if a system exception occurred
1149             */
1150            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1151                    OrderByComparator orderByComparator) throws SystemException {
1152                    int count = countByUuid_C(uuid, companyId);
1153    
1154                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1155                                    orderByComparator);
1156    
1157                    if (!list.isEmpty()) {
1158                            return list.get(0);
1159                    }
1160    
1161                    return null;
1162            }
1163    
1164            /**
1165             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1166             *
1167             * @param entryId the primary key of the current blogs entry
1168             * @param uuid the uuid
1169             * @param companyId the company ID
1170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1171             * @return the previous, current, and next blogs entry
1172             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1173             * @throws SystemException if a system exception occurred
1174             */
1175            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1176                    long companyId, OrderByComparator orderByComparator)
1177                    throws NoSuchEntryException, SystemException {
1178                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1179    
1180                    Session session = null;
1181    
1182                    try {
1183                            session = openSession();
1184    
1185                            BlogsEntry[] array = new BlogsEntryImpl[3];
1186    
1187                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1188                                            companyId, orderByComparator, true);
1189    
1190                            array[1] = blogsEntry;
1191    
1192                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1193                                            companyId, orderByComparator, false);
1194    
1195                            return array;
1196                    }
1197                    catch (Exception e) {
1198                            throw processException(e);
1199                    }
1200                    finally {
1201                            closeSession(session);
1202                    }
1203            }
1204    
1205            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1206                    BlogsEntry blogsEntry, String uuid, long companyId,
1207                    OrderByComparator orderByComparator, boolean previous) {
1208                    StringBundler query = null;
1209    
1210                    if (orderByComparator != null) {
1211                            query = new StringBundler(6 +
1212                                            (orderByComparator.getOrderByFields().length * 6));
1213                    }
1214                    else {
1215                            query = new StringBundler(3);
1216                    }
1217    
1218                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1219    
1220                    if (uuid == null) {
1221                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1222                    }
1223                    else {
1224                            if (uuid.equals(StringPool.BLANK)) {
1225                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1226                            }
1227                            else {
1228                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1229                            }
1230                    }
1231    
1232                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1233    
1234                    if (orderByComparator != null) {
1235                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1236    
1237                            if (orderByConditionFields.length > 0) {
1238                                    query.append(WHERE_AND);
1239                            }
1240    
1241                            for (int i = 0; i < orderByConditionFields.length; i++) {
1242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1243                                    query.append(orderByConditionFields[i]);
1244    
1245                                    if ((i + 1) < orderByConditionFields.length) {
1246                                            if (orderByComparator.isAscending() ^ previous) {
1247                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1248                                            }
1249                                            else {
1250                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1251                                            }
1252                                    }
1253                                    else {
1254                                            if (orderByComparator.isAscending() ^ previous) {
1255                                                    query.append(WHERE_GREATER_THAN);
1256                                            }
1257                                            else {
1258                                                    query.append(WHERE_LESSER_THAN);
1259                                            }
1260                                    }
1261                            }
1262    
1263                            query.append(ORDER_BY_CLAUSE);
1264    
1265                            String[] orderByFields = orderByComparator.getOrderByFields();
1266    
1267                            for (int i = 0; i < orderByFields.length; i++) {
1268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1269                                    query.append(orderByFields[i]);
1270    
1271                                    if ((i + 1) < orderByFields.length) {
1272                                            if (orderByComparator.isAscending() ^ previous) {
1273                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1274                                            }
1275                                            else {
1276                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1277                                            }
1278                                    }
1279                                    else {
1280                                            if (orderByComparator.isAscending() ^ previous) {
1281                                                    query.append(ORDER_BY_ASC);
1282                                            }
1283                                            else {
1284                                                    query.append(ORDER_BY_DESC);
1285                                            }
1286                                    }
1287                            }
1288                    }
1289                    else {
1290                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1291                    }
1292    
1293                    String sql = query.toString();
1294    
1295                    Query q = session.createQuery(sql);
1296    
1297                    q.setFirstResult(0);
1298                    q.setMaxResults(2);
1299    
1300                    QueryPos qPos = QueryPos.getInstance(q);
1301    
1302                    if (uuid != null) {
1303                            qPos.add(uuid);
1304                    }
1305    
1306                    qPos.add(companyId);
1307    
1308                    if (orderByComparator != null) {
1309                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1310    
1311                            for (Object value : values) {
1312                                    qPos.add(value);
1313                            }
1314                    }
1315    
1316                    List<BlogsEntry> list = q.list();
1317    
1318                    if (list.size() == 2) {
1319                            return list.get(1);
1320                    }
1321                    else {
1322                            return null;
1323                    }
1324            }
1325    
1326            /**
1327             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1328             *
1329             * @param uuid the uuid
1330             * @param companyId the company ID
1331             * @throws SystemException if a system exception occurred
1332             */
1333            public void removeByUuid_C(String uuid, long companyId)
1334                    throws SystemException {
1335                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1336                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1337                            remove(blogsEntry);
1338                    }
1339            }
1340    
1341            /**
1342             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1343             *
1344             * @param uuid the uuid
1345             * @param companyId the company ID
1346             * @return the number of matching blogs entries
1347             * @throws SystemException if a system exception occurred
1348             */
1349            public int countByUuid_C(String uuid, long companyId)
1350                    throws SystemException {
1351                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1352    
1353                    Object[] finderArgs = new Object[] { uuid, companyId };
1354    
1355                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1356                                    this);
1357    
1358                    if (count == null) {
1359                            StringBundler query = new StringBundler(3);
1360    
1361                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1362    
1363                            if (uuid == null) {
1364                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1365                            }
1366                            else {
1367                                    if (uuid.equals(StringPool.BLANK)) {
1368                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1369                                    }
1370                                    else {
1371                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1372                                    }
1373                            }
1374    
1375                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1376    
1377                            String sql = query.toString();
1378    
1379                            Session session = null;
1380    
1381                            try {
1382                                    session = openSession();
1383    
1384                                    Query q = session.createQuery(sql);
1385    
1386                                    QueryPos qPos = QueryPos.getInstance(q);
1387    
1388                                    if (uuid != null) {
1389                                            qPos.add(uuid);
1390                                    }
1391    
1392                                    qPos.add(companyId);
1393    
1394                                    count = (Long)q.uniqueResult();
1395    
1396                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1397                            }
1398                            catch (Exception e) {
1399                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1400    
1401                                    throw processException(e);
1402                            }
1403                            finally {
1404                                    closeSession(session);
1405                            }
1406                    }
1407    
1408                    return count.intValue();
1409            }
1410    
1411            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1412            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1413            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = ?) AND ";
1414            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1415            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1416                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1417                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1418                            new String[] {
1419                                    Long.class.getName(),
1420                                    
1421                            Integer.class.getName(), Integer.class.getName(),
1422                                    OrderByComparator.class.getName()
1423                            });
1424            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1425                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1426                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1427                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1428                            new String[] { Long.class.getName() },
1429                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1430                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1431                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1432            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1433                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1434                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1435                            new String[] { Long.class.getName() });
1436    
1437            /**
1438             * Returns all the blogs entries where groupId = &#63;.
1439             *
1440             * @param groupId the group ID
1441             * @return the matching blogs entries
1442             * @throws SystemException if a system exception occurred
1443             */
1444            public List<BlogsEntry> findByGroupId(long groupId)
1445                    throws SystemException {
1446                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1447            }
1448    
1449            /**
1450             * Returns a range of all the blogs entries where groupId = &#63;.
1451             *
1452             * <p>
1453             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1454             * </p>
1455             *
1456             * @param groupId the group ID
1457             * @param start the lower bound of the range of blogs entries
1458             * @param end the upper bound of the range of blogs entries (not inclusive)
1459             * @return the range of matching blogs entries
1460             * @throws SystemException if a system exception occurred
1461             */
1462            public List<BlogsEntry> findByGroupId(long groupId, int start, int end)
1463                    throws SystemException {
1464                    return findByGroupId(groupId, start, end, null);
1465            }
1466    
1467            /**
1468             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1469             *
1470             * <p>
1471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1472             * </p>
1473             *
1474             * @param groupId the group ID
1475             * @param start the lower bound of the range of blogs entries
1476             * @param end the upper bound of the range of blogs entries (not inclusive)
1477             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1478             * @return the ordered range of matching blogs entries
1479             * @throws SystemException if a system exception occurred
1480             */
1481            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1482                    OrderByComparator orderByComparator) throws SystemException {
1483                    boolean pagination = true;
1484                    FinderPath finderPath = null;
1485                    Object[] finderArgs = null;
1486    
1487                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1488                                    (orderByComparator == null)) {
1489                            pagination = false;
1490                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1491                            finderArgs = new Object[] { groupId };
1492                    }
1493                    else {
1494                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1495                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1496                    }
1497    
1498                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1499                                    finderArgs, this);
1500    
1501                    if ((list != null) && !list.isEmpty()) {
1502                            for (BlogsEntry blogsEntry : list) {
1503                                    if ((groupId != blogsEntry.getGroupId())) {
1504                                            list = null;
1505    
1506                                            break;
1507                                    }
1508                            }
1509                    }
1510    
1511                    if (list == null) {
1512                            StringBundler query = null;
1513    
1514                            if (orderByComparator != null) {
1515                                    query = new StringBundler(3 +
1516                                                    (orderByComparator.getOrderByFields().length * 3));
1517                            }
1518                            else {
1519                                    query = new StringBundler(3);
1520                            }
1521    
1522                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1523    
1524                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1525    
1526                            if (orderByComparator != null) {
1527                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1528                                            orderByComparator);
1529                            }
1530                            else
1531                             if (pagination) {
1532                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1533                            }
1534    
1535                            String sql = query.toString();
1536    
1537                            Session session = null;
1538    
1539                            try {
1540                                    session = openSession();
1541    
1542                                    Query q = session.createQuery(sql);
1543    
1544                                    QueryPos qPos = QueryPos.getInstance(q);
1545    
1546                                    qPos.add(groupId);
1547    
1548                                    if (!pagination) {
1549                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1550                                                            start, end, false);
1551    
1552                                            Collections.sort(list);
1553    
1554                                            list = new UnmodifiableList<BlogsEntry>(list);
1555                                    }
1556                                    else {
1557                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1558                                                            start, end);
1559                                    }
1560    
1561                                    cacheResult(list);
1562    
1563                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1564                            }
1565                            catch (Exception e) {
1566                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1567    
1568                                    throw processException(e);
1569                            }
1570                            finally {
1571                                    closeSession(session);
1572                            }
1573                    }
1574    
1575                    return list;
1576            }
1577    
1578            /**
1579             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1580             *
1581             * @param groupId the group ID
1582             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1583             * @return the first matching blogs entry
1584             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1585             * @throws SystemException if a system exception occurred
1586             */
1587            public BlogsEntry findByGroupId_First(long groupId,
1588                    OrderByComparator orderByComparator)
1589                    throws NoSuchEntryException, SystemException {
1590                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1591    
1592                    if (blogsEntry != null) {
1593                            return blogsEntry;
1594                    }
1595    
1596                    StringBundler msg = new StringBundler(4);
1597    
1598                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1599    
1600                    msg.append("groupId=");
1601                    msg.append(groupId);
1602    
1603                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1604    
1605                    throw new NoSuchEntryException(msg.toString());
1606            }
1607    
1608            /**
1609             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1610             *
1611             * @param groupId the group ID
1612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1613             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1614             * @throws SystemException if a system exception occurred
1615             */
1616            public BlogsEntry fetchByGroupId_First(long groupId,
1617                    OrderByComparator orderByComparator) throws SystemException {
1618                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1619    
1620                    if (!list.isEmpty()) {
1621                            return list.get(0);
1622                    }
1623    
1624                    return null;
1625            }
1626    
1627            /**
1628             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1629             *
1630             * @param groupId the group ID
1631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1632             * @return the last matching blogs entry
1633             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1634             * @throws SystemException if a system exception occurred
1635             */
1636            public BlogsEntry findByGroupId_Last(long groupId,
1637                    OrderByComparator orderByComparator)
1638                    throws NoSuchEntryException, SystemException {
1639                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1640    
1641                    if (blogsEntry != null) {
1642                            return blogsEntry;
1643                    }
1644    
1645                    StringBundler msg = new StringBundler(4);
1646    
1647                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1648    
1649                    msg.append("groupId=");
1650                    msg.append(groupId);
1651    
1652                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1653    
1654                    throw new NoSuchEntryException(msg.toString());
1655            }
1656    
1657            /**
1658             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1659             *
1660             * @param groupId the group ID
1661             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1662             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1663             * @throws SystemException if a system exception occurred
1664             */
1665            public BlogsEntry fetchByGroupId_Last(long groupId,
1666                    OrderByComparator orderByComparator) throws SystemException {
1667                    int count = countByGroupId(groupId);
1668    
1669                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1670                                    orderByComparator);
1671    
1672                    if (!list.isEmpty()) {
1673                            return list.get(0);
1674                    }
1675    
1676                    return null;
1677            }
1678    
1679            /**
1680             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1681             *
1682             * @param entryId the primary key of the current blogs entry
1683             * @param groupId the group ID
1684             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1685             * @return the previous, current, and next blogs entry
1686             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1687             * @throws SystemException if a system exception occurred
1688             */
1689            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1690                    OrderByComparator orderByComparator)
1691                    throws NoSuchEntryException, SystemException {
1692                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1693    
1694                    Session session = null;
1695    
1696                    try {
1697                            session = openSession();
1698    
1699                            BlogsEntry[] array = new BlogsEntryImpl[3];
1700    
1701                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1702                                            orderByComparator, true);
1703    
1704                            array[1] = blogsEntry;
1705    
1706                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1707                                            orderByComparator, false);
1708    
1709                            return array;
1710                    }
1711                    catch (Exception e) {
1712                            throw processException(e);
1713                    }
1714                    finally {
1715                            closeSession(session);
1716                    }
1717            }
1718    
1719            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1720                    BlogsEntry blogsEntry, long groupId,
1721                    OrderByComparator orderByComparator, boolean previous) {
1722                    StringBundler query = null;
1723    
1724                    if (orderByComparator != null) {
1725                            query = new StringBundler(6 +
1726                                            (orderByComparator.getOrderByFields().length * 6));
1727                    }
1728                    else {
1729                            query = new StringBundler(3);
1730                    }
1731    
1732                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1733    
1734                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1735    
1736                    if (orderByComparator != null) {
1737                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1738    
1739                            if (orderByConditionFields.length > 0) {
1740                                    query.append(WHERE_AND);
1741                            }
1742    
1743                            for (int i = 0; i < orderByConditionFields.length; i++) {
1744                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1745                                    query.append(orderByConditionFields[i]);
1746    
1747                                    if ((i + 1) < orderByConditionFields.length) {
1748                                            if (orderByComparator.isAscending() ^ previous) {
1749                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1750                                            }
1751                                            else {
1752                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1753                                            }
1754                                    }
1755                                    else {
1756                                            if (orderByComparator.isAscending() ^ previous) {
1757                                                    query.append(WHERE_GREATER_THAN);
1758                                            }
1759                                            else {
1760                                                    query.append(WHERE_LESSER_THAN);
1761                                            }
1762                                    }
1763                            }
1764    
1765                            query.append(ORDER_BY_CLAUSE);
1766    
1767                            String[] orderByFields = orderByComparator.getOrderByFields();
1768    
1769                            for (int i = 0; i < orderByFields.length; i++) {
1770                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1771                                    query.append(orderByFields[i]);
1772    
1773                                    if ((i + 1) < orderByFields.length) {
1774                                            if (orderByComparator.isAscending() ^ previous) {
1775                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1776                                            }
1777                                            else {
1778                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1779                                            }
1780                                    }
1781                                    else {
1782                                            if (orderByComparator.isAscending() ^ previous) {
1783                                                    query.append(ORDER_BY_ASC);
1784                                            }
1785                                            else {
1786                                                    query.append(ORDER_BY_DESC);
1787                                            }
1788                                    }
1789                            }
1790                    }
1791                    else {
1792                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1793                    }
1794    
1795                    String sql = query.toString();
1796    
1797                    Query q = session.createQuery(sql);
1798    
1799                    q.setFirstResult(0);
1800                    q.setMaxResults(2);
1801    
1802                    QueryPos qPos = QueryPos.getInstance(q);
1803    
1804                    qPos.add(groupId);
1805    
1806                    if (orderByComparator != null) {
1807                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1808    
1809                            for (Object value : values) {
1810                                    qPos.add(value);
1811                            }
1812                    }
1813    
1814                    List<BlogsEntry> list = q.list();
1815    
1816                    if (list.size() == 2) {
1817                            return list.get(1);
1818                    }
1819                    else {
1820                            return null;
1821                    }
1822            }
1823    
1824            /**
1825             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1826             *
1827             * @param groupId the group ID
1828             * @return the matching blogs entries that the user has permission to view
1829             * @throws SystemException if a system exception occurred
1830             */
1831            public List<BlogsEntry> filterFindByGroupId(long groupId)
1832                    throws SystemException {
1833                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1834                            QueryUtil.ALL_POS, null);
1835            }
1836    
1837            /**
1838             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1839             *
1840             * <p>
1841             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1842             * </p>
1843             *
1844             * @param groupId the group ID
1845             * @param start the lower bound of the range of blogs entries
1846             * @param end the upper bound of the range of blogs entries (not inclusive)
1847             * @return the range of matching blogs entries that the user has permission to view
1848             * @throws SystemException if a system exception occurred
1849             */
1850            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end)
1851                    throws SystemException {
1852                    return filterFindByGroupId(groupId, start, end, null);
1853            }
1854    
1855            /**
1856             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1857             *
1858             * <p>
1859             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1860             * </p>
1861             *
1862             * @param groupId the group ID
1863             * @param start the lower bound of the range of blogs entries
1864             * @param end the upper bound of the range of blogs entries (not inclusive)
1865             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1866             * @return the ordered range of matching blogs entries that the user has permission to view
1867             * @throws SystemException if a system exception occurred
1868             */
1869            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1870                    int end, OrderByComparator orderByComparator) throws SystemException {
1871                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1872                            return findByGroupId(groupId, start, end, orderByComparator);
1873                    }
1874    
1875                    StringBundler query = null;
1876    
1877                    if (orderByComparator != null) {
1878                            query = new StringBundler(3 +
1879                                            (orderByComparator.getOrderByFields().length * 3));
1880                    }
1881                    else {
1882                            query = new StringBundler(3);
1883                    }
1884    
1885                    if (getDB().isSupportsInlineDistinct()) {
1886                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1887                    }
1888                    else {
1889                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1890                    }
1891    
1892                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1893    
1894                    if (!getDB().isSupportsInlineDistinct()) {
1895                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1896                    }
1897    
1898                    if (orderByComparator != null) {
1899                            if (getDB().isSupportsInlineDistinct()) {
1900                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1901                                            orderByComparator);
1902                            }
1903                            else {
1904                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1905                                            orderByComparator);
1906                            }
1907                    }
1908                    else {
1909                            if (getDB().isSupportsInlineDistinct()) {
1910                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1911                            }
1912                            else {
1913                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
1914                            }
1915                    }
1916    
1917                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1918                                    BlogsEntry.class.getName(),
1919                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1920    
1921                    Session session = null;
1922    
1923                    try {
1924                            session = openSession();
1925    
1926                            SQLQuery q = session.createSQLQuery(sql);
1927    
1928                            if (getDB().isSupportsInlineDistinct()) {
1929                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
1930                            }
1931                            else {
1932                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
1933                            }
1934    
1935                            QueryPos qPos = QueryPos.getInstance(q);
1936    
1937                            qPos.add(groupId);
1938    
1939                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
1940                    }
1941                    catch (Exception e) {
1942                            throw processException(e);
1943                    }
1944                    finally {
1945                            closeSession(session);
1946                    }
1947            }
1948    
1949            /**
1950             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63;.
1951             *
1952             * @param entryId the primary key of the current blogs entry
1953             * @param groupId the group ID
1954             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1955             * @return the previous, current, and next blogs entry
1956             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1957             * @throws SystemException if a system exception occurred
1958             */
1959            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
1960                    long groupId, OrderByComparator orderByComparator)
1961                    throws NoSuchEntryException, SystemException {
1962                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1963                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
1964                    }
1965    
1966                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1967    
1968                    Session session = null;
1969    
1970                    try {
1971                            session = openSession();
1972    
1973                            BlogsEntry[] array = new BlogsEntryImpl[3];
1974    
1975                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
1976                                            groupId, orderByComparator, true);
1977    
1978                            array[1] = blogsEntry;
1979    
1980                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
1981                                            groupId, orderByComparator, false);
1982    
1983                            return array;
1984                    }
1985                    catch (Exception e) {
1986                            throw processException(e);
1987                    }
1988                    finally {
1989                            closeSession(session);
1990                    }
1991            }
1992    
1993            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
1994                    BlogsEntry blogsEntry, long groupId,
1995                    OrderByComparator orderByComparator, boolean previous) {
1996                    StringBundler query = null;
1997    
1998                    if (orderByComparator != null) {
1999                            query = new StringBundler(6 +
2000                                            (orderByComparator.getOrderByFields().length * 6));
2001                    }
2002                    else {
2003                            query = new StringBundler(3);
2004                    }
2005    
2006                    if (getDB().isSupportsInlineDistinct()) {
2007                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2008                    }
2009                    else {
2010                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2011                    }
2012    
2013                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2014    
2015                    if (!getDB().isSupportsInlineDistinct()) {
2016                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2017                    }
2018    
2019                    if (orderByComparator != null) {
2020                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2021    
2022                            if (orderByConditionFields.length > 0) {
2023                                    query.append(WHERE_AND);
2024                            }
2025    
2026                            for (int i = 0; i < orderByConditionFields.length; i++) {
2027                                    if (getDB().isSupportsInlineDistinct()) {
2028                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2029                                    }
2030                                    else {
2031                                            query.append(_ORDER_BY_ENTITY_TABLE);
2032                                    }
2033    
2034                                    query.append(orderByConditionFields[i]);
2035    
2036                                    if ((i + 1) < orderByConditionFields.length) {
2037                                            if (orderByComparator.isAscending() ^ previous) {
2038                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2039                                            }
2040                                            else {
2041                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2042                                            }
2043                                    }
2044                                    else {
2045                                            if (orderByComparator.isAscending() ^ previous) {
2046                                                    query.append(WHERE_GREATER_THAN);
2047                                            }
2048                                            else {
2049                                                    query.append(WHERE_LESSER_THAN);
2050                                            }
2051                                    }
2052                            }
2053    
2054                            query.append(ORDER_BY_CLAUSE);
2055    
2056                            String[] orderByFields = orderByComparator.getOrderByFields();
2057    
2058                            for (int i = 0; i < orderByFields.length; i++) {
2059                                    if (getDB().isSupportsInlineDistinct()) {
2060                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2061                                    }
2062                                    else {
2063                                            query.append(_ORDER_BY_ENTITY_TABLE);
2064                                    }
2065    
2066                                    query.append(orderByFields[i]);
2067    
2068                                    if ((i + 1) < orderByFields.length) {
2069                                            if (orderByComparator.isAscending() ^ previous) {
2070                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2071                                            }
2072                                            else {
2073                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2074                                            }
2075                                    }
2076                                    else {
2077                                            if (orderByComparator.isAscending() ^ previous) {
2078                                                    query.append(ORDER_BY_ASC);
2079                                            }
2080                                            else {
2081                                                    query.append(ORDER_BY_DESC);
2082                                            }
2083                                    }
2084                            }
2085                    }
2086                    else {
2087                            if (getDB().isSupportsInlineDistinct()) {
2088                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2089                            }
2090                            else {
2091                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2092                            }
2093                    }
2094    
2095                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2096                                    BlogsEntry.class.getName(),
2097                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2098    
2099                    SQLQuery q = session.createSQLQuery(sql);
2100    
2101                    q.setFirstResult(0);
2102                    q.setMaxResults(2);
2103    
2104                    if (getDB().isSupportsInlineDistinct()) {
2105                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2106                    }
2107                    else {
2108                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2109                    }
2110    
2111                    QueryPos qPos = QueryPos.getInstance(q);
2112    
2113                    qPos.add(groupId);
2114    
2115                    if (orderByComparator != null) {
2116                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2117    
2118                            for (Object value : values) {
2119                                    qPos.add(value);
2120                            }
2121                    }
2122    
2123                    List<BlogsEntry> list = q.list();
2124    
2125                    if (list.size() == 2) {
2126                            return list.get(1);
2127                    }
2128                    else {
2129                            return null;
2130                    }
2131            }
2132    
2133            /**
2134             * Removes all the blogs entries where groupId = &#63; from the database.
2135             *
2136             * @param groupId the group ID
2137             * @throws SystemException if a system exception occurred
2138             */
2139            public void removeByGroupId(long groupId) throws SystemException {
2140                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2141                                    QueryUtil.ALL_POS, null)) {
2142                            remove(blogsEntry);
2143                    }
2144            }
2145    
2146            /**
2147             * Returns the number of blogs entries where groupId = &#63;.
2148             *
2149             * @param groupId the group ID
2150             * @return the number of matching blogs entries
2151             * @throws SystemException if a system exception occurred
2152             */
2153            public int countByGroupId(long groupId) throws SystemException {
2154                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2155    
2156                    Object[] finderArgs = new Object[] { groupId };
2157    
2158                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2159                                    this);
2160    
2161                    if (count == null) {
2162                            StringBundler query = new StringBundler(2);
2163    
2164                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2165    
2166                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2167    
2168                            String sql = query.toString();
2169    
2170                            Session session = null;
2171    
2172                            try {
2173                                    session = openSession();
2174    
2175                                    Query q = session.createQuery(sql);
2176    
2177                                    QueryPos qPos = QueryPos.getInstance(q);
2178    
2179                                    qPos.add(groupId);
2180    
2181                                    count = (Long)q.uniqueResult();
2182    
2183                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2184                            }
2185                            catch (Exception e) {
2186                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2187    
2188                                    throw processException(e);
2189                            }
2190                            finally {
2191                                    closeSession(session);
2192                            }
2193                    }
2194    
2195                    return count.intValue();
2196            }
2197    
2198            /**
2199             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2200             *
2201             * @param groupId the group ID
2202             * @return the number of matching blogs entries that the user has permission to view
2203             * @throws SystemException if a system exception occurred
2204             */
2205            public int filterCountByGroupId(long groupId) throws SystemException {
2206                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2207                            return countByGroupId(groupId);
2208                    }
2209    
2210                    StringBundler query = new StringBundler(2);
2211    
2212                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2213    
2214                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2215    
2216                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2217                                    BlogsEntry.class.getName(),
2218                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2219    
2220                    Session session = null;
2221    
2222                    try {
2223                            session = openSession();
2224    
2225                            SQLQuery q = session.createSQLQuery(sql);
2226    
2227                            q.addScalar(COUNT_COLUMN_NAME,
2228                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2229    
2230                            QueryPos qPos = QueryPos.getInstance(q);
2231    
2232                            qPos.add(groupId);
2233    
2234                            Long count = (Long)q.uniqueResult();
2235    
2236                            return count.intValue();
2237                    }
2238                    catch (Exception e) {
2239                            throw processException(e);
2240                    }
2241                    finally {
2242                            closeSession(session);
2243                    }
2244            }
2245    
2246            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2247            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2248                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2249                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2250                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2251                            new String[] {
2252                                    Long.class.getName(),
2253                                    
2254                            Integer.class.getName(), Integer.class.getName(),
2255                                    OrderByComparator.class.getName()
2256                            });
2257            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2258                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2259                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2260                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2261                            new String[] { Long.class.getName() },
2262                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2263                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2264                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2265            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2266                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2267                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2268                            new String[] { Long.class.getName() });
2269    
2270            /**
2271             * Returns all the blogs entries where companyId = &#63;.
2272             *
2273             * @param companyId the company ID
2274             * @return the matching blogs entries
2275             * @throws SystemException if a system exception occurred
2276             */
2277            public List<BlogsEntry> findByCompanyId(long companyId)
2278                    throws SystemException {
2279                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2280                            null);
2281            }
2282    
2283            /**
2284             * Returns a range of all the blogs entries where companyId = &#63;.
2285             *
2286             * <p>
2287             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2288             * </p>
2289             *
2290             * @param companyId the company ID
2291             * @param start the lower bound of the range of blogs entries
2292             * @param end the upper bound of the range of blogs entries (not inclusive)
2293             * @return the range of matching blogs entries
2294             * @throws SystemException if a system exception occurred
2295             */
2296            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end)
2297                    throws SystemException {
2298                    return findByCompanyId(companyId, start, end, null);
2299            }
2300    
2301            /**
2302             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2303             *
2304             * <p>
2305             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2306             * </p>
2307             *
2308             * @param companyId the company ID
2309             * @param start the lower bound of the range of blogs entries
2310             * @param end the upper bound of the range of blogs entries (not inclusive)
2311             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2312             * @return the ordered range of matching blogs entries
2313             * @throws SystemException if a system exception occurred
2314             */
2315            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2316                    OrderByComparator orderByComparator) throws SystemException {
2317                    boolean pagination = true;
2318                    FinderPath finderPath = null;
2319                    Object[] finderArgs = null;
2320    
2321                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2322                                    (orderByComparator == null)) {
2323                            pagination = false;
2324                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2325                            finderArgs = new Object[] { companyId };
2326                    }
2327                    else {
2328                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2329                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2330                    }
2331    
2332                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2333                                    finderArgs, this);
2334    
2335                    if ((list != null) && !list.isEmpty()) {
2336                            for (BlogsEntry blogsEntry : list) {
2337                                    if ((companyId != blogsEntry.getCompanyId())) {
2338                                            list = null;
2339    
2340                                            break;
2341                                    }
2342                            }
2343                    }
2344    
2345                    if (list == null) {
2346                            StringBundler query = null;
2347    
2348                            if (orderByComparator != null) {
2349                                    query = new StringBundler(3 +
2350                                                    (orderByComparator.getOrderByFields().length * 3));
2351                            }
2352                            else {
2353                                    query = new StringBundler(3);
2354                            }
2355    
2356                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2357    
2358                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2359    
2360                            if (orderByComparator != null) {
2361                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2362                                            orderByComparator);
2363                            }
2364                            else
2365                             if (pagination) {
2366                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2367                            }
2368    
2369                            String sql = query.toString();
2370    
2371                            Session session = null;
2372    
2373                            try {
2374                                    session = openSession();
2375    
2376                                    Query q = session.createQuery(sql);
2377    
2378                                    QueryPos qPos = QueryPos.getInstance(q);
2379    
2380                                    qPos.add(companyId);
2381    
2382                                    if (!pagination) {
2383                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2384                                                            start, end, false);
2385    
2386                                            Collections.sort(list);
2387    
2388                                            list = new UnmodifiableList<BlogsEntry>(list);
2389                                    }
2390                                    else {
2391                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2392                                                            start, end);
2393                                    }
2394    
2395                                    cacheResult(list);
2396    
2397                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2398                            }
2399                            catch (Exception e) {
2400                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2401    
2402                                    throw processException(e);
2403                            }
2404                            finally {
2405                                    closeSession(session);
2406                            }
2407                    }
2408    
2409                    return list;
2410            }
2411    
2412            /**
2413             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2414             *
2415             * @param companyId the company ID
2416             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2417             * @return the first matching blogs entry
2418             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2419             * @throws SystemException if a system exception occurred
2420             */
2421            public BlogsEntry findByCompanyId_First(long companyId,
2422                    OrderByComparator orderByComparator)
2423                    throws NoSuchEntryException, SystemException {
2424                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2425                                    orderByComparator);
2426    
2427                    if (blogsEntry != null) {
2428                            return blogsEntry;
2429                    }
2430    
2431                    StringBundler msg = new StringBundler(4);
2432    
2433                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2434    
2435                    msg.append("companyId=");
2436                    msg.append(companyId);
2437    
2438                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2439    
2440                    throw new NoSuchEntryException(msg.toString());
2441            }
2442    
2443            /**
2444             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2445             *
2446             * @param companyId the company ID
2447             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2448             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2449             * @throws SystemException if a system exception occurred
2450             */
2451            public BlogsEntry fetchByCompanyId_First(long companyId,
2452                    OrderByComparator orderByComparator) throws SystemException {
2453                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2454                                    orderByComparator);
2455    
2456                    if (!list.isEmpty()) {
2457                            return list.get(0);
2458                    }
2459    
2460                    return null;
2461            }
2462    
2463            /**
2464             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2465             *
2466             * @param companyId the company ID
2467             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2468             * @return the last matching blogs entry
2469             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2470             * @throws SystemException if a system exception occurred
2471             */
2472            public BlogsEntry findByCompanyId_Last(long companyId,
2473                    OrderByComparator orderByComparator)
2474                    throws NoSuchEntryException, SystemException {
2475                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2476                                    orderByComparator);
2477    
2478                    if (blogsEntry != null) {
2479                            return blogsEntry;
2480                    }
2481    
2482                    StringBundler msg = new StringBundler(4);
2483    
2484                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2485    
2486                    msg.append("companyId=");
2487                    msg.append(companyId);
2488    
2489                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2490    
2491                    throw new NoSuchEntryException(msg.toString());
2492            }
2493    
2494            /**
2495             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2496             *
2497             * @param companyId the company ID
2498             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2499             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2500             * @throws SystemException if a system exception occurred
2501             */
2502            public BlogsEntry fetchByCompanyId_Last(long companyId,
2503                    OrderByComparator orderByComparator) throws SystemException {
2504                    int count = countByCompanyId(companyId);
2505    
2506                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2507                                    orderByComparator);
2508    
2509                    if (!list.isEmpty()) {
2510                            return list.get(0);
2511                    }
2512    
2513                    return null;
2514            }
2515    
2516            /**
2517             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2518             *
2519             * @param entryId the primary key of the current blogs entry
2520             * @param companyId the company ID
2521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2522             * @return the previous, current, and next blogs entry
2523             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2524             * @throws SystemException if a system exception occurred
2525             */
2526            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2527                    long companyId, OrderByComparator orderByComparator)
2528                    throws NoSuchEntryException, SystemException {
2529                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2530    
2531                    Session session = null;
2532    
2533                    try {
2534                            session = openSession();
2535    
2536                            BlogsEntry[] array = new BlogsEntryImpl[3];
2537    
2538                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2539                                            companyId, orderByComparator, true);
2540    
2541                            array[1] = blogsEntry;
2542    
2543                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2544                                            companyId, orderByComparator, false);
2545    
2546                            return array;
2547                    }
2548                    catch (Exception e) {
2549                            throw processException(e);
2550                    }
2551                    finally {
2552                            closeSession(session);
2553                    }
2554            }
2555    
2556            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2557                    BlogsEntry blogsEntry, long companyId,
2558                    OrderByComparator orderByComparator, boolean previous) {
2559                    StringBundler query = null;
2560    
2561                    if (orderByComparator != null) {
2562                            query = new StringBundler(6 +
2563                                            (orderByComparator.getOrderByFields().length * 6));
2564                    }
2565                    else {
2566                            query = new StringBundler(3);
2567                    }
2568    
2569                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2570    
2571                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2572    
2573                    if (orderByComparator != null) {
2574                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2575    
2576                            if (orderByConditionFields.length > 0) {
2577                                    query.append(WHERE_AND);
2578                            }
2579    
2580                            for (int i = 0; i < orderByConditionFields.length; i++) {
2581                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2582                                    query.append(orderByConditionFields[i]);
2583    
2584                                    if ((i + 1) < orderByConditionFields.length) {
2585                                            if (orderByComparator.isAscending() ^ previous) {
2586                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2587                                            }
2588                                            else {
2589                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2590                                            }
2591                                    }
2592                                    else {
2593                                            if (orderByComparator.isAscending() ^ previous) {
2594                                                    query.append(WHERE_GREATER_THAN);
2595                                            }
2596                                            else {
2597                                                    query.append(WHERE_LESSER_THAN);
2598                                            }
2599                                    }
2600                            }
2601    
2602                            query.append(ORDER_BY_CLAUSE);
2603    
2604                            String[] orderByFields = orderByComparator.getOrderByFields();
2605    
2606                            for (int i = 0; i < orderByFields.length; i++) {
2607                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2608                                    query.append(orderByFields[i]);
2609    
2610                                    if ((i + 1) < orderByFields.length) {
2611                                            if (orderByComparator.isAscending() ^ previous) {
2612                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2613                                            }
2614                                            else {
2615                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2616                                            }
2617                                    }
2618                                    else {
2619                                            if (orderByComparator.isAscending() ^ previous) {
2620                                                    query.append(ORDER_BY_ASC);
2621                                            }
2622                                            else {
2623                                                    query.append(ORDER_BY_DESC);
2624                                            }
2625                                    }
2626                            }
2627                    }
2628                    else {
2629                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2630                    }
2631    
2632                    String sql = query.toString();
2633    
2634                    Query q = session.createQuery(sql);
2635    
2636                    q.setFirstResult(0);
2637                    q.setMaxResults(2);
2638    
2639                    QueryPos qPos = QueryPos.getInstance(q);
2640    
2641                    qPos.add(companyId);
2642    
2643                    if (orderByComparator != null) {
2644                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2645    
2646                            for (Object value : values) {
2647                                    qPos.add(value);
2648                            }
2649                    }
2650    
2651                    List<BlogsEntry> list = q.list();
2652    
2653                    if (list.size() == 2) {
2654                            return list.get(1);
2655                    }
2656                    else {
2657                            return null;
2658                    }
2659            }
2660    
2661            /**
2662             * Removes all the blogs entries where companyId = &#63; from the database.
2663             *
2664             * @param companyId the company ID
2665             * @throws SystemException if a system exception occurred
2666             */
2667            public void removeByCompanyId(long companyId) throws SystemException {
2668                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2669                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2670                            remove(blogsEntry);
2671                    }
2672            }
2673    
2674            /**
2675             * Returns the number of blogs entries where companyId = &#63;.
2676             *
2677             * @param companyId the company ID
2678             * @return the number of matching blogs entries
2679             * @throws SystemException if a system exception occurred
2680             */
2681            public int countByCompanyId(long companyId) throws SystemException {
2682                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2683    
2684                    Object[] finderArgs = new Object[] { companyId };
2685    
2686                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2687                                    this);
2688    
2689                    if (count == null) {
2690                            StringBundler query = new StringBundler(2);
2691    
2692                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2693    
2694                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2695    
2696                            String sql = query.toString();
2697    
2698                            Session session = null;
2699    
2700                            try {
2701                                    session = openSession();
2702    
2703                                    Query q = session.createQuery(sql);
2704    
2705                                    QueryPos qPos = QueryPos.getInstance(q);
2706    
2707                                    qPos.add(companyId);
2708    
2709                                    count = (Long)q.uniqueResult();
2710    
2711                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2712                            }
2713                            catch (Exception e) {
2714                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2715    
2716                                    throw processException(e);
2717                            }
2718                            finally {
2719                                    closeSession(session);
2720                            }
2721                    }
2722    
2723                    return count.intValue();
2724            }
2725    
2726            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2727            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2728                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2729                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
2730                            new String[] {
2731                                    Long.class.getName(), Long.class.getName(),
2732                                    
2733                            Integer.class.getName(), Integer.class.getName(),
2734                                    OrderByComparator.class.getName()
2735                            });
2736            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2737                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2738                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
2739                            new String[] { Long.class.getName(), Long.class.getName() },
2740                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2741                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
2742                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2743                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2744            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2745                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2746                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
2747                            new String[] { Long.class.getName(), Long.class.getName() });
2748    
2749            /**
2750             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
2751             *
2752             * @param companyId the company ID
2753             * @param userId the user ID
2754             * @return the matching blogs entries
2755             * @throws SystemException if a system exception occurred
2756             */
2757            public List<BlogsEntry> findByC_U(long companyId, long userId)
2758                    throws SystemException {
2759                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
2760                            QueryUtil.ALL_POS, null);
2761            }
2762    
2763            /**
2764             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
2765             *
2766             * <p>
2767             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2768             * </p>
2769             *
2770             * @param companyId the company ID
2771             * @param userId the user ID
2772             * @param start the lower bound of the range of blogs entries
2773             * @param end the upper bound of the range of blogs entries (not inclusive)
2774             * @return the range of matching blogs entries
2775             * @throws SystemException if a system exception occurred
2776             */
2777            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2778                    int end) throws SystemException {
2779                    return findByC_U(companyId, userId, start, end, null);
2780            }
2781    
2782            /**
2783             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
2784             *
2785             * <p>
2786             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2787             * </p>
2788             *
2789             * @param companyId the company ID
2790             * @param userId the user ID
2791             * @param start the lower bound of the range of blogs entries
2792             * @param end the upper bound of the range of blogs entries (not inclusive)
2793             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2794             * @return the ordered range of matching blogs entries
2795             * @throws SystemException if a system exception occurred
2796             */
2797            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2798                    int end, OrderByComparator orderByComparator) throws SystemException {
2799                    boolean pagination = true;
2800                    FinderPath finderPath = null;
2801                    Object[] finderArgs = null;
2802    
2803                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2804                                    (orderByComparator == null)) {
2805                            pagination = false;
2806                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
2807                            finderArgs = new Object[] { companyId, userId };
2808                    }
2809                    else {
2810                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
2811                            finderArgs = new Object[] {
2812                                            companyId, userId,
2813                                            
2814                                            start, end, orderByComparator
2815                                    };
2816                    }
2817    
2818                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2819                                    finderArgs, this);
2820    
2821                    if ((list != null) && !list.isEmpty()) {
2822                            for (BlogsEntry blogsEntry : list) {
2823                                    if ((companyId != blogsEntry.getCompanyId()) ||
2824                                                    (userId != blogsEntry.getUserId())) {
2825                                            list = null;
2826    
2827                                            break;
2828                                    }
2829                            }
2830                    }
2831    
2832                    if (list == null) {
2833                            StringBundler query = null;
2834    
2835                            if (orderByComparator != null) {
2836                                    query = new StringBundler(4 +
2837                                                    (orderByComparator.getOrderByFields().length * 3));
2838                            }
2839                            else {
2840                                    query = new StringBundler(4);
2841                            }
2842    
2843                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2844    
2845                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2846    
2847                            query.append(_FINDER_COLUMN_C_U_USERID_2);
2848    
2849                            if (orderByComparator != null) {
2850                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2851                                            orderByComparator);
2852                            }
2853                            else
2854                             if (pagination) {
2855                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2856                            }
2857    
2858                            String sql = query.toString();
2859    
2860                            Session session = null;
2861    
2862                            try {
2863                                    session = openSession();
2864    
2865                                    Query q = session.createQuery(sql);
2866    
2867                                    QueryPos qPos = QueryPos.getInstance(q);
2868    
2869                                    qPos.add(companyId);
2870    
2871                                    qPos.add(userId);
2872    
2873                                    if (!pagination) {
2874                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2875                                                            start, end, false);
2876    
2877                                            Collections.sort(list);
2878    
2879                                            list = new UnmodifiableList<BlogsEntry>(list);
2880                                    }
2881                                    else {
2882                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2883                                                            start, end);
2884                                    }
2885    
2886                                    cacheResult(list);
2887    
2888                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2889                            }
2890                            catch (Exception e) {
2891                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2892    
2893                                    throw processException(e);
2894                            }
2895                            finally {
2896                                    closeSession(session);
2897                            }
2898                    }
2899    
2900                    return list;
2901            }
2902    
2903            /**
2904             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2905             *
2906             * @param companyId the company ID
2907             * @param userId the user ID
2908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2909             * @return the first matching blogs entry
2910             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2911             * @throws SystemException if a system exception occurred
2912             */
2913            public BlogsEntry findByC_U_First(long companyId, long userId,
2914                    OrderByComparator orderByComparator)
2915                    throws NoSuchEntryException, SystemException {
2916                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
2917                                    orderByComparator);
2918    
2919                    if (blogsEntry != null) {
2920                            return blogsEntry;
2921                    }
2922    
2923                    StringBundler msg = new StringBundler(6);
2924    
2925                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2926    
2927                    msg.append("companyId=");
2928                    msg.append(companyId);
2929    
2930                    msg.append(", userId=");
2931                    msg.append(userId);
2932    
2933                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2934    
2935                    throw new NoSuchEntryException(msg.toString());
2936            }
2937    
2938            /**
2939             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2940             *
2941             * @param companyId the company ID
2942             * @param userId the user ID
2943             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2944             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2945             * @throws SystemException if a system exception occurred
2946             */
2947            public BlogsEntry fetchByC_U_First(long companyId, long userId,
2948                    OrderByComparator orderByComparator) throws SystemException {
2949                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
2950                                    orderByComparator);
2951    
2952                    if (!list.isEmpty()) {
2953                            return list.get(0);
2954                    }
2955    
2956                    return null;
2957            }
2958    
2959            /**
2960             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2961             *
2962             * @param companyId the company ID
2963             * @param userId the user ID
2964             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2965             * @return the last matching blogs entry
2966             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2967             * @throws SystemException if a system exception occurred
2968             */
2969            public BlogsEntry findByC_U_Last(long companyId, long userId,
2970                    OrderByComparator orderByComparator)
2971                    throws NoSuchEntryException, SystemException {
2972                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
2973                                    orderByComparator);
2974    
2975                    if (blogsEntry != null) {
2976                            return blogsEntry;
2977                    }
2978    
2979                    StringBundler msg = new StringBundler(6);
2980    
2981                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2982    
2983                    msg.append("companyId=");
2984                    msg.append(companyId);
2985    
2986                    msg.append(", userId=");
2987                    msg.append(userId);
2988    
2989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2990    
2991                    throw new NoSuchEntryException(msg.toString());
2992            }
2993    
2994            /**
2995             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2996             *
2997             * @param companyId the company ID
2998             * @param userId the user ID
2999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3000             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3001             * @throws SystemException if a system exception occurred
3002             */
3003            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
3004                    OrderByComparator orderByComparator) throws SystemException {
3005                    int count = countByC_U(companyId, userId);
3006    
3007                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
3008                                    orderByComparator);
3009    
3010                    if (!list.isEmpty()) {
3011                            return list.get(0);
3012                    }
3013    
3014                    return null;
3015            }
3016    
3017            /**
3018             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3019             *
3020             * @param entryId the primary key of the current blogs entry
3021             * @param companyId the company ID
3022             * @param userId the user ID
3023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3024             * @return the previous, current, and next blogs entry
3025             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3026             * @throws SystemException if a system exception occurred
3027             */
3028            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
3029                    long userId, OrderByComparator orderByComparator)
3030                    throws NoSuchEntryException, SystemException {
3031                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3032    
3033                    Session session = null;
3034    
3035                    try {
3036                            session = openSession();
3037    
3038                            BlogsEntry[] array = new BlogsEntryImpl[3];
3039    
3040                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3041                                            userId, orderByComparator, true);
3042    
3043                            array[1] = blogsEntry;
3044    
3045                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3046                                            userId, orderByComparator, false);
3047    
3048                            return array;
3049                    }
3050                    catch (Exception e) {
3051                            throw processException(e);
3052                    }
3053                    finally {
3054                            closeSession(session);
3055                    }
3056            }
3057    
3058            protected BlogsEntry getByC_U_PrevAndNext(Session session,
3059                    BlogsEntry blogsEntry, long companyId, long userId,
3060                    OrderByComparator orderByComparator, boolean previous) {
3061                    StringBundler query = null;
3062    
3063                    if (orderByComparator != null) {
3064                            query = new StringBundler(6 +
3065                                            (orderByComparator.getOrderByFields().length * 6));
3066                    }
3067                    else {
3068                            query = new StringBundler(3);
3069                    }
3070    
3071                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3072    
3073                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3074    
3075                    query.append(_FINDER_COLUMN_C_U_USERID_2);
3076    
3077                    if (orderByComparator != null) {
3078                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3079    
3080                            if (orderByConditionFields.length > 0) {
3081                                    query.append(WHERE_AND);
3082                            }
3083    
3084                            for (int i = 0; i < orderByConditionFields.length; i++) {
3085                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3086                                    query.append(orderByConditionFields[i]);
3087    
3088                                    if ((i + 1) < orderByConditionFields.length) {
3089                                            if (orderByComparator.isAscending() ^ previous) {
3090                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3091                                            }
3092                                            else {
3093                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3094                                            }
3095                                    }
3096                                    else {
3097                                            if (orderByComparator.isAscending() ^ previous) {
3098                                                    query.append(WHERE_GREATER_THAN);
3099                                            }
3100                                            else {
3101                                                    query.append(WHERE_LESSER_THAN);
3102                                            }
3103                                    }
3104                            }
3105    
3106                            query.append(ORDER_BY_CLAUSE);
3107    
3108                            String[] orderByFields = orderByComparator.getOrderByFields();
3109    
3110                            for (int i = 0; i < orderByFields.length; i++) {
3111                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3112                                    query.append(orderByFields[i]);
3113    
3114                                    if ((i + 1) < orderByFields.length) {
3115                                            if (orderByComparator.isAscending() ^ previous) {
3116                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3117                                            }
3118                                            else {
3119                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3120                                            }
3121                                    }
3122                                    else {
3123                                            if (orderByComparator.isAscending() ^ previous) {
3124                                                    query.append(ORDER_BY_ASC);
3125                                            }
3126                                            else {
3127                                                    query.append(ORDER_BY_DESC);
3128                                            }
3129                                    }
3130                            }
3131                    }
3132                    else {
3133                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3134                    }
3135    
3136                    String sql = query.toString();
3137    
3138                    Query q = session.createQuery(sql);
3139    
3140                    q.setFirstResult(0);
3141                    q.setMaxResults(2);
3142    
3143                    QueryPos qPos = QueryPos.getInstance(q);
3144    
3145                    qPos.add(companyId);
3146    
3147                    qPos.add(userId);
3148    
3149                    if (orderByComparator != null) {
3150                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3151    
3152                            for (Object value : values) {
3153                                    qPos.add(value);
3154                            }
3155                    }
3156    
3157                    List<BlogsEntry> list = q.list();
3158    
3159                    if (list.size() == 2) {
3160                            return list.get(1);
3161                    }
3162                    else {
3163                            return null;
3164                    }
3165            }
3166    
3167            /**
3168             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
3169             *
3170             * @param companyId the company ID
3171             * @param userId the user ID
3172             * @throws SystemException if a system exception occurred
3173             */
3174            public void removeByC_U(long companyId, long userId)
3175                    throws SystemException {
3176                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
3177                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3178                            remove(blogsEntry);
3179                    }
3180            }
3181    
3182            /**
3183             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
3184             *
3185             * @param companyId the company ID
3186             * @param userId the user ID
3187             * @return the number of matching blogs entries
3188             * @throws SystemException if a system exception occurred
3189             */
3190            public int countByC_U(long companyId, long userId)
3191                    throws SystemException {
3192                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
3193    
3194                    Object[] finderArgs = new Object[] { companyId, userId };
3195    
3196                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3197                                    this);
3198    
3199                    if (count == null) {
3200                            StringBundler query = new StringBundler(3);
3201    
3202                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3203    
3204                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3205    
3206                            query.append(_FINDER_COLUMN_C_U_USERID_2);
3207    
3208                            String sql = query.toString();
3209    
3210                            Session session = null;
3211    
3212                            try {
3213                                    session = openSession();
3214    
3215                                    Query q = session.createQuery(sql);
3216    
3217                                    QueryPos qPos = QueryPos.getInstance(q);
3218    
3219                                    qPos.add(companyId);
3220    
3221                                    qPos.add(userId);
3222    
3223                                    count = (Long)q.uniqueResult();
3224    
3225                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3226                            }
3227                            catch (Exception e) {
3228                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3229    
3230                                    throw processException(e);
3231                            }
3232                            finally {
3233                                    closeSession(session);
3234                            }
3235                    }
3236    
3237                    return count.intValue();
3238            }
3239    
3240            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
3241            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
3242            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3243                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3244                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
3245                            new String[] {
3246                                    Long.class.getName(), Date.class.getName(),
3247                                    
3248                            Integer.class.getName(), Integer.class.getName(),
3249                                    OrderByComparator.class.getName()
3250                            });
3251            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3252                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3253                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
3254                            new String[] { Long.class.getName(), Date.class.getName() });
3255    
3256            /**
3257             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3258             *
3259             * @param companyId the company ID
3260             * @param displayDate the display date
3261             * @return the matching blogs entries
3262             * @throws SystemException if a system exception occurred
3263             */
3264            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate)
3265                    throws SystemException {
3266                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
3267                            QueryUtil.ALL_POS, null);
3268            }
3269    
3270            /**
3271             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3272             *
3273             * <p>
3274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3275             * </p>
3276             *
3277             * @param companyId the company ID
3278             * @param displayDate the display date
3279             * @param start the lower bound of the range of blogs entries
3280             * @param end the upper bound of the range of blogs entries (not inclusive)
3281             * @return the range of matching blogs entries
3282             * @throws SystemException if a system exception occurred
3283             */
3284            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3285                    int start, int end) throws SystemException {
3286                    return findByC_LtD(companyId, displayDate, start, end, null);
3287            }
3288    
3289            /**
3290             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3291             *
3292             * <p>
3293             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3294             * </p>
3295             *
3296             * @param companyId the company ID
3297             * @param displayDate the display date
3298             * @param start the lower bound of the range of blogs entries
3299             * @param end the upper bound of the range of blogs entries (not inclusive)
3300             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3301             * @return the ordered range of matching blogs entries
3302             * @throws SystemException if a system exception occurred
3303             */
3304            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3305                    int start, int end, OrderByComparator orderByComparator)
3306                    throws SystemException {
3307                    boolean pagination = true;
3308                    FinderPath finderPath = null;
3309                    Object[] finderArgs = null;
3310    
3311                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
3312                    finderArgs = new Object[] {
3313                                    companyId, displayDate,
3314                                    
3315                                    start, end, orderByComparator
3316                            };
3317    
3318                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3319                                    finderArgs, this);
3320    
3321                    if ((list != null) && !list.isEmpty()) {
3322                            for (BlogsEntry blogsEntry : list) {
3323                                    if ((companyId != blogsEntry.getCompanyId()) ||
3324                                                    !Validator.equals(displayDate,
3325                                                            blogsEntry.getDisplayDate())) {
3326                                            list = null;
3327    
3328                                            break;
3329                                    }
3330                            }
3331                    }
3332    
3333                    if (list == null) {
3334                            StringBundler query = null;
3335    
3336                            if (orderByComparator != null) {
3337                                    query = new StringBundler(4 +
3338                                                    (orderByComparator.getOrderByFields().length * 3));
3339                            }
3340                            else {
3341                                    query = new StringBundler(4);
3342                            }
3343    
3344                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3345    
3346                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3347    
3348                            if (displayDate == null) {
3349                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3350                            }
3351                            else {
3352                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3353                            }
3354    
3355                            if (orderByComparator != null) {
3356                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3357                                            orderByComparator);
3358                            }
3359                            else
3360                             if (pagination) {
3361                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3362                            }
3363    
3364                            String sql = query.toString();
3365    
3366                            Session session = null;
3367    
3368                            try {
3369                                    session = openSession();
3370    
3371                                    Query q = session.createQuery(sql);
3372    
3373                                    QueryPos qPos = QueryPos.getInstance(q);
3374    
3375                                    qPos.add(companyId);
3376    
3377                                    if (displayDate != null) {
3378                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3379                                    }
3380    
3381                                    if (!pagination) {
3382                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3383                                                            start, end, false);
3384    
3385                                            Collections.sort(list);
3386    
3387                                            list = new UnmodifiableList<BlogsEntry>(list);
3388                                    }
3389                                    else {
3390                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3391                                                            start, end);
3392                                    }
3393    
3394                                    cacheResult(list);
3395    
3396                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3397                            }
3398                            catch (Exception e) {
3399                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3400    
3401                                    throw processException(e);
3402                            }
3403                            finally {
3404                                    closeSession(session);
3405                            }
3406                    }
3407    
3408                    return list;
3409            }
3410    
3411            /**
3412             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3413             *
3414             * @param companyId the company ID
3415             * @param displayDate the display date
3416             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3417             * @return the first matching blogs entry
3418             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3419             * @throws SystemException if a system exception occurred
3420             */
3421            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
3422                    OrderByComparator orderByComparator)
3423                    throws NoSuchEntryException, SystemException {
3424                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
3425                                    orderByComparator);
3426    
3427                    if (blogsEntry != null) {
3428                            return blogsEntry;
3429                    }
3430    
3431                    StringBundler msg = new StringBundler(6);
3432    
3433                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3434    
3435                    msg.append("companyId=");
3436                    msg.append(companyId);
3437    
3438                    msg.append(", displayDate=");
3439                    msg.append(displayDate);
3440    
3441                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3442    
3443                    throw new NoSuchEntryException(msg.toString());
3444            }
3445    
3446            /**
3447             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3448             *
3449             * @param companyId the company ID
3450             * @param displayDate the display date
3451             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3452             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3453             * @throws SystemException if a system exception occurred
3454             */
3455            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
3456                    OrderByComparator orderByComparator) throws SystemException {
3457                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
3458                                    orderByComparator);
3459    
3460                    if (!list.isEmpty()) {
3461                            return list.get(0);
3462                    }
3463    
3464                    return null;
3465            }
3466    
3467            /**
3468             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3469             *
3470             * @param companyId the company ID
3471             * @param displayDate the display date
3472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3473             * @return the last matching blogs entry
3474             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3475             * @throws SystemException if a system exception occurred
3476             */
3477            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
3478                    OrderByComparator orderByComparator)
3479                    throws NoSuchEntryException, SystemException {
3480                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
3481                                    orderByComparator);
3482    
3483                    if (blogsEntry != null) {
3484                            return blogsEntry;
3485                    }
3486    
3487                    StringBundler msg = new StringBundler(6);
3488    
3489                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3490    
3491                    msg.append("companyId=");
3492                    msg.append(companyId);
3493    
3494                    msg.append(", displayDate=");
3495                    msg.append(displayDate);
3496    
3497                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3498    
3499                    throw new NoSuchEntryException(msg.toString());
3500            }
3501    
3502            /**
3503             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3504             *
3505             * @param companyId the company ID
3506             * @param displayDate the display date
3507             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3508             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3509             * @throws SystemException if a system exception occurred
3510             */
3511            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
3512                    OrderByComparator orderByComparator) throws SystemException {
3513                    int count = countByC_LtD(companyId, displayDate);
3514    
3515                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
3516                                    count, orderByComparator);
3517    
3518                    if (!list.isEmpty()) {
3519                            return list.get(0);
3520                    }
3521    
3522                    return null;
3523            }
3524    
3525            /**
3526             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3527             *
3528             * @param entryId the primary key of the current blogs entry
3529             * @param companyId the company ID
3530             * @param displayDate the display date
3531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3532             * @return the previous, current, and next blogs entry
3533             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3534             * @throws SystemException if a system exception occurred
3535             */
3536            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
3537                    Date displayDate, OrderByComparator orderByComparator)
3538                    throws NoSuchEntryException, SystemException {
3539                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3540    
3541                    Session session = null;
3542    
3543                    try {
3544                            session = openSession();
3545    
3546                            BlogsEntry[] array = new BlogsEntryImpl[3];
3547    
3548                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3549                                            displayDate, orderByComparator, true);
3550    
3551                            array[1] = blogsEntry;
3552    
3553                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3554                                            displayDate, orderByComparator, false);
3555    
3556                            return array;
3557                    }
3558                    catch (Exception e) {
3559                            throw processException(e);
3560                    }
3561                    finally {
3562                            closeSession(session);
3563                    }
3564            }
3565    
3566            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
3567                    BlogsEntry blogsEntry, long companyId, Date displayDate,
3568                    OrderByComparator orderByComparator, boolean previous) {
3569                    StringBundler query = null;
3570    
3571                    if (orderByComparator != null) {
3572                            query = new StringBundler(6 +
3573                                            (orderByComparator.getOrderByFields().length * 6));
3574                    }
3575                    else {
3576                            query = new StringBundler(3);
3577                    }
3578    
3579                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3580    
3581                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3582    
3583                    if (displayDate == null) {
3584                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3585                    }
3586                    else {
3587                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3588                    }
3589    
3590                    if (orderByComparator != null) {
3591                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3592    
3593                            if (orderByConditionFields.length > 0) {
3594                                    query.append(WHERE_AND);
3595                            }
3596    
3597                            for (int i = 0; i < orderByConditionFields.length; i++) {
3598                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3599                                    query.append(orderByConditionFields[i]);
3600    
3601                                    if ((i + 1) < orderByConditionFields.length) {
3602                                            if (orderByComparator.isAscending() ^ previous) {
3603                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3604                                            }
3605                                            else {
3606                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3607                                            }
3608                                    }
3609                                    else {
3610                                            if (orderByComparator.isAscending() ^ previous) {
3611                                                    query.append(WHERE_GREATER_THAN);
3612                                            }
3613                                            else {
3614                                                    query.append(WHERE_LESSER_THAN);
3615                                            }
3616                                    }
3617                            }
3618    
3619                            query.append(ORDER_BY_CLAUSE);
3620    
3621                            String[] orderByFields = orderByComparator.getOrderByFields();
3622    
3623                            for (int i = 0; i < orderByFields.length; i++) {
3624                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3625                                    query.append(orderByFields[i]);
3626    
3627                                    if ((i + 1) < orderByFields.length) {
3628                                            if (orderByComparator.isAscending() ^ previous) {
3629                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3630                                            }
3631                                            else {
3632                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3633                                            }
3634                                    }
3635                                    else {
3636                                            if (orderByComparator.isAscending() ^ previous) {
3637                                                    query.append(ORDER_BY_ASC);
3638                                            }
3639                                            else {
3640                                                    query.append(ORDER_BY_DESC);
3641                                            }
3642                                    }
3643                            }
3644                    }
3645                    else {
3646                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3647                    }
3648    
3649                    String sql = query.toString();
3650    
3651                    Query q = session.createQuery(sql);
3652    
3653                    q.setFirstResult(0);
3654                    q.setMaxResults(2);
3655    
3656                    QueryPos qPos = QueryPos.getInstance(q);
3657    
3658                    qPos.add(companyId);
3659    
3660                    if (displayDate != null) {
3661                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3662                    }
3663    
3664                    if (orderByComparator != null) {
3665                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3666    
3667                            for (Object value : values) {
3668                                    qPos.add(value);
3669                            }
3670                    }
3671    
3672                    List<BlogsEntry> list = q.list();
3673    
3674                    if (list.size() == 2) {
3675                            return list.get(1);
3676                    }
3677                    else {
3678                            return null;
3679                    }
3680            }
3681    
3682            /**
3683             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
3684             *
3685             * @param companyId the company ID
3686             * @param displayDate the display date
3687             * @throws SystemException if a system exception occurred
3688             */
3689            public void removeByC_LtD(long companyId, Date displayDate)
3690                    throws SystemException {
3691                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
3692                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3693                            remove(blogsEntry);
3694                    }
3695            }
3696    
3697            /**
3698             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3699             *
3700             * @param companyId the company ID
3701             * @param displayDate the display date
3702             * @return the number of matching blogs entries
3703             * @throws SystemException if a system exception occurred
3704             */
3705            public int countByC_LtD(long companyId, Date displayDate)
3706                    throws SystemException {
3707                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
3708    
3709                    Object[] finderArgs = new Object[] { companyId, displayDate };
3710    
3711                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3712                                    this);
3713    
3714                    if (count == null) {
3715                            StringBundler query = new StringBundler(3);
3716    
3717                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3718    
3719                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3720    
3721                            if (displayDate == null) {
3722                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3723                            }
3724                            else {
3725                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3726                            }
3727    
3728                            String sql = query.toString();
3729    
3730                            Session session = null;
3731    
3732                            try {
3733                                    session = openSession();
3734    
3735                                    Query q = session.createQuery(sql);
3736    
3737                                    QueryPos qPos = QueryPos.getInstance(q);
3738    
3739                                    qPos.add(companyId);
3740    
3741                                    if (displayDate != null) {
3742                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3743                                    }
3744    
3745                                    count = (Long)q.uniqueResult();
3746    
3747                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3748                            }
3749                            catch (Exception e) {
3750                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3751    
3752                                    throw processException(e);
3753                            }
3754                            finally {
3755                                    closeSession(session);
3756                            }
3757                    }
3758    
3759                    return count.intValue();
3760            }
3761    
3762            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
3763            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
3764            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
3765            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3766                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3767                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
3768                            new String[] {
3769                                    Long.class.getName(), Integer.class.getName(),
3770                                    
3771                            Integer.class.getName(), Integer.class.getName(),
3772                                    OrderByComparator.class.getName()
3773                            });
3774            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3775                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3776                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
3777                            new String[] { Long.class.getName(), Integer.class.getName() });
3778    
3779            /**
3780             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
3781             *
3782             * @param companyId the company ID
3783             * @param status the status
3784             * @return the matching blogs entries
3785             * @throws SystemException if a system exception occurred
3786             */
3787            public List<BlogsEntry> findByC_NotS(long companyId, int status)
3788                    throws SystemException {
3789                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
3790                            QueryUtil.ALL_POS, null);
3791            }
3792    
3793            /**
3794             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
3795             *
3796             * <p>
3797             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3798             * </p>
3799             *
3800             * @param companyId the company ID
3801             * @param status the status
3802             * @param start the lower bound of the range of blogs entries
3803             * @param end the upper bound of the range of blogs entries (not inclusive)
3804             * @return the range of matching blogs entries
3805             * @throws SystemException if a system exception occurred
3806             */
3807            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
3808                    int end) throws SystemException {
3809                    return findByC_NotS(companyId, status, start, end, null);
3810            }
3811    
3812            /**
3813             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
3814             *
3815             * <p>
3816             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3817             * </p>
3818             *
3819             * @param companyId the company ID
3820             * @param status the status
3821             * @param start the lower bound of the range of blogs entries
3822             * @param end the upper bound of the range of blogs entries (not inclusive)
3823             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3824             * @return the ordered range of matching blogs entries
3825             * @throws SystemException if a system exception occurred
3826             */
3827            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
3828                    int end, OrderByComparator orderByComparator) throws SystemException {
3829                    boolean pagination = true;
3830                    FinderPath finderPath = null;
3831                    Object[] finderArgs = null;
3832    
3833                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
3834                    finderArgs = new Object[] {
3835                                    companyId, status,
3836                                    
3837                                    start, end, orderByComparator
3838                            };
3839    
3840                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3841                                    finderArgs, this);
3842    
3843                    if ((list != null) && !list.isEmpty()) {
3844                            for (BlogsEntry blogsEntry : list) {
3845                                    if ((companyId != blogsEntry.getCompanyId()) ||
3846                                                    (status != blogsEntry.getStatus())) {
3847                                            list = null;
3848    
3849                                            break;
3850                                    }
3851                            }
3852                    }
3853    
3854                    if (list == null) {
3855                            StringBundler query = null;
3856    
3857                            if (orderByComparator != null) {
3858                                    query = new StringBundler(4 +
3859                                                    (orderByComparator.getOrderByFields().length * 3));
3860                            }
3861                            else {
3862                                    query = new StringBundler(4);
3863                            }
3864    
3865                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3866    
3867                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
3868    
3869                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
3870    
3871                            if (orderByComparator != null) {
3872                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3873                                            orderByComparator);
3874                            }
3875                            else
3876                             if (pagination) {
3877                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3878                            }
3879    
3880                            String sql = query.toString();
3881    
3882                            Session session = null;
3883    
3884                            try {
3885                                    session = openSession();
3886    
3887                                    Query q = session.createQuery(sql);
3888    
3889                                    QueryPos qPos = QueryPos.getInstance(q);
3890    
3891                                    qPos.add(companyId);
3892    
3893                                    qPos.add(status);
3894    
3895                                    if (!pagination) {
3896                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3897                                                            start, end, false);
3898    
3899                                            Collections.sort(list);
3900    
3901                                            list = new UnmodifiableList<BlogsEntry>(list);
3902                                    }
3903                                    else {
3904                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3905                                                            start, end);
3906                                    }
3907    
3908                                    cacheResult(list);
3909    
3910                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3911                            }
3912                            catch (Exception e) {
3913                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3914    
3915                                    throw processException(e);
3916                            }
3917                            finally {
3918                                    closeSession(session);
3919                            }
3920                    }
3921    
3922                    return list;
3923            }
3924    
3925            /**
3926             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
3927             *
3928             * @param companyId the company ID
3929             * @param status the status
3930             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3931             * @return the first matching blogs entry
3932             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3933             * @throws SystemException if a system exception occurred
3934             */
3935            public BlogsEntry findByC_NotS_First(long companyId, int status,
3936                    OrderByComparator orderByComparator)
3937                    throws NoSuchEntryException, SystemException {
3938                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
3939                                    orderByComparator);
3940    
3941                    if (blogsEntry != null) {
3942                            return blogsEntry;
3943                    }
3944    
3945                    StringBundler msg = new StringBundler(6);
3946    
3947                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3948    
3949                    msg.append("companyId=");
3950                    msg.append(companyId);
3951    
3952                    msg.append(", status=");
3953                    msg.append(status);
3954    
3955                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3956    
3957                    throw new NoSuchEntryException(msg.toString());
3958            }
3959    
3960            /**
3961             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
3962             *
3963             * @param companyId the company ID
3964             * @param status the status
3965             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3966             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3967             * @throws SystemException if a system exception occurred
3968             */
3969            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
3970                    OrderByComparator orderByComparator) throws SystemException {
3971                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
3972                                    orderByComparator);
3973    
3974                    if (!list.isEmpty()) {
3975                            return list.get(0);
3976                    }
3977    
3978                    return null;
3979            }
3980    
3981            /**
3982             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
3983             *
3984             * @param companyId the company ID
3985             * @param status the status
3986             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3987             * @return the last matching blogs entry
3988             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3989             * @throws SystemException if a system exception occurred
3990             */
3991            public BlogsEntry findByC_NotS_Last(long companyId, int status,
3992                    OrderByComparator orderByComparator)
3993                    throws NoSuchEntryException, SystemException {
3994                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
3995                                    orderByComparator);
3996    
3997                    if (blogsEntry != null) {
3998                            return blogsEntry;
3999                    }
4000    
4001                    StringBundler msg = new StringBundler(6);
4002    
4003                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4004    
4005                    msg.append("companyId=");
4006                    msg.append(companyId);
4007    
4008                    msg.append(", status=");
4009                    msg.append(status);
4010    
4011                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4012    
4013                    throw new NoSuchEntryException(msg.toString());
4014            }
4015    
4016            /**
4017             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4018             *
4019             * @param companyId the company ID
4020             * @param status the status
4021             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4022             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4023             * @throws SystemException if a system exception occurred
4024             */
4025            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
4026                    OrderByComparator orderByComparator) throws SystemException {
4027                    int count = countByC_NotS(companyId, status);
4028    
4029                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
4030                                    count, orderByComparator);
4031    
4032                    if (!list.isEmpty()) {
4033                            return list.get(0);
4034                    }
4035    
4036                    return null;
4037            }
4038    
4039            /**
4040             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4041             *
4042             * @param entryId the primary key of the current blogs entry
4043             * @param companyId the company ID
4044             * @param status the status
4045             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4046             * @return the previous, current, and next blogs entry
4047             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4048             * @throws SystemException if a system exception occurred
4049             */
4050            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
4051                    int status, OrderByComparator orderByComparator)
4052                    throws NoSuchEntryException, SystemException {
4053                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4054    
4055                    Session session = null;
4056    
4057                    try {
4058                            session = openSession();
4059    
4060                            BlogsEntry[] array = new BlogsEntryImpl[3];
4061    
4062                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
4063                                            status, orderByComparator, true);
4064    
4065                            array[1] = blogsEntry;
4066    
4067                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
4068                                            status, orderByComparator, false);
4069    
4070                            return array;
4071                    }
4072                    catch (Exception e) {
4073                            throw processException(e);
4074                    }
4075                    finally {
4076                            closeSession(session);
4077                    }
4078            }
4079    
4080            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
4081                    BlogsEntry blogsEntry, long companyId, int status,
4082                    OrderByComparator orderByComparator, boolean previous) {
4083                    StringBundler query = null;
4084    
4085                    if (orderByComparator != null) {
4086                            query = new StringBundler(6 +
4087                                            (orderByComparator.getOrderByFields().length * 6));
4088                    }
4089                    else {
4090                            query = new StringBundler(3);
4091                    }
4092    
4093                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4094    
4095                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4096    
4097                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4098    
4099                    if (orderByComparator != null) {
4100                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4101    
4102                            if (orderByConditionFields.length > 0) {
4103                                    query.append(WHERE_AND);
4104                            }
4105    
4106                            for (int i = 0; i < orderByConditionFields.length; i++) {
4107                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4108                                    query.append(orderByConditionFields[i]);
4109    
4110                                    if ((i + 1) < orderByConditionFields.length) {
4111                                            if (orderByComparator.isAscending() ^ previous) {
4112                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4113                                            }
4114                                            else {
4115                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4116                                            }
4117                                    }
4118                                    else {
4119                                            if (orderByComparator.isAscending() ^ previous) {
4120                                                    query.append(WHERE_GREATER_THAN);
4121                                            }
4122                                            else {
4123                                                    query.append(WHERE_LESSER_THAN);
4124                                            }
4125                                    }
4126                            }
4127    
4128                            query.append(ORDER_BY_CLAUSE);
4129    
4130                            String[] orderByFields = orderByComparator.getOrderByFields();
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                    else {
4155                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4156                    }
4157    
4158                    String sql = query.toString();
4159    
4160                    Query q = session.createQuery(sql);
4161    
4162                    q.setFirstResult(0);
4163                    q.setMaxResults(2);
4164    
4165                    QueryPos qPos = QueryPos.getInstance(q);
4166    
4167                    qPos.add(companyId);
4168    
4169                    qPos.add(status);
4170    
4171                    if (orderByComparator != null) {
4172                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4173    
4174                            for (Object value : values) {
4175                                    qPos.add(value);
4176                            }
4177                    }
4178    
4179                    List<BlogsEntry> list = q.list();
4180    
4181                    if (list.size() == 2) {
4182                            return list.get(1);
4183                    }
4184                    else {
4185                            return null;
4186                    }
4187            }
4188    
4189            /**
4190             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
4191             *
4192             * @param companyId the company ID
4193             * @param status the status
4194             * @throws SystemException if a system exception occurred
4195             */
4196            public void removeByC_NotS(long companyId, int status)
4197                    throws SystemException {
4198                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
4199                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4200                            remove(blogsEntry);
4201                    }
4202            }
4203    
4204            /**
4205             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
4206             *
4207             * @param companyId the company ID
4208             * @param status the status
4209             * @return the number of matching blogs entries
4210             * @throws SystemException if a system exception occurred
4211             */
4212            public int countByC_NotS(long companyId, int status)
4213                    throws SystemException {
4214                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
4215    
4216                    Object[] finderArgs = new Object[] { companyId, status };
4217    
4218                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4219                                    this);
4220    
4221                    if (count == null) {
4222                            StringBundler query = new StringBundler(3);
4223    
4224                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4225    
4226                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4227    
4228                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4229    
4230                            String sql = query.toString();
4231    
4232                            Session session = null;
4233    
4234                            try {
4235                                    session = openSession();
4236    
4237                                    Query q = session.createQuery(sql);
4238    
4239                                    QueryPos qPos = QueryPos.getInstance(q);
4240    
4241                                    qPos.add(companyId);
4242    
4243                                    qPos.add(status);
4244    
4245                                    count = (Long)q.uniqueResult();
4246    
4247                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4248                            }
4249                            catch (Exception e) {
4250                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4251    
4252                                    throw processException(e);
4253                            }
4254                            finally {
4255                                    closeSession(session);
4256                            }
4257                    }
4258    
4259                    return count.intValue();
4260            }
4261    
4262            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
4263            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
4264            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4265                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4266                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
4267                            new String[] {
4268                                    Long.class.getName(), Integer.class.getName(),
4269                                    
4270                            Integer.class.getName(), Integer.class.getName(),
4271                                    OrderByComparator.class.getName()
4272                            });
4273            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4274                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4275                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
4276                            new String[] { Long.class.getName(), Integer.class.getName() },
4277                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
4278                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4279                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4280                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4281            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4282                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4283                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
4284                            new String[] { Long.class.getName(), Integer.class.getName() });
4285    
4286            /**
4287             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
4288             *
4289             * @param companyId the company ID
4290             * @param status the status
4291             * @return the matching blogs entries
4292             * @throws SystemException if a system exception occurred
4293             */
4294            public List<BlogsEntry> findByC_S(long companyId, int status)
4295                    throws SystemException {
4296                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
4297                            QueryUtil.ALL_POS, null);
4298            }
4299    
4300            /**
4301             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
4302             *
4303             * <p>
4304             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4305             * </p>
4306             *
4307             * @param companyId the company ID
4308             * @param status the status
4309             * @param start the lower bound of the range of blogs entries
4310             * @param end the upper bound of the range of blogs entries (not inclusive)
4311             * @return the range of matching blogs entries
4312             * @throws SystemException if a system exception occurred
4313             */
4314            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4315                    int end) throws SystemException {
4316                    return findByC_S(companyId, status, start, end, null);
4317            }
4318    
4319            /**
4320             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
4321             *
4322             * <p>
4323             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4324             * </p>
4325             *
4326             * @param companyId the company ID
4327             * @param status the status
4328             * @param start the lower bound of the range of blogs entries
4329             * @param end the upper bound of the range of blogs entries (not inclusive)
4330             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4331             * @return the ordered range of matching blogs entries
4332             * @throws SystemException if a system exception occurred
4333             */
4334            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4335                    int end, OrderByComparator orderByComparator) throws SystemException {
4336                    boolean pagination = true;
4337                    FinderPath finderPath = null;
4338                    Object[] finderArgs = null;
4339    
4340                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4341                                    (orderByComparator == null)) {
4342                            pagination = false;
4343                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
4344                            finderArgs = new Object[] { companyId, status };
4345                    }
4346                    else {
4347                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
4348                            finderArgs = new Object[] {
4349                                            companyId, status,
4350                                            
4351                                            start, end, orderByComparator
4352                                    };
4353                    }
4354    
4355                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4356                                    finderArgs, this);
4357    
4358                    if ((list != null) && !list.isEmpty()) {
4359                            for (BlogsEntry blogsEntry : list) {
4360                                    if ((companyId != blogsEntry.getCompanyId()) ||
4361                                                    (status != blogsEntry.getStatus())) {
4362                                            list = null;
4363    
4364                                            break;
4365                                    }
4366                            }
4367                    }
4368    
4369                    if (list == null) {
4370                            StringBundler query = null;
4371    
4372                            if (orderByComparator != null) {
4373                                    query = new StringBundler(4 +
4374                                                    (orderByComparator.getOrderByFields().length * 3));
4375                            }
4376                            else {
4377                                    query = new StringBundler(4);
4378                            }
4379    
4380                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4381    
4382                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4383    
4384                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
4385    
4386                            if (orderByComparator != null) {
4387                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4388                                            orderByComparator);
4389                            }
4390                            else
4391                             if (pagination) {
4392                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4393                            }
4394    
4395                            String sql = query.toString();
4396    
4397                            Session session = null;
4398    
4399                            try {
4400                                    session = openSession();
4401    
4402                                    Query q = session.createQuery(sql);
4403    
4404                                    QueryPos qPos = QueryPos.getInstance(q);
4405    
4406                                    qPos.add(companyId);
4407    
4408                                    qPos.add(status);
4409    
4410                                    if (!pagination) {
4411                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4412                                                            start, end, false);
4413    
4414                                            Collections.sort(list);
4415    
4416                                            list = new UnmodifiableList<BlogsEntry>(list);
4417                                    }
4418                                    else {
4419                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4420                                                            start, end);
4421                                    }
4422    
4423                                    cacheResult(list);
4424    
4425                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4426                            }
4427                            catch (Exception e) {
4428                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4429    
4430                                    throw processException(e);
4431                            }
4432                            finally {
4433                                    closeSession(session);
4434                            }
4435                    }
4436    
4437                    return list;
4438            }
4439    
4440            /**
4441             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4442             *
4443             * @param companyId the company ID
4444             * @param status the status
4445             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4446             * @return the first matching blogs entry
4447             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4448             * @throws SystemException if a system exception occurred
4449             */
4450            public BlogsEntry findByC_S_First(long companyId, int status,
4451                    OrderByComparator orderByComparator)
4452                    throws NoSuchEntryException, SystemException {
4453                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
4454                                    orderByComparator);
4455    
4456                    if (blogsEntry != null) {
4457                            return blogsEntry;
4458                    }
4459    
4460                    StringBundler msg = new StringBundler(6);
4461    
4462                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4463    
4464                    msg.append("companyId=");
4465                    msg.append(companyId);
4466    
4467                    msg.append(", status=");
4468                    msg.append(status);
4469    
4470                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4471    
4472                    throw new NoSuchEntryException(msg.toString());
4473            }
4474    
4475            /**
4476             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4477             *
4478             * @param companyId the company ID
4479             * @param status the status
4480             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4481             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4482             * @throws SystemException if a system exception occurred
4483             */
4484            public BlogsEntry fetchByC_S_First(long companyId, int status,
4485                    OrderByComparator orderByComparator) throws SystemException {
4486                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
4487                                    orderByComparator);
4488    
4489                    if (!list.isEmpty()) {
4490                            return list.get(0);
4491                    }
4492    
4493                    return null;
4494            }
4495    
4496            /**
4497             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4498             *
4499             * @param companyId the company ID
4500             * @param status the status
4501             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4502             * @return the last matching blogs entry
4503             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4504             * @throws SystemException if a system exception occurred
4505             */
4506            public BlogsEntry findByC_S_Last(long companyId, int status,
4507                    OrderByComparator orderByComparator)
4508                    throws NoSuchEntryException, SystemException {
4509                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
4510                                    orderByComparator);
4511    
4512                    if (blogsEntry != null) {
4513                            return blogsEntry;
4514                    }
4515    
4516                    StringBundler msg = new StringBundler(6);
4517    
4518                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4519    
4520                    msg.append("companyId=");
4521                    msg.append(companyId);
4522    
4523                    msg.append(", status=");
4524                    msg.append(status);
4525    
4526                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4527    
4528                    throw new NoSuchEntryException(msg.toString());
4529            }
4530    
4531            /**
4532             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4533             *
4534             * @param companyId the company ID
4535             * @param status the status
4536             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4537             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4538             * @throws SystemException if a system exception occurred
4539             */
4540            public BlogsEntry fetchByC_S_Last(long companyId, int status,
4541                    OrderByComparator orderByComparator) throws SystemException {
4542                    int count = countByC_S(companyId, status);
4543    
4544                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
4545                                    orderByComparator);
4546    
4547                    if (!list.isEmpty()) {
4548                            return list.get(0);
4549                    }
4550    
4551                    return null;
4552            }
4553    
4554            /**
4555             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4556             *
4557             * @param entryId the primary key of the current blogs entry
4558             * @param companyId the company ID
4559             * @param status the status
4560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4561             * @return the previous, current, and next blogs entry
4562             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4563             * @throws SystemException if a system exception occurred
4564             */
4565            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
4566                    int status, OrderByComparator orderByComparator)
4567                    throws NoSuchEntryException, SystemException {
4568                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4569    
4570                    Session session = null;
4571    
4572                    try {
4573                            session = openSession();
4574    
4575                            BlogsEntry[] array = new BlogsEntryImpl[3];
4576    
4577                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4578                                            status, orderByComparator, true);
4579    
4580                            array[1] = blogsEntry;
4581    
4582                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4583                                            status, orderByComparator, false);
4584    
4585                            return array;
4586                    }
4587                    catch (Exception e) {
4588                            throw processException(e);
4589                    }
4590                    finally {
4591                            closeSession(session);
4592                    }
4593            }
4594    
4595            protected BlogsEntry getByC_S_PrevAndNext(Session session,
4596                    BlogsEntry blogsEntry, long companyId, int status,
4597                    OrderByComparator orderByComparator, boolean previous) {
4598                    StringBundler query = null;
4599    
4600                    if (orderByComparator != null) {
4601                            query = new StringBundler(6 +
4602                                            (orderByComparator.getOrderByFields().length * 6));
4603                    }
4604                    else {
4605                            query = new StringBundler(3);
4606                    }
4607    
4608                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4609    
4610                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4611    
4612                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
4613    
4614                    if (orderByComparator != null) {
4615                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4616    
4617                            if (orderByConditionFields.length > 0) {
4618                                    query.append(WHERE_AND);
4619                            }
4620    
4621                            for (int i = 0; i < orderByConditionFields.length; i++) {
4622                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4623                                    query.append(orderByConditionFields[i]);
4624    
4625                                    if ((i + 1) < orderByConditionFields.length) {
4626                                            if (orderByComparator.isAscending() ^ previous) {
4627                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4628                                            }
4629                                            else {
4630                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4631                                            }
4632                                    }
4633                                    else {
4634                                            if (orderByComparator.isAscending() ^ previous) {
4635                                                    query.append(WHERE_GREATER_THAN);
4636                                            }
4637                                            else {
4638                                                    query.append(WHERE_LESSER_THAN);
4639                                            }
4640                                    }
4641                            }
4642    
4643                            query.append(ORDER_BY_CLAUSE);
4644    
4645                            String[] orderByFields = orderByComparator.getOrderByFields();
4646    
4647                            for (int i = 0; i < orderByFields.length; i++) {
4648                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4649                                    query.append(orderByFields[i]);
4650    
4651                                    if ((i + 1) < orderByFields.length) {
4652                                            if (orderByComparator.isAscending() ^ previous) {
4653                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4654                                            }
4655                                            else {
4656                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4657                                            }
4658                                    }
4659                                    else {
4660                                            if (orderByComparator.isAscending() ^ previous) {
4661                                                    query.append(ORDER_BY_ASC);
4662                                            }
4663                                            else {
4664                                                    query.append(ORDER_BY_DESC);
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(status);
4685    
4686                    if (orderByComparator != null) {
4687                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4688    
4689                            for (Object value : values) {
4690                                    qPos.add(value);
4691                            }
4692                    }
4693    
4694                    List<BlogsEntry> list = q.list();
4695    
4696                    if (list.size() == 2) {
4697                            return list.get(1);
4698                    }
4699                    else {
4700                            return null;
4701                    }
4702            }
4703    
4704            /**
4705             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
4706             *
4707             * @param companyId the company ID
4708             * @param status the status
4709             * @throws SystemException if a system exception occurred
4710             */
4711            public void removeByC_S(long companyId, int status)
4712                    throws SystemException {
4713                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
4714                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4715                            remove(blogsEntry);
4716                    }
4717            }
4718    
4719            /**
4720             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
4721             *
4722             * @param companyId the company ID
4723             * @param status the status
4724             * @return the number of matching blogs entries
4725             * @throws SystemException if a system exception occurred
4726             */
4727            public int countByC_S(long companyId, int status) throws SystemException {
4728                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
4729    
4730                    Object[] finderArgs = new Object[] { companyId, status };
4731    
4732                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4733                                    this);
4734    
4735                    if (count == null) {
4736                            StringBundler query = new StringBundler(3);
4737    
4738                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4739    
4740                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4741    
4742                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
4743    
4744                            String sql = query.toString();
4745    
4746                            Session session = null;
4747    
4748                            try {
4749                                    session = openSession();
4750    
4751                                    Query q = session.createQuery(sql);
4752    
4753                                    QueryPos qPos = QueryPos.getInstance(q);
4754    
4755                                    qPos.add(companyId);
4756    
4757                                    qPos.add(status);
4758    
4759                                    count = (Long)q.uniqueResult();
4760    
4761                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4762                            }
4763                            catch (Exception e) {
4764                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4765    
4766                                    throw processException(e);
4767                            }
4768                            finally {
4769                                    closeSession(session);
4770                            }
4771                    }
4772    
4773                    return count.intValue();
4774            }
4775    
4776            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
4777            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
4778            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4779                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4780                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
4781                            new String[] { Long.class.getName(), String.class.getName() },
4782                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4783                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
4784            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4785                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4786                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
4787                            new String[] { Long.class.getName(), String.class.getName() });
4788    
4789            /**
4790             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
4791             *
4792             * @param groupId the group ID
4793             * @param urlTitle the url title
4794             * @return the matching blogs entry
4795             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4796             * @throws SystemException if a system exception occurred
4797             */
4798            public BlogsEntry findByG_UT(long groupId, String urlTitle)
4799                    throws NoSuchEntryException, SystemException {
4800                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
4801    
4802                    if (blogsEntry == null) {
4803                            StringBundler msg = new StringBundler(6);
4804    
4805                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4806    
4807                            msg.append("groupId=");
4808                            msg.append(groupId);
4809    
4810                            msg.append(", urlTitle=");
4811                            msg.append(urlTitle);
4812    
4813                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4814    
4815                            if (_log.isWarnEnabled()) {
4816                                    _log.warn(msg.toString());
4817                            }
4818    
4819                            throw new NoSuchEntryException(msg.toString());
4820                    }
4821    
4822                    return blogsEntry;
4823            }
4824    
4825            /**
4826             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
4827             *
4828             * @param groupId the group ID
4829             * @param urlTitle the url title
4830             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4831             * @throws SystemException if a system exception occurred
4832             */
4833            public BlogsEntry fetchByG_UT(long groupId, String urlTitle)
4834                    throws SystemException {
4835                    return fetchByG_UT(groupId, urlTitle, true);
4836            }
4837    
4838            /**
4839             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
4840             *
4841             * @param groupId the group ID
4842             * @param urlTitle the url title
4843             * @param retrieveFromCache whether to use the finder cache
4844             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4845             * @throws SystemException if a system exception occurred
4846             */
4847            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
4848                    boolean retrieveFromCache) throws SystemException {
4849                    Object[] finderArgs = new Object[] { groupId, urlTitle };
4850    
4851                    Object result = null;
4852    
4853                    if (retrieveFromCache) {
4854                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_UT,
4855                                            finderArgs, this);
4856                    }
4857    
4858                    if (result instanceof BlogsEntry) {
4859                            BlogsEntry blogsEntry = (BlogsEntry)result;
4860    
4861                            if ((groupId != blogsEntry.getGroupId()) ||
4862                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
4863                                    result = null;
4864                            }
4865                    }
4866    
4867                    if (result == null) {
4868                            StringBundler query = new StringBundler(4);
4869    
4870                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4871    
4872                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
4873    
4874                            if (urlTitle == null) {
4875                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
4876                            }
4877                            else {
4878                                    if (urlTitle.equals(StringPool.BLANK)) {
4879                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
4880                                    }
4881                                    else {
4882                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
4883                                    }
4884                            }
4885    
4886                            String sql = query.toString();
4887    
4888                            Session session = null;
4889    
4890                            try {
4891                                    session = openSession();
4892    
4893                                    Query q = session.createQuery(sql);
4894    
4895                                    QueryPos qPos = QueryPos.getInstance(q);
4896    
4897                                    qPos.add(groupId);
4898    
4899                                    if (urlTitle != null) {
4900                                            qPos.add(urlTitle);
4901                                    }
4902    
4903                                    List<BlogsEntry> list = q.list();
4904    
4905                                    if (list.isEmpty()) {
4906                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
4907                                                    finderArgs, list);
4908                                    }
4909                                    else {
4910                                            BlogsEntry blogsEntry = list.get(0);
4911    
4912                                            result = blogsEntry;
4913    
4914                                            cacheResult(blogsEntry);
4915    
4916                                            if ((blogsEntry.getGroupId() != groupId) ||
4917                                                            (blogsEntry.getUrlTitle() == null) ||
4918                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
4919                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
4920                                                            finderArgs, blogsEntry);
4921                                            }
4922                                    }
4923                            }
4924                            catch (Exception e) {
4925                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
4926                                            finderArgs);
4927    
4928                                    throw processException(e);
4929                            }
4930                            finally {
4931                                    closeSession(session);
4932                            }
4933                    }
4934    
4935                    if (result instanceof List<?>) {
4936                            return null;
4937                    }
4938                    else {
4939                            return (BlogsEntry)result;
4940                    }
4941            }
4942    
4943            /**
4944             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
4945             *
4946             * @param groupId the group ID
4947             * @param urlTitle the url title
4948             * @return the blogs entry that was removed
4949             * @throws SystemException if a system exception occurred
4950             */
4951            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
4952                    throws NoSuchEntryException, SystemException {
4953                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
4954    
4955                    return remove(blogsEntry);
4956            }
4957    
4958            /**
4959             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
4960             *
4961             * @param groupId the group ID
4962             * @param urlTitle the url title
4963             * @return the number of matching blogs entries
4964             * @throws SystemException if a system exception occurred
4965             */
4966            public int countByG_UT(long groupId, String urlTitle)
4967                    throws SystemException {
4968                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
4969    
4970                    Object[] finderArgs = new Object[] { groupId, urlTitle };
4971    
4972                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4973                                    this);
4974    
4975                    if (count == null) {
4976                            StringBundler query = new StringBundler(3);
4977    
4978                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4979    
4980                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
4981    
4982                            if (urlTitle == null) {
4983                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
4984                            }
4985                            else {
4986                                    if (urlTitle.equals(StringPool.BLANK)) {
4987                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
4988                                    }
4989                                    else {
4990                                            query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
4991                                    }
4992                            }
4993    
4994                            String sql = query.toString();
4995    
4996                            Session session = null;
4997    
4998                            try {
4999                                    session = openSession();
5000    
5001                                    Query q = session.createQuery(sql);
5002    
5003                                    QueryPos qPos = QueryPos.getInstance(q);
5004    
5005                                    qPos.add(groupId);
5006    
5007                                    if (urlTitle != null) {
5008                                            qPos.add(urlTitle);
5009                                    }
5010    
5011                                    count = (Long)q.uniqueResult();
5012    
5013                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5014                            }
5015                            catch (Exception e) {
5016                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5017    
5018                                    throw processException(e);
5019                            }
5020                            finally {
5021                                    closeSession(session);
5022                            }
5023                    }
5024    
5025                    return count.intValue();
5026            }
5027    
5028            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5029            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
5030            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
5031            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = ?)";
5032            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5033                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5034                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
5035                            new String[] {
5036                                    Long.class.getName(), Date.class.getName(),
5037                                    
5038                            Integer.class.getName(), Integer.class.getName(),
5039                                    OrderByComparator.class.getName()
5040                            });
5041            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5042                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5043                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
5044                            new String[] { Long.class.getName(), Date.class.getName() });
5045    
5046            /**
5047             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5048             *
5049             * @param groupId the group ID
5050             * @param displayDate the display date
5051             * @return the matching blogs entries
5052             * @throws SystemException if a system exception occurred
5053             */
5054            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate)
5055                    throws SystemException {
5056                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5057                            QueryUtil.ALL_POS, null);
5058            }
5059    
5060            /**
5061             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5062             *
5063             * <p>
5064             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5065             * </p>
5066             *
5067             * @param groupId the group ID
5068             * @param displayDate the display date
5069             * @param start the lower bound of the range of blogs entries
5070             * @param end the upper bound of the range of blogs entries (not inclusive)
5071             * @return the range of matching blogs entries
5072             * @throws SystemException if a system exception occurred
5073             */
5074            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5075                    int start, int end) throws SystemException {
5076                    return findByG_LtD(groupId, displayDate, start, end, null);
5077            }
5078    
5079            /**
5080             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5081             *
5082             * <p>
5083             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5084             * </p>
5085             *
5086             * @param groupId the group ID
5087             * @param displayDate the display date
5088             * @param start the lower bound of the range of blogs entries
5089             * @param end the upper bound of the range of blogs entries (not inclusive)
5090             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5091             * @return the ordered range of matching blogs entries
5092             * @throws SystemException if a system exception occurred
5093             */
5094            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5095                    int start, int end, OrderByComparator orderByComparator)
5096                    throws SystemException {
5097                    boolean pagination = true;
5098                    FinderPath finderPath = null;
5099                    Object[] finderArgs = null;
5100    
5101                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
5102                    finderArgs = new Object[] {
5103                                    groupId, displayDate,
5104                                    
5105                                    start, end, orderByComparator
5106                            };
5107    
5108                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5109                                    finderArgs, this);
5110    
5111                    if ((list != null) && !list.isEmpty()) {
5112                            for (BlogsEntry blogsEntry : list) {
5113                                    if ((groupId != blogsEntry.getGroupId()) ||
5114                                                    !Validator.equals(displayDate,
5115                                                            blogsEntry.getDisplayDate())) {
5116                                            list = null;
5117    
5118                                            break;
5119                                    }
5120                            }
5121                    }
5122    
5123                    if (list == null) {
5124                            StringBundler query = null;
5125    
5126                            if (orderByComparator != null) {
5127                                    query = new StringBundler(4 +
5128                                                    (orderByComparator.getOrderByFields().length * 3));
5129                            }
5130                            else {
5131                                    query = new StringBundler(4);
5132                            }
5133    
5134                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5135    
5136                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5137    
5138                            if (displayDate == null) {
5139                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5140                            }
5141                            else {
5142                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5143                            }
5144    
5145                            if (orderByComparator != null) {
5146                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5147                                            orderByComparator);
5148                            }
5149                            else
5150                             if (pagination) {
5151                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5152                            }
5153    
5154                            String sql = query.toString();
5155    
5156                            Session session = null;
5157    
5158                            try {
5159                                    session = openSession();
5160    
5161                                    Query q = session.createQuery(sql);
5162    
5163                                    QueryPos qPos = QueryPos.getInstance(q);
5164    
5165                                    qPos.add(groupId);
5166    
5167                                    if (displayDate != null) {
5168                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5169                                    }
5170    
5171                                    if (!pagination) {
5172                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5173                                                            start, end, false);
5174    
5175                                            Collections.sort(list);
5176    
5177                                            list = new UnmodifiableList<BlogsEntry>(list);
5178                                    }
5179                                    else {
5180                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5181                                                            start, end);
5182                                    }
5183    
5184                                    cacheResult(list);
5185    
5186                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5187                            }
5188                            catch (Exception e) {
5189                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5190    
5191                                    throw processException(e);
5192                            }
5193                            finally {
5194                                    closeSession(session);
5195                            }
5196                    }
5197    
5198                    return list;
5199            }
5200    
5201            /**
5202             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5203             *
5204             * @param groupId the group ID
5205             * @param displayDate the display date
5206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5207             * @return the first matching blogs entry
5208             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5209             * @throws SystemException if a system exception occurred
5210             */
5211            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
5212                    OrderByComparator orderByComparator)
5213                    throws NoSuchEntryException, SystemException {
5214                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
5215                                    orderByComparator);
5216    
5217                    if (blogsEntry != null) {
5218                            return blogsEntry;
5219                    }
5220    
5221                    StringBundler msg = new StringBundler(6);
5222    
5223                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5224    
5225                    msg.append("groupId=");
5226                    msg.append(groupId);
5227    
5228                    msg.append(", displayDate=");
5229                    msg.append(displayDate);
5230    
5231                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5232    
5233                    throw new NoSuchEntryException(msg.toString());
5234            }
5235    
5236            /**
5237             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5238             *
5239             * @param groupId the group ID
5240             * @param displayDate the display date
5241             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5242             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5243             * @throws SystemException if a system exception occurred
5244             */
5245            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
5246                    OrderByComparator orderByComparator) throws SystemException {
5247                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
5248                                    orderByComparator);
5249    
5250                    if (!list.isEmpty()) {
5251                            return list.get(0);
5252                    }
5253    
5254                    return null;
5255            }
5256    
5257            /**
5258             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5259             *
5260             * @param groupId the group ID
5261             * @param displayDate the display date
5262             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5263             * @return the last matching blogs entry
5264             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5265             * @throws SystemException if a system exception occurred
5266             */
5267            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
5268                    OrderByComparator orderByComparator)
5269                    throws NoSuchEntryException, SystemException {
5270                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
5271                                    orderByComparator);
5272    
5273                    if (blogsEntry != null) {
5274                            return blogsEntry;
5275                    }
5276    
5277                    StringBundler msg = new StringBundler(6);
5278    
5279                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5280    
5281                    msg.append("groupId=");
5282                    msg.append(groupId);
5283    
5284                    msg.append(", displayDate=");
5285                    msg.append(displayDate);
5286    
5287                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5288    
5289                    throw new NoSuchEntryException(msg.toString());
5290            }
5291    
5292            /**
5293             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5294             *
5295             * @param groupId the group ID
5296             * @param displayDate the display date
5297             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5298             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5299             * @throws SystemException if a system exception occurred
5300             */
5301            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
5302                    OrderByComparator orderByComparator) throws SystemException {
5303                    int count = countByG_LtD(groupId, displayDate);
5304    
5305                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
5306                                    count, orderByComparator);
5307    
5308                    if (!list.isEmpty()) {
5309                            return list.get(0);
5310                    }
5311    
5312                    return null;
5313            }
5314    
5315            /**
5316             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5317             *
5318             * @param entryId the primary key of the current blogs entry
5319             * @param groupId the group ID
5320             * @param displayDate the display date
5321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5322             * @return the previous, current, and next blogs entry
5323             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5324             * @throws SystemException if a system exception occurred
5325             */
5326            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
5327                    Date displayDate, OrderByComparator orderByComparator)
5328                    throws NoSuchEntryException, SystemException {
5329                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5330    
5331                    Session session = null;
5332    
5333                    try {
5334                            session = openSession();
5335    
5336                            BlogsEntry[] array = new BlogsEntryImpl[3];
5337    
5338                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5339                                            displayDate, orderByComparator, true);
5340    
5341                            array[1] = blogsEntry;
5342    
5343                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5344                                            displayDate, orderByComparator, false);
5345    
5346                            return array;
5347                    }
5348                    catch (Exception e) {
5349                            throw processException(e);
5350                    }
5351                    finally {
5352                            closeSession(session);
5353                    }
5354            }
5355    
5356            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
5357                    BlogsEntry blogsEntry, long groupId, Date displayDate,
5358                    OrderByComparator orderByComparator, boolean previous) {
5359                    StringBundler query = null;
5360    
5361                    if (orderByComparator != null) {
5362                            query = new StringBundler(6 +
5363                                            (orderByComparator.getOrderByFields().length * 6));
5364                    }
5365                    else {
5366                            query = new StringBundler(3);
5367                    }
5368    
5369                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5370    
5371                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5372    
5373                    if (displayDate == null) {
5374                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5375                    }
5376                    else {
5377                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5378                    }
5379    
5380                    if (orderByComparator != null) {
5381                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5382    
5383                            if (orderByConditionFields.length > 0) {
5384                                    query.append(WHERE_AND);
5385                            }
5386    
5387                            for (int i = 0; i < orderByConditionFields.length; i++) {
5388                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5389                                    query.append(orderByConditionFields[i]);
5390    
5391                                    if ((i + 1) < orderByConditionFields.length) {
5392                                            if (orderByComparator.isAscending() ^ previous) {
5393                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5394                                            }
5395                                            else {
5396                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5397                                            }
5398                                    }
5399                                    else {
5400                                            if (orderByComparator.isAscending() ^ previous) {
5401                                                    query.append(WHERE_GREATER_THAN);
5402                                            }
5403                                            else {
5404                                                    query.append(WHERE_LESSER_THAN);
5405                                            }
5406                                    }
5407                            }
5408    
5409                            query.append(ORDER_BY_CLAUSE);
5410    
5411                            String[] orderByFields = orderByComparator.getOrderByFields();
5412    
5413                            for (int i = 0; i < orderByFields.length; i++) {
5414                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5415                                    query.append(orderByFields[i]);
5416    
5417                                    if ((i + 1) < orderByFields.length) {
5418                                            if (orderByComparator.isAscending() ^ previous) {
5419                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5420                                            }
5421                                            else {
5422                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5423                                            }
5424                                    }
5425                                    else {
5426                                            if (orderByComparator.isAscending() ^ previous) {
5427                                                    query.append(ORDER_BY_ASC);
5428                                            }
5429                                            else {
5430                                                    query.append(ORDER_BY_DESC);
5431                                            }
5432                                    }
5433                            }
5434                    }
5435                    else {
5436                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5437                    }
5438    
5439                    String sql = query.toString();
5440    
5441                    Query q = session.createQuery(sql);
5442    
5443                    q.setFirstResult(0);
5444                    q.setMaxResults(2);
5445    
5446                    QueryPos qPos = QueryPos.getInstance(q);
5447    
5448                    qPos.add(groupId);
5449    
5450                    if (displayDate != null) {
5451                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5452                    }
5453    
5454                    if (orderByComparator != null) {
5455                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5456    
5457                            for (Object value : values) {
5458                                    qPos.add(value);
5459                            }
5460                    }
5461    
5462                    List<BlogsEntry> list = q.list();
5463    
5464                    if (list.size() == 2) {
5465                            return list.get(1);
5466                    }
5467                    else {
5468                            return null;
5469                    }
5470            }
5471    
5472            /**
5473             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5474             *
5475             * @param groupId the group ID
5476             * @param displayDate the display date
5477             * @return the matching blogs entries that the user has permission to view
5478             * @throws SystemException if a system exception occurred
5479             */
5480            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate)
5481                    throws SystemException {
5482                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5483                            QueryUtil.ALL_POS, null);
5484            }
5485    
5486            /**
5487             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5488             *
5489             * <p>
5490             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5491             * </p>
5492             *
5493             * @param groupId the group ID
5494             * @param displayDate the display date
5495             * @param start the lower bound of the range of blogs entries
5496             * @param end the upper bound of the range of blogs entries (not inclusive)
5497             * @return the range of matching blogs entries that the user has permission to view
5498             * @throws SystemException if a system exception occurred
5499             */
5500            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5501                    int start, int end) throws SystemException {
5502                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
5503            }
5504    
5505            /**
5506             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
5507             *
5508             * <p>
5509             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5510             * </p>
5511             *
5512             * @param groupId the group ID
5513             * @param displayDate the display date
5514             * @param start the lower bound of the range of blogs entries
5515             * @param end the upper bound of the range of blogs entries (not inclusive)
5516             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5517             * @return the ordered range of matching blogs entries that the user has permission to view
5518             * @throws SystemException if a system exception occurred
5519             */
5520            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5521                    int start, int end, OrderByComparator orderByComparator)
5522                    throws SystemException {
5523                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5524                            return findByG_LtD(groupId, displayDate, start, end,
5525                                    orderByComparator);
5526                    }
5527    
5528                    StringBundler query = null;
5529    
5530                    if (orderByComparator != null) {
5531                            query = new StringBundler(4 +
5532                                            (orderByComparator.getOrderByFields().length * 3));
5533                    }
5534                    else {
5535                            query = new StringBundler(4);
5536                    }
5537    
5538                    if (getDB().isSupportsInlineDistinct()) {
5539                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5540                    }
5541                    else {
5542                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5543                    }
5544    
5545                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5546    
5547                    if (displayDate == null) {
5548                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5549                    }
5550                    else {
5551                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5552                    }
5553    
5554                    if (!getDB().isSupportsInlineDistinct()) {
5555                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5556                    }
5557    
5558                    if (orderByComparator != null) {
5559                            if (getDB().isSupportsInlineDistinct()) {
5560                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5561                                            orderByComparator);
5562                            }
5563                            else {
5564                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5565                                            orderByComparator);
5566                            }
5567                    }
5568                    else {
5569                            if (getDB().isSupportsInlineDistinct()) {
5570                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5571                            }
5572                            else {
5573                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5574                            }
5575                    }
5576    
5577                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5578                                    BlogsEntry.class.getName(),
5579                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5580    
5581                    Session session = null;
5582    
5583                    try {
5584                            session = openSession();
5585    
5586                            SQLQuery q = session.createSQLQuery(sql);
5587    
5588                            if (getDB().isSupportsInlineDistinct()) {
5589                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5590                            }
5591                            else {
5592                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5593                            }
5594    
5595                            QueryPos qPos = QueryPos.getInstance(q);
5596    
5597                            qPos.add(groupId);
5598    
5599                            if (displayDate != null) {
5600                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
5601                            }
5602    
5603                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5604                    }
5605                    catch (Exception e) {
5606                            throw processException(e);
5607                    }
5608                    finally {
5609                            closeSession(session);
5610                    }
5611            }
5612    
5613            /**
5614             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5615             *
5616             * @param entryId the primary key of the current blogs entry
5617             * @param groupId the group ID
5618             * @param displayDate the display date
5619             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5620             * @return the previous, current, and next blogs entry
5621             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5622             * @throws SystemException if a system exception occurred
5623             */
5624            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
5625                    long groupId, Date displayDate, OrderByComparator orderByComparator)
5626                    throws NoSuchEntryException, SystemException {
5627                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5628                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
5629                                    orderByComparator);
5630                    }
5631    
5632                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5633    
5634                    Session session = null;
5635    
5636                    try {
5637                            session = openSession();
5638    
5639                            BlogsEntry[] array = new BlogsEntryImpl[3];
5640    
5641                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5642                                            groupId, displayDate, orderByComparator, true);
5643    
5644                            array[1] = blogsEntry;
5645    
5646                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5647                                            groupId, displayDate, orderByComparator, false);
5648    
5649                            return array;
5650                    }
5651                    catch (Exception e) {
5652                            throw processException(e);
5653                    }
5654                    finally {
5655                            closeSession(session);
5656                    }
5657            }
5658    
5659            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
5660                    BlogsEntry blogsEntry, long groupId, Date displayDate,
5661                    OrderByComparator orderByComparator, boolean previous) {
5662                    StringBundler query = null;
5663    
5664                    if (orderByComparator != null) {
5665                            query = new StringBundler(6 +
5666                                            (orderByComparator.getOrderByFields().length * 6));
5667                    }
5668                    else {
5669                            query = new StringBundler(3);
5670                    }
5671    
5672                    if (getDB().isSupportsInlineDistinct()) {
5673                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5674                    }
5675                    else {
5676                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5677                    }
5678    
5679                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5680    
5681                    if (displayDate == null) {
5682                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5683                    }
5684                    else {
5685                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5686                    }
5687    
5688                    if (!getDB().isSupportsInlineDistinct()) {
5689                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5690                    }
5691    
5692                    if (orderByComparator != null) {
5693                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5694    
5695                            if (orderByConditionFields.length > 0) {
5696                                    query.append(WHERE_AND);
5697                            }
5698    
5699                            for (int i = 0; i < orderByConditionFields.length; i++) {
5700                                    if (getDB().isSupportsInlineDistinct()) {
5701                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5702                                    }
5703                                    else {
5704                                            query.append(_ORDER_BY_ENTITY_TABLE);
5705                                    }
5706    
5707                                    query.append(orderByConditionFields[i]);
5708    
5709                                    if ((i + 1) < orderByConditionFields.length) {
5710                                            if (orderByComparator.isAscending() ^ previous) {
5711                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5712                                            }
5713                                            else {
5714                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5715                                            }
5716                                    }
5717                                    else {
5718                                            if (orderByComparator.isAscending() ^ previous) {
5719                                                    query.append(WHERE_GREATER_THAN);
5720                                            }
5721                                            else {
5722                                                    query.append(WHERE_LESSER_THAN);
5723                                            }
5724                                    }
5725                            }
5726    
5727                            query.append(ORDER_BY_CLAUSE);
5728    
5729                            String[] orderByFields = orderByComparator.getOrderByFields();
5730    
5731                            for (int i = 0; i < orderByFields.length; i++) {
5732                                    if (getDB().isSupportsInlineDistinct()) {
5733                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5734                                    }
5735                                    else {
5736                                            query.append(_ORDER_BY_ENTITY_TABLE);
5737                                    }
5738    
5739                                    query.append(orderByFields[i]);
5740    
5741                                    if ((i + 1) < orderByFields.length) {
5742                                            if (orderByComparator.isAscending() ^ previous) {
5743                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5744                                            }
5745                                            else {
5746                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5747                                            }
5748                                    }
5749                                    else {
5750                                            if (orderByComparator.isAscending() ^ previous) {
5751                                                    query.append(ORDER_BY_ASC);
5752                                            }
5753                                            else {
5754                                                    query.append(ORDER_BY_DESC);
5755                                            }
5756                                    }
5757                            }
5758                    }
5759                    else {
5760                            if (getDB().isSupportsInlineDistinct()) {
5761                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5762                            }
5763                            else {
5764                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5765                            }
5766                    }
5767    
5768                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5769                                    BlogsEntry.class.getName(),
5770                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5771    
5772                    SQLQuery q = session.createSQLQuery(sql);
5773    
5774                    q.setFirstResult(0);
5775                    q.setMaxResults(2);
5776    
5777                    if (getDB().isSupportsInlineDistinct()) {
5778                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5779                    }
5780                    else {
5781                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5782                    }
5783    
5784                    QueryPos qPos = QueryPos.getInstance(q);
5785    
5786                    qPos.add(groupId);
5787    
5788                    if (displayDate != null) {
5789                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5790                    }
5791    
5792                    if (orderByComparator != null) {
5793                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5794    
5795                            for (Object value : values) {
5796                                    qPos.add(value);
5797                            }
5798                    }
5799    
5800                    List<BlogsEntry> list = q.list();
5801    
5802                    if (list.size() == 2) {
5803                            return list.get(1);
5804                    }
5805                    else {
5806                            return null;
5807                    }
5808            }
5809    
5810            /**
5811             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
5812             *
5813             * @param groupId the group ID
5814             * @param displayDate the display date
5815             * @throws SystemException if a system exception occurred
5816             */
5817            public void removeByG_LtD(long groupId, Date displayDate)
5818                    throws SystemException {
5819                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
5820                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5821                            remove(blogsEntry);
5822                    }
5823            }
5824    
5825            /**
5826             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5827             *
5828             * @param groupId the group ID
5829             * @param displayDate the display date
5830             * @return the number of matching blogs entries
5831             * @throws SystemException if a system exception occurred
5832             */
5833            public int countByG_LtD(long groupId, Date displayDate)
5834                    throws SystemException {
5835                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
5836    
5837                    Object[] finderArgs = new Object[] { groupId, displayDate };
5838    
5839                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5840                                    this);
5841    
5842                    if (count == null) {
5843                            StringBundler query = new StringBundler(3);
5844    
5845                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5846    
5847                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5848    
5849                            if (displayDate == null) {
5850                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5851                            }
5852                            else {
5853                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5854                            }
5855    
5856                            String sql = query.toString();
5857    
5858                            Session session = null;
5859    
5860                            try {
5861                                    session = openSession();
5862    
5863                                    Query q = session.createQuery(sql);
5864    
5865                                    QueryPos qPos = QueryPos.getInstance(q);
5866    
5867                                    qPos.add(groupId);
5868    
5869                                    if (displayDate != null) {
5870                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5871                                    }
5872    
5873                                    count = (Long)q.uniqueResult();
5874    
5875                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5876                            }
5877                            catch (Exception e) {
5878                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5879    
5880                                    throw processException(e);
5881                            }
5882                            finally {
5883                                    closeSession(session);
5884                            }
5885                    }
5886    
5887                    return count.intValue();
5888            }
5889    
5890            /**
5891             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5892             *
5893             * @param groupId the group ID
5894             * @param displayDate the display date
5895             * @return the number of matching blogs entries that the user has permission to view
5896             * @throws SystemException if a system exception occurred
5897             */
5898            public int filterCountByG_LtD(long groupId, Date displayDate)
5899                    throws SystemException {
5900                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5901                            return countByG_LtD(groupId, displayDate);
5902                    }
5903    
5904                    StringBundler query = new StringBundler(3);
5905    
5906                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5907    
5908                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5909    
5910                    if (displayDate == null) {
5911                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5912                    }
5913                    else {
5914                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5915                    }
5916    
5917                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5918                                    BlogsEntry.class.getName(),
5919                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5920    
5921                    Session session = null;
5922    
5923                    try {
5924                            session = openSession();
5925    
5926                            SQLQuery q = session.createSQLQuery(sql);
5927    
5928                            q.addScalar(COUNT_COLUMN_NAME,
5929                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5930    
5931                            QueryPos qPos = QueryPos.getInstance(q);
5932    
5933                            qPos.add(groupId);
5934    
5935                            if (displayDate != null) {
5936                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
5937                            }
5938    
5939                            Long count = (Long)q.uniqueResult();
5940    
5941                            return count.intValue();
5942                    }
5943                    catch (Exception e) {
5944                            throw processException(e);
5945                    }
5946                    finally {
5947                            closeSession(session);
5948                    }
5949            }
5950    
5951            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5952            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
5953            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
5954            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5955                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5956                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
5957                            new String[] {
5958                                    Long.class.getName(), Integer.class.getName(),
5959                                    
5960                            Integer.class.getName(), Integer.class.getName(),
5961                                    OrderByComparator.class.getName()
5962                            });
5963            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5964                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5965                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
5966                            new String[] { Long.class.getName(), Integer.class.getName() });
5967    
5968            /**
5969             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5970             *
5971             * @param groupId the group ID
5972             * @param status the status
5973             * @return the matching blogs entries
5974             * @throws SystemException if a system exception occurred
5975             */
5976            public List<BlogsEntry> findByG_NotS(long groupId, int status)
5977                    throws SystemException {
5978                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
5979                            QueryUtil.ALL_POS, null);
5980            }
5981    
5982            /**
5983             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5984             *
5985             * <p>
5986             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5987             * </p>
5988             *
5989             * @param groupId the group ID
5990             * @param status the status
5991             * @param start the lower bound of the range of blogs entries
5992             * @param end the upper bound of the range of blogs entries (not inclusive)
5993             * @return the range of matching blogs entries
5994             * @throws SystemException if a system exception occurred
5995             */
5996            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5997                    int end) throws SystemException {
5998                    return findByG_NotS(groupId, status, start, end, null);
5999            }
6000    
6001            /**
6002             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
6003             *
6004             * <p>
6005             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6006             * </p>
6007             *
6008             * @param groupId the group ID
6009             * @param status the status
6010             * @param start the lower bound of the range of blogs entries
6011             * @param end the upper bound of the range of blogs entries (not inclusive)
6012             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6013             * @return the ordered range of matching blogs entries
6014             * @throws SystemException if a system exception occurred
6015             */
6016            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
6017                    int end, OrderByComparator orderByComparator) throws SystemException {
6018                    boolean pagination = true;
6019                    FinderPath finderPath = null;
6020                    Object[] finderArgs = null;
6021    
6022                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
6023                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
6024    
6025                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6026                                    finderArgs, this);
6027    
6028                    if ((list != null) && !list.isEmpty()) {
6029                            for (BlogsEntry blogsEntry : list) {
6030                                    if ((groupId != blogsEntry.getGroupId()) ||
6031                                                    (status != blogsEntry.getStatus())) {
6032                                            list = null;
6033    
6034                                            break;
6035                                    }
6036                            }
6037                    }
6038    
6039                    if (list == null) {
6040                            StringBundler query = null;
6041    
6042                            if (orderByComparator != null) {
6043                                    query = new StringBundler(4 +
6044                                                    (orderByComparator.getOrderByFields().length * 3));
6045                            }
6046                            else {
6047                                    query = new StringBundler(4);
6048                            }
6049    
6050                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6051    
6052                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6053    
6054                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6055    
6056                            if (orderByComparator != null) {
6057                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6058                                            orderByComparator);
6059                            }
6060                            else
6061                             if (pagination) {
6062                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6063                            }
6064    
6065                            String sql = query.toString();
6066    
6067                            Session session = null;
6068    
6069                            try {
6070                                    session = openSession();
6071    
6072                                    Query q = session.createQuery(sql);
6073    
6074                                    QueryPos qPos = QueryPos.getInstance(q);
6075    
6076                                    qPos.add(groupId);
6077    
6078                                    qPos.add(status);
6079    
6080                                    if (!pagination) {
6081                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6082                                                            start, end, false);
6083    
6084                                            Collections.sort(list);
6085    
6086                                            list = new UnmodifiableList<BlogsEntry>(list);
6087                                    }
6088                                    else {
6089                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6090                                                            start, end);
6091                                    }
6092    
6093                                    cacheResult(list);
6094    
6095                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6096                            }
6097                            catch (Exception e) {
6098                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6099    
6100                                    throw processException(e);
6101                            }
6102                            finally {
6103                                    closeSession(session);
6104                            }
6105                    }
6106    
6107                    return list;
6108            }
6109    
6110            /**
6111             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6112             *
6113             * @param groupId the group ID
6114             * @param status the status
6115             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6116             * @return the first matching blogs entry
6117             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6118             * @throws SystemException if a system exception occurred
6119             */
6120            public BlogsEntry findByG_NotS_First(long groupId, int status,
6121                    OrderByComparator orderByComparator)
6122                    throws NoSuchEntryException, SystemException {
6123                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
6124                                    orderByComparator);
6125    
6126                    if (blogsEntry != null) {
6127                            return blogsEntry;
6128                    }
6129    
6130                    StringBundler msg = new StringBundler(6);
6131    
6132                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6133    
6134                    msg.append("groupId=");
6135                    msg.append(groupId);
6136    
6137                    msg.append(", status=");
6138                    msg.append(status);
6139    
6140                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6141    
6142                    throw new NoSuchEntryException(msg.toString());
6143            }
6144    
6145            /**
6146             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6147             *
6148             * @param groupId the group ID
6149             * @param status the status
6150             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6151             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6152             * @throws SystemException if a system exception occurred
6153             */
6154            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
6155                    OrderByComparator orderByComparator) throws SystemException {
6156                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
6157                                    orderByComparator);
6158    
6159                    if (!list.isEmpty()) {
6160                            return list.get(0);
6161                    }
6162    
6163                    return null;
6164            }
6165    
6166            /**
6167             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6168             *
6169             * @param groupId the group ID
6170             * @param status the status
6171             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6172             * @return the last matching blogs entry
6173             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6174             * @throws SystemException if a system exception occurred
6175             */
6176            public BlogsEntry findByG_NotS_Last(long groupId, int status,
6177                    OrderByComparator orderByComparator)
6178                    throws NoSuchEntryException, SystemException {
6179                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
6180                                    orderByComparator);
6181    
6182                    if (blogsEntry != null) {
6183                            return blogsEntry;
6184                    }
6185    
6186                    StringBundler msg = new StringBundler(6);
6187    
6188                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6189    
6190                    msg.append("groupId=");
6191                    msg.append(groupId);
6192    
6193                    msg.append(", status=");
6194                    msg.append(status);
6195    
6196                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6197    
6198                    throw new NoSuchEntryException(msg.toString());
6199            }
6200    
6201            /**
6202             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6203             *
6204             * @param groupId the group ID
6205             * @param status the status
6206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6207             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6208             * @throws SystemException if a system exception occurred
6209             */
6210            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
6211                    OrderByComparator orderByComparator) throws SystemException {
6212                    int count = countByG_NotS(groupId, status);
6213    
6214                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
6215                                    orderByComparator);
6216    
6217                    if (!list.isEmpty()) {
6218                            return list.get(0);
6219                    }
6220    
6221                    return null;
6222            }
6223    
6224            /**
6225             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6226             *
6227             * @param entryId the primary key of the current blogs entry
6228             * @param groupId the group ID
6229             * @param status the status
6230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6231             * @return the previous, current, and next blogs entry
6232             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6233             * @throws SystemException if a system exception occurred
6234             */
6235            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
6236                    int status, OrderByComparator orderByComparator)
6237                    throws NoSuchEntryException, SystemException {
6238                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6239    
6240                    Session session = null;
6241    
6242                    try {
6243                            session = openSession();
6244    
6245                            BlogsEntry[] array = new BlogsEntryImpl[3];
6246    
6247                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
6248                                            status, orderByComparator, true);
6249    
6250                            array[1] = blogsEntry;
6251    
6252                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
6253                                            status, orderByComparator, false);
6254    
6255                            return array;
6256                    }
6257                    catch (Exception e) {
6258                            throw processException(e);
6259                    }
6260                    finally {
6261                            closeSession(session);
6262                    }
6263            }
6264    
6265            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
6266                    BlogsEntry blogsEntry, long groupId, int status,
6267                    OrderByComparator orderByComparator, boolean previous) {
6268                    StringBundler query = null;
6269    
6270                    if (orderByComparator != null) {
6271                            query = new StringBundler(6 +
6272                                            (orderByComparator.getOrderByFields().length * 6));
6273                    }
6274                    else {
6275                            query = new StringBundler(3);
6276                    }
6277    
6278                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6279    
6280                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6281    
6282                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6283    
6284                    if (orderByComparator != null) {
6285                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6286    
6287                            if (orderByConditionFields.length > 0) {
6288                                    query.append(WHERE_AND);
6289                            }
6290    
6291                            for (int i = 0; i < orderByConditionFields.length; i++) {
6292                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6293                                    query.append(orderByConditionFields[i]);
6294    
6295                                    if ((i + 1) < orderByConditionFields.length) {
6296                                            if (orderByComparator.isAscending() ^ previous) {
6297                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6298                                            }
6299                                            else {
6300                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6301                                            }
6302                                    }
6303                                    else {
6304                                            if (orderByComparator.isAscending() ^ previous) {
6305                                                    query.append(WHERE_GREATER_THAN);
6306                                            }
6307                                            else {
6308                                                    query.append(WHERE_LESSER_THAN);
6309                                            }
6310                                    }
6311                            }
6312    
6313                            query.append(ORDER_BY_CLAUSE);
6314    
6315                            String[] orderByFields = orderByComparator.getOrderByFields();
6316    
6317                            for (int i = 0; i < orderByFields.length; i++) {
6318                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6319                                    query.append(orderByFields[i]);
6320    
6321                                    if ((i + 1) < orderByFields.length) {
6322                                            if (orderByComparator.isAscending() ^ previous) {
6323                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6324                                            }
6325                                            else {
6326                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6327                                            }
6328                                    }
6329                                    else {
6330                                            if (orderByComparator.isAscending() ^ previous) {
6331                                                    query.append(ORDER_BY_ASC);
6332                                            }
6333                                            else {
6334                                                    query.append(ORDER_BY_DESC);
6335                                            }
6336                                    }
6337                            }
6338                    }
6339                    else {
6340                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6341                    }
6342    
6343                    String sql = query.toString();
6344    
6345                    Query q = session.createQuery(sql);
6346    
6347                    q.setFirstResult(0);
6348                    q.setMaxResults(2);
6349    
6350                    QueryPos qPos = QueryPos.getInstance(q);
6351    
6352                    qPos.add(groupId);
6353    
6354                    qPos.add(status);
6355    
6356                    if (orderByComparator != null) {
6357                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6358    
6359                            for (Object value : values) {
6360                                    qPos.add(value);
6361                            }
6362                    }
6363    
6364                    List<BlogsEntry> list = q.list();
6365    
6366                    if (list.size() == 2) {
6367                            return list.get(1);
6368                    }
6369                    else {
6370                            return null;
6371                    }
6372            }
6373    
6374            /**
6375             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6376             *
6377             * @param groupId the group ID
6378             * @param status the status
6379             * @return the matching blogs entries that the user has permission to view
6380             * @throws SystemException if a system exception occurred
6381             */
6382            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status)
6383                    throws SystemException {
6384                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
6385                            QueryUtil.ALL_POS, null);
6386            }
6387    
6388            /**
6389             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6390             *
6391             * <p>
6392             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6393             * </p>
6394             *
6395             * @param groupId the group ID
6396             * @param status the status
6397             * @param start the lower bound of the range of blogs entries
6398             * @param end the upper bound of the range of blogs entries (not inclusive)
6399             * @return the range of matching blogs entries that the user has permission to view
6400             * @throws SystemException if a system exception occurred
6401             */
6402            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
6403                    int start, int end) throws SystemException {
6404                    return filterFindByG_NotS(groupId, status, start, end, null);
6405            }
6406    
6407            /**
6408             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
6409             *
6410             * <p>
6411             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6412             * </p>
6413             *
6414             * @param groupId the group ID
6415             * @param status the status
6416             * @param start the lower bound of the range of blogs entries
6417             * @param end the upper bound of the range of blogs entries (not inclusive)
6418             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6419             * @return the ordered range of matching blogs entries that the user has permission to view
6420             * @throws SystemException if a system exception occurred
6421             */
6422            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
6423                    int start, int end, OrderByComparator orderByComparator)
6424                    throws SystemException {
6425                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6426                            return findByG_NotS(groupId, status, start, end, orderByComparator);
6427                    }
6428    
6429                    StringBundler query = null;
6430    
6431                    if (orderByComparator != null) {
6432                            query = new StringBundler(4 +
6433                                            (orderByComparator.getOrderByFields().length * 3));
6434                    }
6435                    else {
6436                            query = new StringBundler(4);
6437                    }
6438    
6439                    if (getDB().isSupportsInlineDistinct()) {
6440                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6441                    }
6442                    else {
6443                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6444                    }
6445    
6446                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6447    
6448                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6449    
6450                    if (!getDB().isSupportsInlineDistinct()) {
6451                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6452                    }
6453    
6454                    if (orderByComparator != null) {
6455                            if (getDB().isSupportsInlineDistinct()) {
6456                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6457                                            orderByComparator);
6458                            }
6459                            else {
6460                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6461                                            orderByComparator);
6462                            }
6463                    }
6464                    else {
6465                            if (getDB().isSupportsInlineDistinct()) {
6466                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6467                            }
6468                            else {
6469                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6470                            }
6471                    }
6472    
6473                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6474                                    BlogsEntry.class.getName(),
6475                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6476    
6477                    Session session = null;
6478    
6479                    try {
6480                            session = openSession();
6481    
6482                            SQLQuery q = session.createSQLQuery(sql);
6483    
6484                            if (getDB().isSupportsInlineDistinct()) {
6485                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6486                            }
6487                            else {
6488                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6489                            }
6490    
6491                            QueryPos qPos = QueryPos.getInstance(q);
6492    
6493                            qPos.add(groupId);
6494    
6495                            qPos.add(status);
6496    
6497                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
6498                    }
6499                    catch (Exception e) {
6500                            throw processException(e);
6501                    }
6502                    finally {
6503                            closeSession(session);
6504                    }
6505            }
6506    
6507            /**
6508             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6509             *
6510             * @param entryId the primary key of the current blogs entry
6511             * @param groupId the group ID
6512             * @param status the status
6513             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6514             * @return the previous, current, and next blogs entry
6515             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6516             * @throws SystemException if a system exception occurred
6517             */
6518            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
6519                    long groupId, int status, OrderByComparator orderByComparator)
6520                    throws NoSuchEntryException, SystemException {
6521                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6522                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
6523                                    orderByComparator);
6524                    }
6525    
6526                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6527    
6528                    Session session = null;
6529    
6530                    try {
6531                            session = openSession();
6532    
6533                            BlogsEntry[] array = new BlogsEntryImpl[3];
6534    
6535                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
6536                                            groupId, status, orderByComparator, true);
6537    
6538                            array[1] = blogsEntry;
6539    
6540                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
6541                                            groupId, status, orderByComparator, false);
6542    
6543                            return array;
6544                    }
6545                    catch (Exception e) {
6546                            throw processException(e);
6547                    }
6548                    finally {
6549                            closeSession(session);
6550                    }
6551            }
6552    
6553            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
6554                    BlogsEntry blogsEntry, long groupId, int status,
6555                    OrderByComparator orderByComparator, boolean previous) {
6556                    StringBundler query = null;
6557    
6558                    if (orderByComparator != null) {
6559                            query = new StringBundler(6 +
6560                                            (orderByComparator.getOrderByFields().length * 6));
6561                    }
6562                    else {
6563                            query = new StringBundler(3);
6564                    }
6565    
6566                    if (getDB().isSupportsInlineDistinct()) {
6567                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6568                    }
6569                    else {
6570                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6571                    }
6572    
6573                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6574    
6575                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6576    
6577                    if (!getDB().isSupportsInlineDistinct()) {
6578                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6579                    }
6580    
6581                    if (orderByComparator != null) {
6582                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6583    
6584                            if (orderByConditionFields.length > 0) {
6585                                    query.append(WHERE_AND);
6586                            }
6587    
6588                            for (int i = 0; i < orderByConditionFields.length; i++) {
6589                                    if (getDB().isSupportsInlineDistinct()) {
6590                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6591                                    }
6592                                    else {
6593                                            query.append(_ORDER_BY_ENTITY_TABLE);
6594                                    }
6595    
6596                                    query.append(orderByConditionFields[i]);
6597    
6598                                    if ((i + 1) < orderByConditionFields.length) {
6599                                            if (orderByComparator.isAscending() ^ previous) {
6600                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6601                                            }
6602                                            else {
6603                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6604                                            }
6605                                    }
6606                                    else {
6607                                            if (orderByComparator.isAscending() ^ previous) {
6608                                                    query.append(WHERE_GREATER_THAN);
6609                                            }
6610                                            else {
6611                                                    query.append(WHERE_LESSER_THAN);
6612                                            }
6613                                    }
6614                            }
6615    
6616                            query.append(ORDER_BY_CLAUSE);
6617    
6618                            String[] orderByFields = orderByComparator.getOrderByFields();
6619    
6620                            for (int i = 0; i < orderByFields.length; i++) {
6621                                    if (getDB().isSupportsInlineDistinct()) {
6622                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6623                                    }
6624                                    else {
6625                                            query.append(_ORDER_BY_ENTITY_TABLE);
6626                                    }
6627    
6628                                    query.append(orderByFields[i]);
6629    
6630                                    if ((i + 1) < orderByFields.length) {
6631                                            if (orderByComparator.isAscending() ^ previous) {
6632                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6633                                            }
6634                                            else {
6635                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6636                                            }
6637                                    }
6638                                    else {
6639                                            if (orderByComparator.isAscending() ^ previous) {
6640                                                    query.append(ORDER_BY_ASC);
6641                                            }
6642                                            else {
6643                                                    query.append(ORDER_BY_DESC);
6644                                            }
6645                                    }
6646                            }
6647                    }
6648                    else {
6649                            if (getDB().isSupportsInlineDistinct()) {
6650                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6651                            }
6652                            else {
6653                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6654                            }
6655                    }
6656    
6657                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6658                                    BlogsEntry.class.getName(),
6659                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6660    
6661                    SQLQuery q = session.createSQLQuery(sql);
6662    
6663                    q.setFirstResult(0);
6664                    q.setMaxResults(2);
6665    
6666                    if (getDB().isSupportsInlineDistinct()) {
6667                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6668                    }
6669                    else {
6670                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6671                    }
6672    
6673                    QueryPos qPos = QueryPos.getInstance(q);
6674    
6675                    qPos.add(groupId);
6676    
6677                    qPos.add(status);
6678    
6679                    if (orderByComparator != null) {
6680                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6681    
6682                            for (Object value : values) {
6683                                    qPos.add(value);
6684                            }
6685                    }
6686    
6687                    List<BlogsEntry> list = q.list();
6688    
6689                    if (list.size() == 2) {
6690                            return list.get(1);
6691                    }
6692                    else {
6693                            return null;
6694                    }
6695            }
6696    
6697            /**
6698             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
6699             *
6700             * @param groupId the group ID
6701             * @param status the status
6702             * @throws SystemException if a system exception occurred
6703             */
6704            public void removeByG_NotS(long groupId, int status)
6705                    throws SystemException {
6706                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
6707                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6708                            remove(blogsEntry);
6709                    }
6710            }
6711    
6712            /**
6713             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
6714             *
6715             * @param groupId the group ID
6716             * @param status the status
6717             * @return the number of matching blogs entries
6718             * @throws SystemException if a system exception occurred
6719             */
6720            public int countByG_NotS(long groupId, int status)
6721                    throws SystemException {
6722                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
6723    
6724                    Object[] finderArgs = new Object[] { groupId, status };
6725    
6726                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6727                                    this);
6728    
6729                    if (count == null) {
6730                            StringBundler query = new StringBundler(3);
6731    
6732                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6733    
6734                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6735    
6736                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6737    
6738                            String sql = query.toString();
6739    
6740                            Session session = null;
6741    
6742                            try {
6743                                    session = openSession();
6744    
6745                                    Query q = session.createQuery(sql);
6746    
6747                                    QueryPos qPos = QueryPos.getInstance(q);
6748    
6749                                    qPos.add(groupId);
6750    
6751                                    qPos.add(status);
6752    
6753                                    count = (Long)q.uniqueResult();
6754    
6755                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6756                            }
6757                            catch (Exception e) {
6758                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6759    
6760                                    throw processException(e);
6761                            }
6762                            finally {
6763                                    closeSession(session);
6764                            }
6765                    }
6766    
6767                    return count.intValue();
6768            }
6769    
6770            /**
6771             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6772             *
6773             * @param groupId the group ID
6774             * @param status the status
6775             * @return the number of matching blogs entries that the user has permission to view
6776             * @throws SystemException if a system exception occurred
6777             */
6778            public int filterCountByG_NotS(long groupId, int status)
6779                    throws SystemException {
6780                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6781                            return countByG_NotS(groupId, status);
6782                    }
6783    
6784                    StringBundler query = new StringBundler(3);
6785    
6786                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
6787    
6788                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6789    
6790                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6791    
6792                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6793                                    BlogsEntry.class.getName(),
6794                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6795    
6796                    Session session = null;
6797    
6798                    try {
6799                            session = openSession();
6800    
6801                            SQLQuery q = session.createSQLQuery(sql);
6802    
6803                            q.addScalar(COUNT_COLUMN_NAME,
6804                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6805    
6806                            QueryPos qPos = QueryPos.getInstance(q);
6807    
6808                            qPos.add(groupId);
6809    
6810                            qPos.add(status);
6811    
6812                            Long count = (Long)q.uniqueResult();
6813    
6814                            return count.intValue();
6815                    }
6816                    catch (Exception e) {
6817                            throw processException(e);
6818                    }
6819                    finally {
6820                            closeSession(session);
6821                    }
6822            }
6823    
6824            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
6825            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
6826            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6827                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6828                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
6829                            new String[] {
6830                                    Long.class.getName(), Integer.class.getName(),
6831                                    
6832                            Integer.class.getName(), Integer.class.getName(),
6833                                    OrderByComparator.class.getName()
6834                            });
6835            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6836                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6837                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
6838                            new String[] { Long.class.getName(), Integer.class.getName() },
6839                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
6840                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
6841                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
6842                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
6843            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6844                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6845                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
6846                            new String[] { Long.class.getName(), Integer.class.getName() });
6847    
6848            /**
6849             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
6850             *
6851             * @param groupId the group ID
6852             * @param status the status
6853             * @return the matching blogs entries
6854             * @throws SystemException if a system exception occurred
6855             */
6856            public List<BlogsEntry> findByG_S(long groupId, int status)
6857                    throws SystemException {
6858                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6859                            null);
6860            }
6861    
6862            /**
6863             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
6864             *
6865             * <p>
6866             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6867             * </p>
6868             *
6869             * @param groupId the group ID
6870             * @param status the status
6871             * @param start the lower bound of the range of blogs entries
6872             * @param end the upper bound of the range of blogs entries (not inclusive)
6873             * @return the range of matching blogs entries
6874             * @throws SystemException if a system exception occurred
6875             */
6876            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
6877                    int end) throws SystemException {
6878                    return findByG_S(groupId, status, start, end, null);
6879            }
6880    
6881            /**
6882             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
6883             *
6884             * <p>
6885             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6886             * </p>
6887             *
6888             * @param groupId the group ID
6889             * @param status the status
6890             * @param start the lower bound of the range of blogs entries
6891             * @param end the upper bound of the range of blogs entries (not inclusive)
6892             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6893             * @return the ordered range of matching blogs entries
6894             * @throws SystemException if a system exception occurred
6895             */
6896            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
6897                    int end, OrderByComparator orderByComparator) throws SystemException {
6898                    boolean pagination = true;
6899                    FinderPath finderPath = null;
6900                    Object[] finderArgs = null;
6901    
6902                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6903                                    (orderByComparator == null)) {
6904                            pagination = false;
6905                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
6906                            finderArgs = new Object[] { groupId, status };
6907                    }
6908                    else {
6909                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
6910                            finderArgs = new Object[] {
6911                                            groupId, status,
6912                                            
6913                                            start, end, orderByComparator
6914                                    };
6915                    }
6916    
6917                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6918                                    finderArgs, this);
6919    
6920                    if ((list != null) && !list.isEmpty()) {
6921                            for (BlogsEntry blogsEntry : list) {
6922                                    if ((groupId != blogsEntry.getGroupId()) ||
6923                                                    (status != blogsEntry.getStatus())) {
6924                                            list = null;
6925    
6926                                            break;
6927                                    }
6928                            }
6929                    }
6930    
6931                    if (list == null) {
6932                            StringBundler query = null;
6933    
6934                            if (orderByComparator != null) {
6935                                    query = new StringBundler(4 +
6936                                                    (orderByComparator.getOrderByFields().length * 3));
6937                            }
6938                            else {
6939                                    query = new StringBundler(4);
6940                            }
6941    
6942                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6943    
6944                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
6945    
6946                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
6947    
6948                            if (orderByComparator != null) {
6949                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6950                                            orderByComparator);
6951                            }
6952                            else
6953                             if (pagination) {
6954                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6955                            }
6956    
6957                            String sql = query.toString();
6958    
6959                            Session session = null;
6960    
6961                            try {
6962                                    session = openSession();
6963    
6964                                    Query q = session.createQuery(sql);
6965    
6966                                    QueryPos qPos = QueryPos.getInstance(q);
6967    
6968                                    qPos.add(groupId);
6969    
6970                                    qPos.add(status);
6971    
6972                                    if (!pagination) {
6973                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6974                                                            start, end, false);
6975    
6976                                            Collections.sort(list);
6977    
6978                                            list = new UnmodifiableList<BlogsEntry>(list);
6979                                    }
6980                                    else {
6981                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6982                                                            start, end);
6983                                    }
6984    
6985                                    cacheResult(list);
6986    
6987                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6988                            }
6989                            catch (Exception e) {
6990                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6991    
6992                                    throw processException(e);
6993                            }
6994                            finally {
6995                                    closeSession(session);
6996                            }
6997                    }
6998    
6999                    return list;
7000            }
7001    
7002            /**
7003             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7004             *
7005             * @param groupId the group ID
7006             * @param status the status
7007             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7008             * @return the first matching blogs entry
7009             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7010             * @throws SystemException if a system exception occurred
7011             */
7012            public BlogsEntry findByG_S_First(long groupId, int status,
7013                    OrderByComparator orderByComparator)
7014                    throws NoSuchEntryException, SystemException {
7015                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
7016                                    orderByComparator);
7017    
7018                    if (blogsEntry != null) {
7019                            return blogsEntry;
7020                    }
7021    
7022                    StringBundler msg = new StringBundler(6);
7023    
7024                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7025    
7026                    msg.append("groupId=");
7027                    msg.append(groupId);
7028    
7029                    msg.append(", status=");
7030                    msg.append(status);
7031    
7032                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7033    
7034                    throw new NoSuchEntryException(msg.toString());
7035            }
7036    
7037            /**
7038             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7039             *
7040             * @param groupId the group ID
7041             * @param status the status
7042             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7043             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7044             * @throws SystemException if a system exception occurred
7045             */
7046            public BlogsEntry fetchByG_S_First(long groupId, int status,
7047                    OrderByComparator orderByComparator) throws SystemException {
7048                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
7049                                    orderByComparator);
7050    
7051                    if (!list.isEmpty()) {
7052                            return list.get(0);
7053                    }
7054    
7055                    return null;
7056            }
7057    
7058            /**
7059             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7060             *
7061             * @param groupId the group ID
7062             * @param status the status
7063             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7064             * @return the last matching blogs entry
7065             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7066             * @throws SystemException if a system exception occurred
7067             */
7068            public BlogsEntry findByG_S_Last(long groupId, int status,
7069                    OrderByComparator orderByComparator)
7070                    throws NoSuchEntryException, SystemException {
7071                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
7072                                    orderByComparator);
7073    
7074                    if (blogsEntry != null) {
7075                            return blogsEntry;
7076                    }
7077    
7078                    StringBundler msg = new StringBundler(6);
7079    
7080                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7081    
7082                    msg.append("groupId=");
7083                    msg.append(groupId);
7084    
7085                    msg.append(", status=");
7086                    msg.append(status);
7087    
7088                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7089    
7090                    throw new NoSuchEntryException(msg.toString());
7091            }
7092    
7093            /**
7094             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7095             *
7096             * @param groupId the group ID
7097             * @param status the status
7098             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7099             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7100             * @throws SystemException if a system exception occurred
7101             */
7102            public BlogsEntry fetchByG_S_Last(long groupId, int status,
7103                    OrderByComparator orderByComparator) throws SystemException {
7104                    int count = countByG_S(groupId, status);
7105    
7106                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
7107                                    orderByComparator);
7108    
7109                    if (!list.isEmpty()) {
7110                            return list.get(0);
7111                    }
7112    
7113                    return null;
7114            }
7115    
7116            /**
7117             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7118             *
7119             * @param entryId the primary key of the current blogs entry
7120             * @param groupId the group ID
7121             * @param status the status
7122             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7123             * @return the previous, current, and next blogs entry
7124             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7125             * @throws SystemException if a system exception occurred
7126             */
7127            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
7128                    int status, OrderByComparator orderByComparator)
7129                    throws NoSuchEntryException, SystemException {
7130                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7131    
7132                    Session session = null;
7133    
7134                    try {
7135                            session = openSession();
7136    
7137                            BlogsEntry[] array = new BlogsEntryImpl[3];
7138    
7139                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
7140                                            status, orderByComparator, true);
7141    
7142                            array[1] = blogsEntry;
7143    
7144                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
7145                                            status, orderByComparator, false);
7146    
7147                            return array;
7148                    }
7149                    catch (Exception e) {
7150                            throw processException(e);
7151                    }
7152                    finally {
7153                            closeSession(session);
7154                    }
7155            }
7156    
7157            protected BlogsEntry getByG_S_PrevAndNext(Session session,
7158                    BlogsEntry blogsEntry, long groupId, int status,
7159                    OrderByComparator orderByComparator, boolean previous) {
7160                    StringBundler query = null;
7161    
7162                    if (orderByComparator != null) {
7163                            query = new StringBundler(6 +
7164                                            (orderByComparator.getOrderByFields().length * 6));
7165                    }
7166                    else {
7167                            query = new StringBundler(3);
7168                    }
7169    
7170                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7171    
7172                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7173    
7174                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7175    
7176                    if (orderByComparator != null) {
7177                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7178    
7179                            if (orderByConditionFields.length > 0) {
7180                                    query.append(WHERE_AND);
7181                            }
7182    
7183                            for (int i = 0; i < orderByConditionFields.length; i++) {
7184                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7185                                    query.append(orderByConditionFields[i]);
7186    
7187                                    if ((i + 1) < orderByConditionFields.length) {
7188                                            if (orderByComparator.isAscending() ^ previous) {
7189                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7190                                            }
7191                                            else {
7192                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7193                                            }
7194                                    }
7195                                    else {
7196                                            if (orderByComparator.isAscending() ^ previous) {
7197                                                    query.append(WHERE_GREATER_THAN);
7198                                            }
7199                                            else {
7200                                                    query.append(WHERE_LESSER_THAN);
7201                                            }
7202                                    }
7203                            }
7204    
7205                            query.append(ORDER_BY_CLAUSE);
7206    
7207                            String[] orderByFields = orderByComparator.getOrderByFields();
7208    
7209                            for (int i = 0; i < orderByFields.length; i++) {
7210                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7211                                    query.append(orderByFields[i]);
7212    
7213                                    if ((i + 1) < orderByFields.length) {
7214                                            if (orderByComparator.isAscending() ^ previous) {
7215                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7216                                            }
7217                                            else {
7218                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7219                                            }
7220                                    }
7221                                    else {
7222                                            if (orderByComparator.isAscending() ^ previous) {
7223                                                    query.append(ORDER_BY_ASC);
7224                                            }
7225                                            else {
7226                                                    query.append(ORDER_BY_DESC);
7227                                            }
7228                                    }
7229                            }
7230                    }
7231                    else {
7232                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7233                    }
7234    
7235                    String sql = query.toString();
7236    
7237                    Query q = session.createQuery(sql);
7238    
7239                    q.setFirstResult(0);
7240                    q.setMaxResults(2);
7241    
7242                    QueryPos qPos = QueryPos.getInstance(q);
7243    
7244                    qPos.add(groupId);
7245    
7246                    qPos.add(status);
7247    
7248                    if (orderByComparator != null) {
7249                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7250    
7251                            for (Object value : values) {
7252                                    qPos.add(value);
7253                            }
7254                    }
7255    
7256                    List<BlogsEntry> list = q.list();
7257    
7258                    if (list.size() == 2) {
7259                            return list.get(1);
7260                    }
7261                    else {
7262                            return null;
7263                    }
7264            }
7265    
7266            /**
7267             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7268             *
7269             * @param groupId the group ID
7270             * @param status the status
7271             * @return the matching blogs entries that the user has permission to view
7272             * @throws SystemException if a system exception occurred
7273             */
7274            public List<BlogsEntry> filterFindByG_S(long groupId, int status)
7275                    throws SystemException {
7276                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
7277                            QueryUtil.ALL_POS, null);
7278            }
7279    
7280            /**
7281             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7282             *
7283             * <p>
7284             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7285             * </p>
7286             *
7287             * @param groupId the group ID
7288             * @param status the status
7289             * @param start the lower bound of the range of blogs entries
7290             * @param end the upper bound of the range of blogs entries (not inclusive)
7291             * @return the range of matching blogs entries that the user has permission to view
7292             * @throws SystemException if a system exception occurred
7293             */
7294            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7295                    int start, int end) throws SystemException {
7296                    return filterFindByG_S(groupId, status, start, end, null);
7297            }
7298    
7299            /**
7300             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
7301             *
7302             * <p>
7303             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7304             * </p>
7305             *
7306             * @param groupId the group ID
7307             * @param status the status
7308             * @param start the lower bound of the range of blogs entries
7309             * @param end the upper bound of the range of blogs entries (not inclusive)
7310             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7311             * @return the ordered range of matching blogs entries that the user has permission to view
7312             * @throws SystemException if a system exception occurred
7313             */
7314            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7315                    int start, int end, OrderByComparator orderByComparator)
7316                    throws SystemException {
7317                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7318                            return findByG_S(groupId, status, start, end, orderByComparator);
7319                    }
7320    
7321                    StringBundler query = null;
7322    
7323                    if (orderByComparator != null) {
7324                            query = new StringBundler(4 +
7325                                            (orderByComparator.getOrderByFields().length * 3));
7326                    }
7327                    else {
7328                            query = new StringBundler(4);
7329                    }
7330    
7331                    if (getDB().isSupportsInlineDistinct()) {
7332                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7333                    }
7334                    else {
7335                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7336                    }
7337    
7338                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7339    
7340                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7341    
7342                    if (!getDB().isSupportsInlineDistinct()) {
7343                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7344                    }
7345    
7346                    if (orderByComparator != null) {
7347                            if (getDB().isSupportsInlineDistinct()) {
7348                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7349                                            orderByComparator);
7350                            }
7351                            else {
7352                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7353                                            orderByComparator);
7354                            }
7355                    }
7356                    else {
7357                            if (getDB().isSupportsInlineDistinct()) {
7358                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7359                            }
7360                            else {
7361                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7362                            }
7363                    }
7364    
7365                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7366                                    BlogsEntry.class.getName(),
7367                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7368    
7369                    Session session = null;
7370    
7371                    try {
7372                            session = openSession();
7373    
7374                            SQLQuery q = session.createSQLQuery(sql);
7375    
7376                            if (getDB().isSupportsInlineDistinct()) {
7377                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7378                            }
7379                            else {
7380                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7381                            }
7382    
7383                            QueryPos qPos = QueryPos.getInstance(q);
7384    
7385                            qPos.add(groupId);
7386    
7387                            qPos.add(status);
7388    
7389                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
7390                    }
7391                    catch (Exception e) {
7392                            throw processException(e);
7393                    }
7394                    finally {
7395                            closeSession(session);
7396                    }
7397            }
7398    
7399            /**
7400             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7401             *
7402             * @param entryId the primary key of the current blogs entry
7403             * @param groupId the group ID
7404             * @param status the status
7405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7406             * @return the previous, current, and next blogs entry
7407             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7408             * @throws SystemException if a system exception occurred
7409             */
7410            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
7411                    int status, OrderByComparator orderByComparator)
7412                    throws NoSuchEntryException, SystemException {
7413                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7414                            return findByG_S_PrevAndNext(entryId, groupId, status,
7415                                    orderByComparator);
7416                    }
7417    
7418                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7419    
7420                    Session session = null;
7421    
7422                    try {
7423                            session = openSession();
7424    
7425                            BlogsEntry[] array = new BlogsEntryImpl[3];
7426    
7427                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7428                                            status, orderByComparator, true);
7429    
7430                            array[1] = blogsEntry;
7431    
7432                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7433                                            status, orderByComparator, false);
7434    
7435                            return array;
7436                    }
7437                    catch (Exception e) {
7438                            throw processException(e);
7439                    }
7440                    finally {
7441                            closeSession(session);
7442                    }
7443            }
7444    
7445            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
7446                    BlogsEntry blogsEntry, long groupId, int status,
7447                    OrderByComparator orderByComparator, boolean previous) {
7448                    StringBundler query = null;
7449    
7450                    if (orderByComparator != null) {
7451                            query = new StringBundler(6 +
7452                                            (orderByComparator.getOrderByFields().length * 6));
7453                    }
7454                    else {
7455                            query = new StringBundler(3);
7456                    }
7457    
7458                    if (getDB().isSupportsInlineDistinct()) {
7459                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7460                    }
7461                    else {
7462                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7463                    }
7464    
7465                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7466    
7467                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7468    
7469                    if (!getDB().isSupportsInlineDistinct()) {
7470                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7471                    }
7472    
7473                    if (orderByComparator != null) {
7474                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7475    
7476                            if (orderByConditionFields.length > 0) {
7477                                    query.append(WHERE_AND);
7478                            }
7479    
7480                            for (int i = 0; i < orderByConditionFields.length; i++) {
7481                                    if (getDB().isSupportsInlineDistinct()) {
7482                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7483                                    }
7484                                    else {
7485                                            query.append(_ORDER_BY_ENTITY_TABLE);
7486                                    }
7487    
7488                                    query.append(orderByConditionFields[i]);
7489    
7490                                    if ((i + 1) < orderByConditionFields.length) {
7491                                            if (orderByComparator.isAscending() ^ previous) {
7492                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7493                                            }
7494                                            else {
7495                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7496                                            }
7497                                    }
7498                                    else {
7499                                            if (orderByComparator.isAscending() ^ previous) {
7500                                                    query.append(WHERE_GREATER_THAN);
7501                                            }
7502                                            else {
7503                                                    query.append(WHERE_LESSER_THAN);
7504                                            }
7505                                    }
7506                            }
7507    
7508                            query.append(ORDER_BY_CLAUSE);
7509    
7510                            String[] orderByFields = orderByComparator.getOrderByFields();
7511    
7512                            for (int i = 0; i < orderByFields.length; i++) {
7513                                    if (getDB().isSupportsInlineDistinct()) {
7514                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7515                                    }
7516                                    else {
7517                                            query.append(_ORDER_BY_ENTITY_TABLE);
7518                                    }
7519    
7520                                    query.append(orderByFields[i]);
7521    
7522                                    if ((i + 1) < orderByFields.length) {
7523                                            if (orderByComparator.isAscending() ^ previous) {
7524                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7525                                            }
7526                                            else {
7527                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7528                                            }
7529                                    }
7530                                    else {
7531                                            if (orderByComparator.isAscending() ^ previous) {
7532                                                    query.append(ORDER_BY_ASC);
7533                                            }
7534                                            else {
7535                                                    query.append(ORDER_BY_DESC);
7536                                            }
7537                                    }
7538                            }
7539                    }
7540                    else {
7541                            if (getDB().isSupportsInlineDistinct()) {
7542                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7543                            }
7544                            else {
7545                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7546                            }
7547                    }
7548    
7549                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7550                                    BlogsEntry.class.getName(),
7551                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7552    
7553                    SQLQuery q = session.createSQLQuery(sql);
7554    
7555                    q.setFirstResult(0);
7556                    q.setMaxResults(2);
7557    
7558                    if (getDB().isSupportsInlineDistinct()) {
7559                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7560                    }
7561                    else {
7562                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7563                    }
7564    
7565                    QueryPos qPos = QueryPos.getInstance(q);
7566    
7567                    qPos.add(groupId);
7568    
7569                    qPos.add(status);
7570    
7571                    if (orderByComparator != null) {
7572                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7573    
7574                            for (Object value : values) {
7575                                    qPos.add(value);
7576                            }
7577                    }
7578    
7579                    List<BlogsEntry> list = q.list();
7580    
7581                    if (list.size() == 2) {
7582                            return list.get(1);
7583                    }
7584                    else {
7585                            return null;
7586                    }
7587            }
7588    
7589            /**
7590             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
7591             *
7592             * @param groupId the group ID
7593             * @param status the status
7594             * @throws SystemException if a system exception occurred
7595             */
7596            public void removeByG_S(long groupId, int status) throws SystemException {
7597                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
7598                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7599                            remove(blogsEntry);
7600                    }
7601            }
7602    
7603            /**
7604             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
7605             *
7606             * @param groupId the group ID
7607             * @param status the status
7608             * @return the number of matching blogs entries
7609             * @throws SystemException if a system exception occurred
7610             */
7611            public int countByG_S(long groupId, int status) throws SystemException {
7612                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
7613    
7614                    Object[] finderArgs = new Object[] { groupId, status };
7615    
7616                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7617                                    this);
7618    
7619                    if (count == null) {
7620                            StringBundler query = new StringBundler(3);
7621    
7622                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7623    
7624                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7625    
7626                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
7627    
7628                            String sql = query.toString();
7629    
7630                            Session session = null;
7631    
7632                            try {
7633                                    session = openSession();
7634    
7635                                    Query q = session.createQuery(sql);
7636    
7637                                    QueryPos qPos = QueryPos.getInstance(q);
7638    
7639                                    qPos.add(groupId);
7640    
7641                                    qPos.add(status);
7642    
7643                                    count = (Long)q.uniqueResult();
7644    
7645                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7646                            }
7647                            catch (Exception e) {
7648                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7649    
7650                                    throw processException(e);
7651                            }
7652                            finally {
7653                                    closeSession(session);
7654                            }
7655                    }
7656    
7657                    return count.intValue();
7658            }
7659    
7660            /**
7661             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7662             *
7663             * @param groupId the group ID
7664             * @param status the status
7665             * @return the number of matching blogs entries that the user has permission to view
7666             * @throws SystemException if a system exception occurred
7667             */
7668            public int filterCountByG_S(long groupId, int status)
7669                    throws SystemException {
7670                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7671                            return countByG_S(groupId, status);
7672                    }
7673    
7674                    StringBundler query = new StringBundler(3);
7675    
7676                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
7677    
7678                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7679    
7680                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7681    
7682                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7683                                    BlogsEntry.class.getName(),
7684                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7685    
7686                    Session session = null;
7687    
7688                    try {
7689                            session = openSession();
7690    
7691                            SQLQuery q = session.createSQLQuery(sql);
7692    
7693                            q.addScalar(COUNT_COLUMN_NAME,
7694                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7695    
7696                            QueryPos qPos = QueryPos.getInstance(q);
7697    
7698                            qPos.add(groupId);
7699    
7700                            qPos.add(status);
7701    
7702                            Long count = (Long)q.uniqueResult();
7703    
7704                            return count.intValue();
7705                    }
7706                    catch (Exception e) {
7707                            throw processException(e);
7708                    }
7709                    finally {
7710                            closeSession(session);
7711                    }
7712            }
7713    
7714            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
7715            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
7716            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7717                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7718                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
7719                            new String[] {
7720                                    Date.class.getName(), Integer.class.getName(),
7721                                    
7722                            Integer.class.getName(), Integer.class.getName(),
7723                                    OrderByComparator.class.getName()
7724                            });
7725            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7726                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7727                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
7728                            new String[] { Date.class.getName(), Integer.class.getName() });
7729    
7730            /**
7731             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7732             *
7733             * @param displayDate the display date
7734             * @param status the status
7735             * @return the matching blogs entries
7736             * @throws SystemException if a system exception occurred
7737             */
7738            public List<BlogsEntry> findByLtD_S(Date displayDate, int status)
7739                    throws SystemException {
7740                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
7741                            QueryUtil.ALL_POS, null);
7742            }
7743    
7744            /**
7745             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7746             *
7747             * <p>
7748             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7749             * </p>
7750             *
7751             * @param displayDate the display date
7752             * @param status the status
7753             * @param start the lower bound of the range of blogs entries
7754             * @param end the upper bound of the range of blogs entries (not inclusive)
7755             * @return the range of matching blogs entries
7756             * @throws SystemException if a system exception occurred
7757             */
7758            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7759                    int start, int end) throws SystemException {
7760                    return findByLtD_S(displayDate, status, start, end, null);
7761            }
7762    
7763            /**
7764             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7765             *
7766             * <p>
7767             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7768             * </p>
7769             *
7770             * @param displayDate the display date
7771             * @param status the status
7772             * @param start the lower bound of the range of blogs entries
7773             * @param end the upper bound of the range of blogs entries (not inclusive)
7774             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7775             * @return the ordered range of matching blogs entries
7776             * @throws SystemException if a system exception occurred
7777             */
7778            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7779                    int start, int end, OrderByComparator orderByComparator)
7780                    throws SystemException {
7781                    boolean pagination = true;
7782                    FinderPath finderPath = null;
7783                    Object[] finderArgs = null;
7784    
7785                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
7786                    finderArgs = new Object[] {
7787                                    displayDate, status,
7788                                    
7789                                    start, end, orderByComparator
7790                            };
7791    
7792                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7793                                    finderArgs, this);
7794    
7795                    if ((list != null) && !list.isEmpty()) {
7796                            for (BlogsEntry blogsEntry : list) {
7797                                    if (!Validator.equals(displayDate, blogsEntry.getDisplayDate()) ||
7798                                                    (status != blogsEntry.getStatus())) {
7799                                            list = null;
7800    
7801                                            break;
7802                                    }
7803                            }
7804                    }
7805    
7806                    if (list == null) {
7807                            StringBundler query = null;
7808    
7809                            if (orderByComparator != null) {
7810                                    query = new StringBundler(4 +
7811                                                    (orderByComparator.getOrderByFields().length * 3));
7812                            }
7813                            else {
7814                                    query = new StringBundler(4);
7815                            }
7816    
7817                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7818    
7819                            if (displayDate == null) {
7820                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
7821                            }
7822                            else {
7823                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
7824                            }
7825    
7826                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
7827    
7828                            if (orderByComparator != null) {
7829                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7830                                            orderByComparator);
7831                            }
7832                            else
7833                             if (pagination) {
7834                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7835                            }
7836    
7837                            String sql = query.toString();
7838    
7839                            Session session = null;
7840    
7841                            try {
7842                                    session = openSession();
7843    
7844                                    Query q = session.createQuery(sql);
7845    
7846                                    QueryPos qPos = QueryPos.getInstance(q);
7847    
7848                                    if (displayDate != null) {
7849                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
7850                                    }
7851    
7852                                    qPos.add(status);
7853    
7854                                    if (!pagination) {
7855                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7856                                                            start, end, false);
7857    
7858                                            Collections.sort(list);
7859    
7860                                            list = new UnmodifiableList<BlogsEntry>(list);
7861                                    }
7862                                    else {
7863                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7864                                                            start, end);
7865                                    }
7866    
7867                                    cacheResult(list);
7868    
7869                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7870                            }
7871                            catch (Exception e) {
7872                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7873    
7874                                    throw processException(e);
7875                            }
7876                            finally {
7877                                    closeSession(session);
7878                            }
7879                    }
7880    
7881                    return list;
7882            }
7883    
7884            /**
7885             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7886             *
7887             * @param displayDate the display date
7888             * @param status the status
7889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7890             * @return the first matching blogs entry
7891             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7892             * @throws SystemException if a system exception occurred
7893             */
7894            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
7895                    OrderByComparator orderByComparator)
7896                    throws NoSuchEntryException, SystemException {
7897                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
7898                                    orderByComparator);
7899    
7900                    if (blogsEntry != null) {
7901                            return blogsEntry;
7902                    }
7903    
7904                    StringBundler msg = new StringBundler(6);
7905    
7906                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7907    
7908                    msg.append("displayDate=");
7909                    msg.append(displayDate);
7910    
7911                    msg.append(", status=");
7912                    msg.append(status);
7913    
7914                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7915    
7916                    throw new NoSuchEntryException(msg.toString());
7917            }
7918    
7919            /**
7920             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7921             *
7922             * @param displayDate the display date
7923             * @param status the status
7924             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7925             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7926             * @throws SystemException if a system exception occurred
7927             */
7928            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
7929                    OrderByComparator orderByComparator) throws SystemException {
7930                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
7931                                    orderByComparator);
7932    
7933                    if (!list.isEmpty()) {
7934                            return list.get(0);
7935                    }
7936    
7937                    return null;
7938            }
7939    
7940            /**
7941             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7942             *
7943             * @param displayDate the display date
7944             * @param status the status
7945             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7946             * @return the last matching blogs entry
7947             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7948             * @throws SystemException if a system exception occurred
7949             */
7950            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
7951                    OrderByComparator orderByComparator)
7952                    throws NoSuchEntryException, SystemException {
7953                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
7954                                    orderByComparator);
7955    
7956                    if (blogsEntry != null) {
7957                            return blogsEntry;
7958                    }
7959    
7960                    StringBundler msg = new StringBundler(6);
7961    
7962                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7963    
7964                    msg.append("displayDate=");
7965                    msg.append(displayDate);
7966    
7967                    msg.append(", status=");
7968                    msg.append(status);
7969    
7970                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7971    
7972                    throw new NoSuchEntryException(msg.toString());
7973            }
7974    
7975            /**
7976             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7977             *
7978             * @param displayDate the display date
7979             * @param status the status
7980             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7981             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7982             * @throws SystemException if a system exception occurred
7983             */
7984            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
7985                    OrderByComparator orderByComparator) throws SystemException {
7986                    int count = countByLtD_S(displayDate, status);
7987    
7988                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
7989                                    count, orderByComparator);
7990    
7991                    if (!list.isEmpty()) {
7992                            return list.get(0);
7993                    }
7994    
7995                    return null;
7996            }
7997    
7998            /**
7999             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8000             *
8001             * @param entryId the primary key of the current blogs entry
8002             * @param displayDate the display date
8003             * @param status the status
8004             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8005             * @return the previous, current, and next blogs entry
8006             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8007             * @throws SystemException if a system exception occurred
8008             */
8009            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8010                    int status, OrderByComparator orderByComparator)
8011                    throws NoSuchEntryException, SystemException {
8012                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8013    
8014                    Session session = null;
8015    
8016                    try {
8017                            session = openSession();
8018    
8019                            BlogsEntry[] array = new BlogsEntryImpl[3];
8020    
8021                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8022                                            status, orderByComparator, true);
8023    
8024                            array[1] = blogsEntry;
8025    
8026                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8027                                            status, orderByComparator, false);
8028    
8029                            return array;
8030                    }
8031                    catch (Exception e) {
8032                            throw processException(e);
8033                    }
8034                    finally {
8035                            closeSession(session);
8036                    }
8037            }
8038    
8039            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8040                    BlogsEntry blogsEntry, Date displayDate, int status,
8041                    OrderByComparator orderByComparator, boolean previous) {
8042                    StringBundler query = null;
8043    
8044                    if (orderByComparator != null) {
8045                            query = new StringBundler(6 +
8046                                            (orderByComparator.getOrderByFields().length * 6));
8047                    }
8048                    else {
8049                            query = new StringBundler(3);
8050                    }
8051    
8052                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8053    
8054                    if (displayDate == null) {
8055                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8056                    }
8057                    else {
8058                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8059                    }
8060    
8061                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8062    
8063                    if (orderByComparator != null) {
8064                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8065    
8066                            if (orderByConditionFields.length > 0) {
8067                                    query.append(WHERE_AND);
8068                            }
8069    
8070                            for (int i = 0; i < orderByConditionFields.length; i++) {
8071                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8072                                    query.append(orderByConditionFields[i]);
8073    
8074                                    if ((i + 1) < orderByConditionFields.length) {
8075                                            if (orderByComparator.isAscending() ^ previous) {
8076                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8077                                            }
8078                                            else {
8079                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8080                                            }
8081                                    }
8082                                    else {
8083                                            if (orderByComparator.isAscending() ^ previous) {
8084                                                    query.append(WHERE_GREATER_THAN);
8085                                            }
8086                                            else {
8087                                                    query.append(WHERE_LESSER_THAN);
8088                                            }
8089                                    }
8090                            }
8091    
8092                            query.append(ORDER_BY_CLAUSE);
8093    
8094                            String[] orderByFields = orderByComparator.getOrderByFields();
8095    
8096                            for (int i = 0; i < orderByFields.length; i++) {
8097                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8098                                    query.append(orderByFields[i]);
8099    
8100                                    if ((i + 1) < orderByFields.length) {
8101                                            if (orderByComparator.isAscending() ^ previous) {
8102                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8103                                            }
8104                                            else {
8105                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8106                                            }
8107                                    }
8108                                    else {
8109                                            if (orderByComparator.isAscending() ^ previous) {
8110                                                    query.append(ORDER_BY_ASC);
8111                                            }
8112                                            else {
8113                                                    query.append(ORDER_BY_DESC);
8114                                            }
8115                                    }
8116                            }
8117                    }
8118                    else {
8119                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8120                    }
8121    
8122                    String sql = query.toString();
8123    
8124                    Query q = session.createQuery(sql);
8125    
8126                    q.setFirstResult(0);
8127                    q.setMaxResults(2);
8128    
8129                    QueryPos qPos = QueryPos.getInstance(q);
8130    
8131                    if (displayDate != null) {
8132                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8133                    }
8134    
8135                    qPos.add(status);
8136    
8137                    if (orderByComparator != null) {
8138                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8139    
8140                            for (Object value : values) {
8141                                    qPos.add(value);
8142                            }
8143                    }
8144    
8145                    List<BlogsEntry> list = q.list();
8146    
8147                    if (list.size() == 2) {
8148                            return list.get(1);
8149                    }
8150                    else {
8151                            return null;
8152                    }
8153            }
8154    
8155            /**
8156             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8157             *
8158             * @param displayDate the display date
8159             * @param status the status
8160             * @throws SystemException if a system exception occurred
8161             */
8162            public void removeByLtD_S(Date displayDate, int status)
8163                    throws SystemException {
8164                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8165                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8166                            remove(blogsEntry);
8167                    }
8168            }
8169    
8170            /**
8171             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8172             *
8173             * @param displayDate the display date
8174             * @param status the status
8175             * @return the number of matching blogs entries
8176             * @throws SystemException if a system exception occurred
8177             */
8178            public int countByLtD_S(Date displayDate, int status)
8179                    throws SystemException {
8180                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8181    
8182                    Object[] finderArgs = new Object[] { displayDate, status };
8183    
8184                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8185                                    this);
8186    
8187                    if (count == null) {
8188                            StringBundler query = new StringBundler(3);
8189    
8190                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8191    
8192                            if (displayDate == null) {
8193                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8194                            }
8195                            else {
8196                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8197                            }
8198    
8199                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8200    
8201                            String sql = query.toString();
8202    
8203                            Session session = null;
8204    
8205                            try {
8206                                    session = openSession();
8207    
8208                                    Query q = session.createQuery(sql);
8209    
8210                                    QueryPos qPos = QueryPos.getInstance(q);
8211    
8212                                    if (displayDate != null) {
8213                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8214                                    }
8215    
8216                                    qPos.add(status);
8217    
8218                                    count = (Long)q.uniqueResult();
8219    
8220                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8221                            }
8222                            catch (Exception e) {
8223                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8224    
8225                                    throw processException(e);
8226                            }
8227                            finally {
8228                                    closeSession(session);
8229                            }
8230                    }
8231    
8232                    return count.intValue();
8233            }
8234    
8235            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
8236            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8237            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8238            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8239                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8240                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
8241                            new String[] {
8242                                    Long.class.getName(), Long.class.getName(),
8243                                    Integer.class.getName(),
8244                                    
8245                            Integer.class.getName(), Integer.class.getName(),
8246                                    OrderByComparator.class.getName()
8247                            });
8248            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
8249                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8250                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8251                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
8252                            new String[] {
8253                                    Long.class.getName(), Long.class.getName(),
8254                                    Integer.class.getName()
8255                            });
8256    
8257            /**
8258             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8259             *
8260             * @param companyId the company ID
8261             * @param userId the user ID
8262             * @param status the status
8263             * @return the matching blogs entries
8264             * @throws SystemException if a system exception occurred
8265             */
8266            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8267                    int status) throws SystemException {
8268                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
8269                            QueryUtil.ALL_POS, null);
8270            }
8271    
8272            /**
8273             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8274             *
8275             * <p>
8276             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8277             * </p>
8278             *
8279             * @param companyId the company ID
8280             * @param userId the user ID
8281             * @param status the status
8282             * @param start the lower bound of the range of blogs entries
8283             * @param end the upper bound of the range of blogs entries (not inclusive)
8284             * @return the range of matching blogs entries
8285             * @throws SystemException if a system exception occurred
8286             */
8287            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8288                    int status, int start, int end) throws SystemException {
8289                    return findByC_U_NotS(companyId, userId, status, start, end, null);
8290            }
8291    
8292            /**
8293             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8294             *
8295             * <p>
8296             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8297             * </p>
8298             *
8299             * @param companyId the company ID
8300             * @param userId the user ID
8301             * @param status the status
8302             * @param start the lower bound of the range of blogs entries
8303             * @param end the upper bound of the range of blogs entries (not inclusive)
8304             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8305             * @return the ordered range of matching blogs entries
8306             * @throws SystemException if a system exception occurred
8307             */
8308            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8309                    int status, int start, int end, OrderByComparator orderByComparator)
8310                    throws SystemException {
8311                    boolean pagination = true;
8312                    FinderPath finderPath = null;
8313                    Object[] finderArgs = null;
8314    
8315                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
8316                    finderArgs = new Object[] {
8317                                    companyId, userId, status,
8318                                    
8319                                    start, end, orderByComparator
8320                            };
8321    
8322                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8323                                    finderArgs, this);
8324    
8325                    if ((list != null) && !list.isEmpty()) {
8326                            for (BlogsEntry blogsEntry : list) {
8327                                    if ((companyId != blogsEntry.getCompanyId()) ||
8328                                                    (userId != blogsEntry.getUserId()) ||
8329                                                    (status != blogsEntry.getStatus())) {
8330                                            list = null;
8331    
8332                                            break;
8333                                    }
8334                            }
8335                    }
8336    
8337                    if (list == null) {
8338                            StringBundler query = null;
8339    
8340                            if (orderByComparator != null) {
8341                                    query = new StringBundler(5 +
8342                                                    (orderByComparator.getOrderByFields().length * 3));
8343                            }
8344                            else {
8345                                    query = new StringBundler(5);
8346                            }
8347    
8348                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8349    
8350                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8351    
8352                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8353    
8354                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8355    
8356                            if (orderByComparator != null) {
8357                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8358                                            orderByComparator);
8359                            }
8360                            else
8361                             if (pagination) {
8362                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8363                            }
8364    
8365                            String sql = query.toString();
8366    
8367                            Session session = null;
8368    
8369                            try {
8370                                    session = openSession();
8371    
8372                                    Query q = session.createQuery(sql);
8373    
8374                                    QueryPos qPos = QueryPos.getInstance(q);
8375    
8376                                    qPos.add(companyId);
8377    
8378                                    qPos.add(userId);
8379    
8380                                    qPos.add(status);
8381    
8382                                    if (!pagination) {
8383                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8384                                                            start, end, false);
8385    
8386                                            Collections.sort(list);
8387    
8388                                            list = new UnmodifiableList<BlogsEntry>(list);
8389                                    }
8390                                    else {
8391                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8392                                                            start, end);
8393                                    }
8394    
8395                                    cacheResult(list);
8396    
8397                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8398                            }
8399                            catch (Exception e) {
8400                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8401    
8402                                    throw processException(e);
8403                            }
8404                            finally {
8405                                    closeSession(session);
8406                            }
8407                    }
8408    
8409                    return list;
8410            }
8411    
8412            /**
8413             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8414             *
8415             * @param companyId the company ID
8416             * @param userId the user ID
8417             * @param status the status
8418             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8419             * @return the first matching blogs entry
8420             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8421             * @throws SystemException if a system exception occurred
8422             */
8423            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
8424                    int status, OrderByComparator orderByComparator)
8425                    throws NoSuchEntryException, SystemException {
8426                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
8427                                    status, orderByComparator);
8428    
8429                    if (blogsEntry != null) {
8430                            return blogsEntry;
8431                    }
8432    
8433                    StringBundler msg = new StringBundler(8);
8434    
8435                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8436    
8437                    msg.append("companyId=");
8438                    msg.append(companyId);
8439    
8440                    msg.append(", userId=");
8441                    msg.append(userId);
8442    
8443                    msg.append(", status=");
8444                    msg.append(status);
8445    
8446                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8447    
8448                    throw new NoSuchEntryException(msg.toString());
8449            }
8450    
8451            /**
8452             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8453             *
8454             * @param companyId the company ID
8455             * @param userId the user ID
8456             * @param status the status
8457             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8458             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8459             * @throws SystemException if a system exception occurred
8460             */
8461            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
8462                    int status, OrderByComparator orderByComparator)
8463                    throws SystemException {
8464                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
8465                                    orderByComparator);
8466    
8467                    if (!list.isEmpty()) {
8468                            return list.get(0);
8469                    }
8470    
8471                    return null;
8472            }
8473    
8474            /**
8475             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8476             *
8477             * @param companyId the company ID
8478             * @param userId the user ID
8479             * @param status the status
8480             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8481             * @return the last matching blogs entry
8482             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8483             * @throws SystemException if a system exception occurred
8484             */
8485            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
8486                    int status, OrderByComparator orderByComparator)
8487                    throws NoSuchEntryException, SystemException {
8488                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
8489                                    orderByComparator);
8490    
8491                    if (blogsEntry != null) {
8492                            return blogsEntry;
8493                    }
8494    
8495                    StringBundler msg = new StringBundler(8);
8496    
8497                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8498    
8499                    msg.append("companyId=");
8500                    msg.append(companyId);
8501    
8502                    msg.append(", userId=");
8503                    msg.append(userId);
8504    
8505                    msg.append(", status=");
8506                    msg.append(status);
8507    
8508                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8509    
8510                    throw new NoSuchEntryException(msg.toString());
8511            }
8512    
8513            /**
8514             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8515             *
8516             * @param companyId the company ID
8517             * @param userId the user ID
8518             * @param status the status
8519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8520             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8521             * @throws SystemException if a system exception occurred
8522             */
8523            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
8524                    int status, OrderByComparator orderByComparator)
8525                    throws SystemException {
8526                    int count = countByC_U_NotS(companyId, userId, status);
8527    
8528                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
8529                                    count - 1, count, orderByComparator);
8530    
8531                    if (!list.isEmpty()) {
8532                            return list.get(0);
8533                    }
8534    
8535                    return null;
8536            }
8537    
8538            /**
8539             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8540             *
8541             * @param entryId the primary key of the current blogs entry
8542             * @param companyId the company ID
8543             * @param userId the user ID
8544             * @param status the status
8545             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8546             * @return the previous, current, and next blogs entry
8547             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8548             * @throws SystemException if a system exception occurred
8549             */
8550            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
8551                    long companyId, long userId, int status,
8552                    OrderByComparator orderByComparator)
8553                    throws NoSuchEntryException, SystemException {
8554                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8555    
8556                    Session session = null;
8557    
8558                    try {
8559                            session = openSession();
8560    
8561                            BlogsEntry[] array = new BlogsEntryImpl[3];
8562    
8563                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8564                                            companyId, userId, status, orderByComparator, true);
8565    
8566                            array[1] = blogsEntry;
8567    
8568                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8569                                            companyId, userId, status, orderByComparator, false);
8570    
8571                            return array;
8572                    }
8573                    catch (Exception e) {
8574                            throw processException(e);
8575                    }
8576                    finally {
8577                            closeSession(session);
8578                    }
8579            }
8580    
8581            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
8582                    BlogsEntry blogsEntry, long companyId, long userId, int status,
8583                    OrderByComparator orderByComparator, boolean previous) {
8584                    StringBundler query = null;
8585    
8586                    if (orderByComparator != null) {
8587                            query = new StringBundler(6 +
8588                                            (orderByComparator.getOrderByFields().length * 6));
8589                    }
8590                    else {
8591                            query = new StringBundler(3);
8592                    }
8593    
8594                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8595    
8596                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8597    
8598                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8599    
8600                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8601    
8602                    if (orderByComparator != null) {
8603                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8604    
8605                            if (orderByConditionFields.length > 0) {
8606                                    query.append(WHERE_AND);
8607                            }
8608    
8609                            for (int i = 0; i < orderByConditionFields.length; i++) {
8610                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8611                                    query.append(orderByConditionFields[i]);
8612    
8613                                    if ((i + 1) < orderByConditionFields.length) {
8614                                            if (orderByComparator.isAscending() ^ previous) {
8615                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8616                                            }
8617                                            else {
8618                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8619                                            }
8620                                    }
8621                                    else {
8622                                            if (orderByComparator.isAscending() ^ previous) {
8623                                                    query.append(WHERE_GREATER_THAN);
8624                                            }
8625                                            else {
8626                                                    query.append(WHERE_LESSER_THAN);
8627                                            }
8628                                    }
8629                            }
8630    
8631                            query.append(ORDER_BY_CLAUSE);
8632    
8633                            String[] orderByFields = orderByComparator.getOrderByFields();
8634    
8635                            for (int i = 0; i < orderByFields.length; i++) {
8636                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8637                                    query.append(orderByFields[i]);
8638    
8639                                    if ((i + 1) < orderByFields.length) {
8640                                            if (orderByComparator.isAscending() ^ previous) {
8641                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8642                                            }
8643                                            else {
8644                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8645                                            }
8646                                    }
8647                                    else {
8648                                            if (orderByComparator.isAscending() ^ previous) {
8649                                                    query.append(ORDER_BY_ASC);
8650                                            }
8651                                            else {
8652                                                    query.append(ORDER_BY_DESC);
8653                                            }
8654                                    }
8655                            }
8656                    }
8657                    else {
8658                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8659                    }
8660    
8661                    String sql = query.toString();
8662    
8663                    Query q = session.createQuery(sql);
8664    
8665                    q.setFirstResult(0);
8666                    q.setMaxResults(2);
8667    
8668                    QueryPos qPos = QueryPos.getInstance(q);
8669    
8670                    qPos.add(companyId);
8671    
8672                    qPos.add(userId);
8673    
8674                    qPos.add(status);
8675    
8676                    if (orderByComparator != null) {
8677                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8678    
8679                            for (Object value : values) {
8680                                    qPos.add(value);
8681                            }
8682                    }
8683    
8684                    List<BlogsEntry> list = q.list();
8685    
8686                    if (list.size() == 2) {
8687                            return list.get(1);
8688                    }
8689                    else {
8690                            return null;
8691                    }
8692            }
8693    
8694            /**
8695             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
8696             *
8697             * @param companyId the company ID
8698             * @param userId the user ID
8699             * @param status the status
8700             * @throws SystemException if a system exception occurred
8701             */
8702            public void removeByC_U_NotS(long companyId, long userId, int status)
8703                    throws SystemException {
8704                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
8705                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8706                            remove(blogsEntry);
8707                    }
8708            }
8709    
8710            /**
8711             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8712             *
8713             * @param companyId the company ID
8714             * @param userId the user ID
8715             * @param status the status
8716             * @return the number of matching blogs entries
8717             * @throws SystemException if a system exception occurred
8718             */
8719            public int countByC_U_NotS(long companyId, long userId, int status)
8720                    throws SystemException {
8721                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
8722    
8723                    Object[] finderArgs = new Object[] { companyId, userId, status };
8724    
8725                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8726                                    this);
8727    
8728                    if (count == null) {
8729                            StringBundler query = new StringBundler(4);
8730    
8731                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8732    
8733                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8734    
8735                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8736    
8737                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8738    
8739                            String sql = query.toString();
8740    
8741                            Session session = null;
8742    
8743                            try {
8744                                    session = openSession();
8745    
8746                                    Query q = session.createQuery(sql);
8747    
8748                                    QueryPos qPos = QueryPos.getInstance(q);
8749    
8750                                    qPos.add(companyId);
8751    
8752                                    qPos.add(userId);
8753    
8754                                    qPos.add(status);
8755    
8756                                    count = (Long)q.uniqueResult();
8757    
8758                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8759                            }
8760                            catch (Exception e) {
8761                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8762    
8763                                    throw processException(e);
8764                            }
8765                            finally {
8766                                    closeSession(session);
8767                            }
8768                    }
8769    
8770                    return count.intValue();
8771            }
8772    
8773            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8774            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
8775            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
8776            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8777                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8778                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
8779                            new String[] {
8780                                    Long.class.getName(), Long.class.getName(),
8781                                    Integer.class.getName(),
8782                                    
8783                            Integer.class.getName(), Integer.class.getName(),
8784                                    OrderByComparator.class.getName()
8785                            });
8786            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8787                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8788                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
8789                            new String[] {
8790                                    Long.class.getName(), Long.class.getName(),
8791                                    Integer.class.getName()
8792                            },
8793                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
8794                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
8795                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
8796                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
8797                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
8798            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8799                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8800                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
8801                            new String[] {
8802                                    Long.class.getName(), Long.class.getName(),
8803                                    Integer.class.getName()
8804                            });
8805    
8806            /**
8807             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
8808             *
8809             * @param companyId the company ID
8810             * @param userId the user ID
8811             * @param status the status
8812             * @return the matching blogs entries
8813             * @throws SystemException if a system exception occurred
8814             */
8815            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status)
8816                    throws SystemException {
8817                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
8818                            QueryUtil.ALL_POS, null);
8819            }
8820    
8821            /**
8822             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
8823             *
8824             * <p>
8825             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8826             * </p>
8827             *
8828             * @param companyId the company ID
8829             * @param userId the user ID
8830             * @param status the status
8831             * @param start the lower bound of the range of blogs entries
8832             * @param end the upper bound of the range of blogs entries (not inclusive)
8833             * @return the range of matching blogs entries
8834             * @throws SystemException if a system exception occurred
8835             */
8836            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
8837                    int status, int start, int end) throws SystemException {
8838                    return findByC_U_S(companyId, userId, status, start, end, null);
8839            }
8840    
8841            /**
8842             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
8843             *
8844             * <p>
8845             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8846             * </p>
8847             *
8848             * @param companyId the company ID
8849             * @param userId the user ID
8850             * @param status the status
8851             * @param start the lower bound of the range of blogs entries
8852             * @param end the upper bound of the range of blogs entries (not inclusive)
8853             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8854             * @return the ordered range of matching blogs entries
8855             * @throws SystemException if a system exception occurred
8856             */
8857            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
8858                    int status, int start, int end, OrderByComparator orderByComparator)
8859                    throws SystemException {
8860                    boolean pagination = true;
8861                    FinderPath finderPath = null;
8862                    Object[] finderArgs = null;
8863    
8864                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8865                                    (orderByComparator == null)) {
8866                            pagination = false;
8867                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
8868                            finderArgs = new Object[] { companyId, userId, status };
8869                    }
8870                    else {
8871                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
8872                            finderArgs = new Object[] {
8873                                            companyId, userId, status,
8874                                            
8875                                            start, end, orderByComparator
8876                                    };
8877                    }
8878    
8879                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8880                                    finderArgs, this);
8881    
8882                    if ((list != null) && !list.isEmpty()) {
8883                            for (BlogsEntry blogsEntry : list) {
8884                                    if ((companyId != blogsEntry.getCompanyId()) ||
8885                                                    (userId != blogsEntry.getUserId()) ||
8886                                                    (status != blogsEntry.getStatus())) {
8887                                            list = null;
8888    
8889                                            break;
8890                                    }
8891                            }
8892                    }
8893    
8894                    if (list == null) {
8895                            StringBundler query = null;
8896    
8897                            if (orderByComparator != null) {
8898                                    query = new StringBundler(5 +
8899                                                    (orderByComparator.getOrderByFields().length * 3));
8900                            }
8901                            else {
8902                                    query = new StringBundler(5);
8903                            }
8904    
8905                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8906    
8907                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
8908    
8909                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
8910    
8911                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
8912    
8913                            if (orderByComparator != null) {
8914                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8915                                            orderByComparator);
8916                            }
8917                            else
8918                             if (pagination) {
8919                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8920                            }
8921    
8922                            String sql = query.toString();
8923    
8924                            Session session = null;
8925    
8926                            try {
8927                                    session = openSession();
8928    
8929                                    Query q = session.createQuery(sql);
8930    
8931                                    QueryPos qPos = QueryPos.getInstance(q);
8932    
8933                                    qPos.add(companyId);
8934    
8935                                    qPos.add(userId);
8936    
8937                                    qPos.add(status);
8938    
8939                                    if (!pagination) {
8940                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8941                                                            start, end, false);
8942    
8943                                            Collections.sort(list);
8944    
8945                                            list = new UnmodifiableList<BlogsEntry>(list);
8946                                    }
8947                                    else {
8948                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8949                                                            start, end);
8950                                    }
8951    
8952                                    cacheResult(list);
8953    
8954                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8955                            }
8956                            catch (Exception e) {
8957                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8958    
8959                                    throw processException(e);
8960                            }
8961                            finally {
8962                                    closeSession(session);
8963                            }
8964                    }
8965    
8966                    return list;
8967            }
8968    
8969            /**
8970             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
8971             *
8972             * @param companyId the company ID
8973             * @param userId the user ID
8974             * @param status the status
8975             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8976             * @return the first matching blogs entry
8977             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8978             * @throws SystemException if a system exception occurred
8979             */
8980            public BlogsEntry findByC_U_S_First(long companyId, long userId,
8981                    int status, OrderByComparator orderByComparator)
8982                    throws NoSuchEntryException, SystemException {
8983                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
8984                                    orderByComparator);
8985    
8986                    if (blogsEntry != null) {
8987                            return blogsEntry;
8988                    }
8989    
8990                    StringBundler msg = new StringBundler(8);
8991    
8992                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8993    
8994                    msg.append("companyId=");
8995                    msg.append(companyId);
8996    
8997                    msg.append(", userId=");
8998                    msg.append(userId);
8999    
9000                    msg.append(", status=");
9001                    msg.append(status);
9002    
9003                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9004    
9005                    throw new NoSuchEntryException(msg.toString());
9006            }
9007    
9008            /**
9009             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9010             *
9011             * @param companyId the company ID
9012             * @param userId the user ID
9013             * @param status the status
9014             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9015             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9016             * @throws SystemException if a system exception occurred
9017             */
9018            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
9019                    int status, OrderByComparator orderByComparator)
9020                    throws SystemException {
9021                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
9022                                    orderByComparator);
9023    
9024                    if (!list.isEmpty()) {
9025                            return list.get(0);
9026                    }
9027    
9028                    return null;
9029            }
9030    
9031            /**
9032             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9033             *
9034             * @param companyId the company ID
9035             * @param userId the user ID
9036             * @param status the status
9037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9038             * @return the last matching blogs entry
9039             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9040             * @throws SystemException if a system exception occurred
9041             */
9042            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
9043                    OrderByComparator orderByComparator)
9044                    throws NoSuchEntryException, SystemException {
9045                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
9046                                    orderByComparator);
9047    
9048                    if (blogsEntry != null) {
9049                            return blogsEntry;
9050                    }
9051    
9052                    StringBundler msg = new StringBundler(8);
9053    
9054                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9055    
9056                    msg.append("companyId=");
9057                    msg.append(companyId);
9058    
9059                    msg.append(", userId=");
9060                    msg.append(userId);
9061    
9062                    msg.append(", status=");
9063                    msg.append(status);
9064    
9065                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9066    
9067                    throw new NoSuchEntryException(msg.toString());
9068            }
9069    
9070            /**
9071             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9072             *
9073             * @param companyId the company ID
9074             * @param userId the user ID
9075             * @param status the status
9076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9077             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9078             * @throws SystemException if a system exception occurred
9079             */
9080            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
9081                    int status, OrderByComparator orderByComparator)
9082                    throws SystemException {
9083                    int count = countByC_U_S(companyId, userId, status);
9084    
9085                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
9086                                    count - 1, count, orderByComparator);
9087    
9088                    if (!list.isEmpty()) {
9089                            return list.get(0);
9090                    }
9091    
9092                    return null;
9093            }
9094    
9095            /**
9096             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9097             *
9098             * @param entryId the primary key of the current blogs entry
9099             * @param companyId the company ID
9100             * @param userId the user ID
9101             * @param status the status
9102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9103             * @return the previous, current, and next blogs entry
9104             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9105             * @throws SystemException if a system exception occurred
9106             */
9107            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
9108                    long userId, int status, OrderByComparator orderByComparator)
9109                    throws NoSuchEntryException, SystemException {
9110                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9111    
9112                    Session session = null;
9113    
9114                    try {
9115                            session = openSession();
9116    
9117                            BlogsEntry[] array = new BlogsEntryImpl[3];
9118    
9119                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9120                                            userId, status, orderByComparator, true);
9121    
9122                            array[1] = blogsEntry;
9123    
9124                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9125                                            userId, status, orderByComparator, false);
9126    
9127                            return array;
9128                    }
9129                    catch (Exception e) {
9130                            throw processException(e);
9131                    }
9132                    finally {
9133                            closeSession(session);
9134                    }
9135            }
9136    
9137            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
9138                    BlogsEntry blogsEntry, long companyId, long userId, int status,
9139                    OrderByComparator orderByComparator, boolean previous) {
9140                    StringBundler query = null;
9141    
9142                    if (orderByComparator != null) {
9143                            query = new StringBundler(6 +
9144                                            (orderByComparator.getOrderByFields().length * 6));
9145                    }
9146                    else {
9147                            query = new StringBundler(3);
9148                    }
9149    
9150                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9151    
9152                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9153    
9154                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9155    
9156                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9157    
9158                    if (orderByComparator != null) {
9159                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9160    
9161                            if (orderByConditionFields.length > 0) {
9162                                    query.append(WHERE_AND);
9163                            }
9164    
9165                            for (int i = 0; i < orderByConditionFields.length; i++) {
9166                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9167                                    query.append(orderByConditionFields[i]);
9168    
9169                                    if ((i + 1) < orderByConditionFields.length) {
9170                                            if (orderByComparator.isAscending() ^ previous) {
9171                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9172                                            }
9173                                            else {
9174                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9175                                            }
9176                                    }
9177                                    else {
9178                                            if (orderByComparator.isAscending() ^ previous) {
9179                                                    query.append(WHERE_GREATER_THAN);
9180                                            }
9181                                            else {
9182                                                    query.append(WHERE_LESSER_THAN);
9183                                            }
9184                                    }
9185                            }
9186    
9187                            query.append(ORDER_BY_CLAUSE);
9188    
9189                            String[] orderByFields = orderByComparator.getOrderByFields();
9190    
9191                            for (int i = 0; i < orderByFields.length; i++) {
9192                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9193                                    query.append(orderByFields[i]);
9194    
9195                                    if ((i + 1) < orderByFields.length) {
9196                                            if (orderByComparator.isAscending() ^ previous) {
9197                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9198                                            }
9199                                            else {
9200                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9201                                            }
9202                                    }
9203                                    else {
9204                                            if (orderByComparator.isAscending() ^ previous) {
9205                                                    query.append(ORDER_BY_ASC);
9206                                            }
9207                                            else {
9208                                                    query.append(ORDER_BY_DESC);
9209                                            }
9210                                    }
9211                            }
9212                    }
9213                    else {
9214                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9215                    }
9216    
9217                    String sql = query.toString();
9218    
9219                    Query q = session.createQuery(sql);
9220    
9221                    q.setFirstResult(0);
9222                    q.setMaxResults(2);
9223    
9224                    QueryPos qPos = QueryPos.getInstance(q);
9225    
9226                    qPos.add(companyId);
9227    
9228                    qPos.add(userId);
9229    
9230                    qPos.add(status);
9231    
9232                    if (orderByComparator != null) {
9233                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9234    
9235                            for (Object value : values) {
9236                                    qPos.add(value);
9237                            }
9238                    }
9239    
9240                    List<BlogsEntry> list = q.list();
9241    
9242                    if (list.size() == 2) {
9243                            return list.get(1);
9244                    }
9245                    else {
9246                            return null;
9247                    }
9248            }
9249    
9250            /**
9251             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
9252             *
9253             * @param companyId the company ID
9254             * @param userId the user ID
9255             * @param status the status
9256             * @throws SystemException if a system exception occurred
9257             */
9258            public void removeByC_U_S(long companyId, long userId, int status)
9259                    throws SystemException {
9260                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
9261                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9262                            remove(blogsEntry);
9263                    }
9264            }
9265    
9266            /**
9267             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9268             *
9269             * @param companyId the company ID
9270             * @param userId the user ID
9271             * @param status the status
9272             * @return the number of matching blogs entries
9273             * @throws SystemException if a system exception occurred
9274             */
9275            public int countByC_U_S(long companyId, long userId, int status)
9276                    throws SystemException {
9277                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
9278    
9279                    Object[] finderArgs = new Object[] { companyId, userId, status };
9280    
9281                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9282                                    this);
9283    
9284                    if (count == null) {
9285                            StringBundler query = new StringBundler(4);
9286    
9287                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9288    
9289                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9290    
9291                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9292    
9293                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9294    
9295                            String sql = query.toString();
9296    
9297                            Session session = null;
9298    
9299                            try {
9300                                    session = openSession();
9301    
9302                                    Query q = session.createQuery(sql);
9303    
9304                                    QueryPos qPos = QueryPos.getInstance(q);
9305    
9306                                    qPos.add(companyId);
9307    
9308                                    qPos.add(userId);
9309    
9310                                    qPos.add(status);
9311    
9312                                    count = (Long)q.uniqueResult();
9313    
9314                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9315                            }
9316                            catch (Exception e) {
9317                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9318    
9319                                    throw processException(e);
9320                            }
9321                            finally {
9322                                    closeSession(session);
9323                            }
9324                    }
9325    
9326                    return count.intValue();
9327            }
9328    
9329            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9330            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
9331            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
9332            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
9333                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9334                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9335                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
9336                            new String[] {
9337                                    Long.class.getName(), Date.class.getName(),
9338                                    Integer.class.getName(),
9339                                    
9340                            Integer.class.getName(), Integer.class.getName(),
9341                                    OrderByComparator.class.getName()
9342                            });
9343            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
9344                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9345                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9346                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
9347                            new String[] {
9348                                    Long.class.getName(), Date.class.getName(),
9349                                    Integer.class.getName()
9350                            });
9351    
9352            /**
9353             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9354             *
9355             * @param companyId the company ID
9356             * @param displayDate the display date
9357             * @param status the status
9358             * @return the matching blogs entries
9359             * @throws SystemException if a system exception occurred
9360             */
9361            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9362                    int status) throws SystemException {
9363                    return findByC_LtD_NotS(companyId, displayDate, status,
9364                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9365            }
9366    
9367            /**
9368             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9369             *
9370             * <p>
9371             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9372             * </p>
9373             *
9374             * @param companyId the company ID
9375             * @param displayDate the display date
9376             * @param status the status
9377             * @param start the lower bound of the range of blogs entries
9378             * @param end the upper bound of the range of blogs entries (not inclusive)
9379             * @return the range of matching blogs entries
9380             * @throws SystemException if a system exception occurred
9381             */
9382            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9383                    int status, int start, int end) throws SystemException {
9384                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
9385            }
9386    
9387            /**
9388             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9389             *
9390             * <p>
9391             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9392             * </p>
9393             *
9394             * @param companyId the company ID
9395             * @param displayDate the display date
9396             * @param status the status
9397             * @param start the lower bound of the range of blogs entries
9398             * @param end the upper bound of the range of blogs entries (not inclusive)
9399             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9400             * @return the ordered range of matching blogs entries
9401             * @throws SystemException if a system exception occurred
9402             */
9403            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9404                    int status, int start, int end, OrderByComparator orderByComparator)
9405                    throws SystemException {
9406                    boolean pagination = true;
9407                    FinderPath finderPath = null;
9408                    Object[] finderArgs = null;
9409    
9410                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
9411                    finderArgs = new Object[] {
9412                                    companyId, displayDate, status,
9413                                    
9414                                    start, end, orderByComparator
9415                            };
9416    
9417                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9418                                    finderArgs, this);
9419    
9420                    if ((list != null) && !list.isEmpty()) {
9421                            for (BlogsEntry blogsEntry : list) {
9422                                    if ((companyId != blogsEntry.getCompanyId()) ||
9423                                                    !Validator.equals(displayDate,
9424                                                            blogsEntry.getDisplayDate()) ||
9425                                                    (status != blogsEntry.getStatus())) {
9426                                            list = null;
9427    
9428                                            break;
9429                                    }
9430                            }
9431                    }
9432    
9433                    if (list == null) {
9434                            StringBundler query = null;
9435    
9436                            if (orderByComparator != null) {
9437                                    query = new StringBundler(5 +
9438                                                    (orderByComparator.getOrderByFields().length * 3));
9439                            }
9440                            else {
9441                                    query = new StringBundler(5);
9442                            }
9443    
9444                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9445    
9446                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9447    
9448                            if (displayDate == null) {
9449                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9450                            }
9451                            else {
9452                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9453                            }
9454    
9455                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9456    
9457                            if (orderByComparator != null) {
9458                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9459                                            orderByComparator);
9460                            }
9461                            else
9462                             if (pagination) {
9463                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9464                            }
9465    
9466                            String sql = query.toString();
9467    
9468                            Session session = null;
9469    
9470                            try {
9471                                    session = openSession();
9472    
9473                                    Query q = session.createQuery(sql);
9474    
9475                                    QueryPos qPos = QueryPos.getInstance(q);
9476    
9477                                    qPos.add(companyId);
9478    
9479                                    if (displayDate != null) {
9480                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9481                                    }
9482    
9483                                    qPos.add(status);
9484    
9485                                    if (!pagination) {
9486                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9487                                                            start, end, false);
9488    
9489                                            Collections.sort(list);
9490    
9491                                            list = new UnmodifiableList<BlogsEntry>(list);
9492                                    }
9493                                    else {
9494                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9495                                                            start, end);
9496                                    }
9497    
9498                                    cacheResult(list);
9499    
9500                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9501                            }
9502                            catch (Exception e) {
9503                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9504    
9505                                    throw processException(e);
9506                            }
9507                            finally {
9508                                    closeSession(session);
9509                            }
9510                    }
9511    
9512                    return list;
9513            }
9514    
9515            /**
9516             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9517             *
9518             * @param companyId the company ID
9519             * @param displayDate the display date
9520             * @param status the status
9521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9522             * @return the first matching blogs entry
9523             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9524             * @throws SystemException if a system exception occurred
9525             */
9526            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
9527                    int status, OrderByComparator orderByComparator)
9528                    throws NoSuchEntryException, SystemException {
9529                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
9530                                    status, orderByComparator);
9531    
9532                    if (blogsEntry != null) {
9533                            return blogsEntry;
9534                    }
9535    
9536                    StringBundler msg = new StringBundler(8);
9537    
9538                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9539    
9540                    msg.append("companyId=");
9541                    msg.append(companyId);
9542    
9543                    msg.append(", displayDate=");
9544                    msg.append(displayDate);
9545    
9546                    msg.append(", status=");
9547                    msg.append(status);
9548    
9549                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9550    
9551                    throw new NoSuchEntryException(msg.toString());
9552            }
9553    
9554            /**
9555             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9556             *
9557             * @param companyId the company ID
9558             * @param displayDate the display date
9559             * @param status the status
9560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9561             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9562             * @throws SystemException if a system exception occurred
9563             */
9564            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
9565                    int status, OrderByComparator orderByComparator)
9566                    throws SystemException {
9567                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9568                                    status, 0, 1, orderByComparator);
9569    
9570                    if (!list.isEmpty()) {
9571                            return list.get(0);
9572                    }
9573    
9574                    return null;
9575            }
9576    
9577            /**
9578             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9579             *
9580             * @param companyId the company ID
9581             * @param displayDate the display date
9582             * @param status the status
9583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9584             * @return the last matching blogs entry
9585             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9586             * @throws SystemException if a system exception occurred
9587             */
9588            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
9589                    int status, OrderByComparator orderByComparator)
9590                    throws NoSuchEntryException, SystemException {
9591                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
9592                                    status, orderByComparator);
9593    
9594                    if (blogsEntry != null) {
9595                            return blogsEntry;
9596                    }
9597    
9598                    StringBundler msg = new StringBundler(8);
9599    
9600                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9601    
9602                    msg.append("companyId=");
9603                    msg.append(companyId);
9604    
9605                    msg.append(", displayDate=");
9606                    msg.append(displayDate);
9607    
9608                    msg.append(", status=");
9609                    msg.append(status);
9610    
9611                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9612    
9613                    throw new NoSuchEntryException(msg.toString());
9614            }
9615    
9616            /**
9617             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9618             *
9619             * @param companyId the company ID
9620             * @param displayDate the display date
9621             * @param status the status
9622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9623             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9624             * @throws SystemException if a system exception occurred
9625             */
9626            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
9627                    int status, OrderByComparator orderByComparator)
9628                    throws SystemException {
9629                    int count = countByC_LtD_NotS(companyId, displayDate, status);
9630    
9631                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9632                                    status, count - 1, count, orderByComparator);
9633    
9634                    if (!list.isEmpty()) {
9635                            return list.get(0);
9636                    }
9637    
9638                    return null;
9639            }
9640    
9641            /**
9642             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9643             *
9644             * @param entryId the primary key of the current blogs entry
9645             * @param companyId the company ID
9646             * @param displayDate the display date
9647             * @param status the status
9648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9649             * @return the previous, current, and next blogs entry
9650             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9651             * @throws SystemException if a system exception occurred
9652             */
9653            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
9654                    long companyId, Date displayDate, int status,
9655                    OrderByComparator orderByComparator)
9656                    throws NoSuchEntryException, SystemException {
9657                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9658    
9659                    Session session = null;
9660    
9661                    try {
9662                            session = openSession();
9663    
9664                            BlogsEntry[] array = new BlogsEntryImpl[3];
9665    
9666                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9667                                            companyId, displayDate, status, orderByComparator, true);
9668    
9669                            array[1] = blogsEntry;
9670    
9671                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9672                                            companyId, displayDate, status, orderByComparator, false);
9673    
9674                            return array;
9675                    }
9676                    catch (Exception e) {
9677                            throw processException(e);
9678                    }
9679                    finally {
9680                            closeSession(session);
9681                    }
9682            }
9683    
9684            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
9685                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
9686                    OrderByComparator orderByComparator, boolean previous) {
9687                    StringBundler query = null;
9688    
9689                    if (orderByComparator != null) {
9690                            query = new StringBundler(6 +
9691                                            (orderByComparator.getOrderByFields().length * 6));
9692                    }
9693                    else {
9694                            query = new StringBundler(3);
9695                    }
9696    
9697                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9698    
9699                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9700    
9701                    if (displayDate == null) {
9702                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9703                    }
9704                    else {
9705                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9706                    }
9707    
9708                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9709    
9710                    if (orderByComparator != null) {
9711                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9712    
9713                            if (orderByConditionFields.length > 0) {
9714                                    query.append(WHERE_AND);
9715                            }
9716    
9717                            for (int i = 0; i < orderByConditionFields.length; i++) {
9718                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9719                                    query.append(orderByConditionFields[i]);
9720    
9721                                    if ((i + 1) < orderByConditionFields.length) {
9722                                            if (orderByComparator.isAscending() ^ previous) {
9723                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9724                                            }
9725                                            else {
9726                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9727                                            }
9728                                    }
9729                                    else {
9730                                            if (orderByComparator.isAscending() ^ previous) {
9731                                                    query.append(WHERE_GREATER_THAN);
9732                                            }
9733                                            else {
9734                                                    query.append(WHERE_LESSER_THAN);
9735                                            }
9736                                    }
9737                            }
9738    
9739                            query.append(ORDER_BY_CLAUSE);
9740    
9741                            String[] orderByFields = orderByComparator.getOrderByFields();
9742    
9743                            for (int i = 0; i < orderByFields.length; i++) {
9744                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9745                                    query.append(orderByFields[i]);
9746    
9747                                    if ((i + 1) < orderByFields.length) {
9748                                            if (orderByComparator.isAscending() ^ previous) {
9749                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9750                                            }
9751                                            else {
9752                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9753                                            }
9754                                    }
9755                                    else {
9756                                            if (orderByComparator.isAscending() ^ previous) {
9757                                                    query.append(ORDER_BY_ASC);
9758                                            }
9759                                            else {
9760                                                    query.append(ORDER_BY_DESC);
9761                                            }
9762                                    }
9763                            }
9764                    }
9765                    else {
9766                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9767                    }
9768    
9769                    String sql = query.toString();
9770    
9771                    Query q = session.createQuery(sql);
9772    
9773                    q.setFirstResult(0);
9774                    q.setMaxResults(2);
9775    
9776                    QueryPos qPos = QueryPos.getInstance(q);
9777    
9778                    qPos.add(companyId);
9779    
9780                    if (displayDate != null) {
9781                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9782                    }
9783    
9784                    qPos.add(status);
9785    
9786                    if (orderByComparator != null) {
9787                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9788    
9789                            for (Object value : values) {
9790                                    qPos.add(value);
9791                            }
9792                    }
9793    
9794                    List<BlogsEntry> list = q.list();
9795    
9796                    if (list.size() == 2) {
9797                            return list.get(1);
9798                    }
9799                    else {
9800                            return null;
9801                    }
9802            }
9803    
9804            /**
9805             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
9806             *
9807             * @param companyId the company ID
9808             * @param displayDate the display date
9809             * @param status the status
9810             * @throws SystemException if a system exception occurred
9811             */
9812            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status)
9813                    throws SystemException {
9814                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
9815                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9816                            remove(blogsEntry);
9817                    }
9818            }
9819    
9820            /**
9821             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9822             *
9823             * @param companyId the company ID
9824             * @param displayDate the display date
9825             * @param status the status
9826             * @return the number of matching blogs entries
9827             * @throws SystemException if a system exception occurred
9828             */
9829            public int countByC_LtD_NotS(long companyId, Date displayDate, int status)
9830                    throws SystemException {
9831                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
9832    
9833                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
9834    
9835                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9836                                    this);
9837    
9838                    if (count == null) {
9839                            StringBundler query = new StringBundler(4);
9840    
9841                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9842    
9843                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9844    
9845                            if (displayDate == null) {
9846                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9847                            }
9848                            else {
9849                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9850                            }
9851    
9852                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9853    
9854                            String sql = query.toString();
9855    
9856                            Session session = null;
9857    
9858                            try {
9859                                    session = openSession();
9860    
9861                                    Query q = session.createQuery(sql);
9862    
9863                                    QueryPos qPos = QueryPos.getInstance(q);
9864    
9865                                    qPos.add(companyId);
9866    
9867                                    if (displayDate != null) {
9868                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9869                                    }
9870    
9871                                    qPos.add(status);
9872    
9873                                    count = (Long)q.uniqueResult();
9874    
9875                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9876                            }
9877                            catch (Exception e) {
9878                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9879    
9880                                    throw processException(e);
9881                            }
9882                            finally {
9883                                    closeSession(session);
9884                            }
9885                    }
9886    
9887                    return count.intValue();
9888            }
9889    
9890            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9891            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
9892            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
9893            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
9894            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9895                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9896                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
9897                            new String[] {
9898                                    Long.class.getName(), Date.class.getName(),
9899                                    Integer.class.getName(),
9900                                    
9901                            Integer.class.getName(), Integer.class.getName(),
9902                                    OrderByComparator.class.getName()
9903                            });
9904            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9905                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9906                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
9907                            new String[] {
9908                                    Long.class.getName(), Date.class.getName(),
9909                                    Integer.class.getName()
9910                            });
9911    
9912            /**
9913             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9914             *
9915             * @param companyId the company ID
9916             * @param displayDate the display date
9917             * @param status the status
9918             * @return the matching blogs entries
9919             * @throws SystemException if a system exception occurred
9920             */
9921            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
9922                    int status) throws SystemException {
9923                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
9924                            QueryUtil.ALL_POS, null);
9925            }
9926    
9927            /**
9928             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9929             *
9930             * <p>
9931             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9932             * </p>
9933             *
9934             * @param companyId the company ID
9935             * @param displayDate the display date
9936             * @param status the status
9937             * @param start the lower bound of the range of blogs entries
9938             * @param end the upper bound of the range of blogs entries (not inclusive)
9939             * @return the range of matching blogs entries
9940             * @throws SystemException if a system exception occurred
9941             */
9942            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
9943                    int status, int start, int end) throws SystemException {
9944                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
9945            }
9946    
9947            /**
9948             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
9949             *
9950             * <p>
9951             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9952             * </p>
9953             *
9954             * @param companyId the company ID
9955             * @param displayDate the display date
9956             * @param status the status
9957             * @param start the lower bound of the range of blogs entries
9958             * @param end the upper bound of the range of blogs entries (not inclusive)
9959             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9960             * @return the ordered range of matching blogs entries
9961             * @throws SystemException if a system exception occurred
9962             */
9963            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
9964                    int status, int start, int end, OrderByComparator orderByComparator)
9965                    throws SystemException {
9966                    boolean pagination = true;
9967                    FinderPath finderPath = null;
9968                    Object[] finderArgs = null;
9969    
9970                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
9971                    finderArgs = new Object[] {
9972                                    companyId, displayDate, status,
9973                                    
9974                                    start, end, orderByComparator
9975                            };
9976    
9977                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9978                                    finderArgs, this);
9979    
9980                    if ((list != null) && !list.isEmpty()) {
9981                            for (BlogsEntry blogsEntry : list) {
9982                                    if ((companyId != blogsEntry.getCompanyId()) ||
9983                                                    !Validator.equals(displayDate,
9984                                                            blogsEntry.getDisplayDate()) ||
9985                                                    (status != blogsEntry.getStatus())) {
9986                                            list = null;
9987    
9988                                            break;
9989                                    }
9990                            }
9991                    }
9992    
9993                    if (list == null) {
9994                            StringBundler query = null;
9995    
9996                            if (orderByComparator != null) {
9997                                    query = new StringBundler(5 +
9998                                                    (orderByComparator.getOrderByFields().length * 3));
9999                            }
10000                            else {
10001                                    query = new StringBundler(5);
10002                            }
10003    
10004                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10005    
10006                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10007    
10008                            if (displayDate == null) {
10009                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10010                            }
10011                            else {
10012                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10013                            }
10014    
10015                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10016    
10017                            if (orderByComparator != null) {
10018                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10019                                            orderByComparator);
10020                            }
10021                            else
10022                             if (pagination) {
10023                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10024                            }
10025    
10026                            String sql = query.toString();
10027    
10028                            Session session = null;
10029    
10030                            try {
10031                                    session = openSession();
10032    
10033                                    Query q = session.createQuery(sql);
10034    
10035                                    QueryPos qPos = QueryPos.getInstance(q);
10036    
10037                                    qPos.add(companyId);
10038    
10039                                    if (displayDate != null) {
10040                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10041                                    }
10042    
10043                                    qPos.add(status);
10044    
10045                                    if (!pagination) {
10046                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10047                                                            start, end, false);
10048    
10049                                            Collections.sort(list);
10050    
10051                                            list = new UnmodifiableList<BlogsEntry>(list);
10052                                    }
10053                                    else {
10054                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10055                                                            start, end);
10056                                    }
10057    
10058                                    cacheResult(list);
10059    
10060                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10061                            }
10062                            catch (Exception e) {
10063                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10064    
10065                                    throw processException(e);
10066                            }
10067                            finally {
10068                                    closeSession(session);
10069                            }
10070                    }
10071    
10072                    return list;
10073            }
10074    
10075            /**
10076             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10077             *
10078             * @param companyId the company ID
10079             * @param displayDate the display date
10080             * @param status the status
10081             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10082             * @return the first matching blogs entry
10083             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10084             * @throws SystemException if a system exception occurred
10085             */
10086            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
10087                    int status, OrderByComparator orderByComparator)
10088                    throws NoSuchEntryException, SystemException {
10089                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
10090                                    status, orderByComparator);
10091    
10092                    if (blogsEntry != null) {
10093                            return blogsEntry;
10094                    }
10095    
10096                    StringBundler msg = new StringBundler(8);
10097    
10098                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10099    
10100                    msg.append("companyId=");
10101                    msg.append(companyId);
10102    
10103                    msg.append(", displayDate=");
10104                    msg.append(displayDate);
10105    
10106                    msg.append(", status=");
10107                    msg.append(status);
10108    
10109                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10110    
10111                    throw new NoSuchEntryException(msg.toString());
10112            }
10113    
10114            /**
10115             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10116             *
10117             * @param companyId the company ID
10118             * @param displayDate the display date
10119             * @param status the status
10120             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10121             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10122             * @throws SystemException if a system exception occurred
10123             */
10124            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
10125                    int status, OrderByComparator orderByComparator)
10126                    throws SystemException {
10127                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10128                                    0, 1, orderByComparator);
10129    
10130                    if (!list.isEmpty()) {
10131                            return list.get(0);
10132                    }
10133    
10134                    return null;
10135            }
10136    
10137            /**
10138             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10139             *
10140             * @param companyId the company ID
10141             * @param displayDate the display date
10142             * @param status the status
10143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10144             * @return the last matching blogs entry
10145             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10146             * @throws SystemException if a system exception occurred
10147             */
10148            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
10149                    int status, OrderByComparator orderByComparator)
10150                    throws NoSuchEntryException, SystemException {
10151                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
10152                                    status, orderByComparator);
10153    
10154                    if (blogsEntry != null) {
10155                            return blogsEntry;
10156                    }
10157    
10158                    StringBundler msg = new StringBundler(8);
10159    
10160                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10161    
10162                    msg.append("companyId=");
10163                    msg.append(companyId);
10164    
10165                    msg.append(", displayDate=");
10166                    msg.append(displayDate);
10167    
10168                    msg.append(", status=");
10169                    msg.append(status);
10170    
10171                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10172    
10173                    throw new NoSuchEntryException(msg.toString());
10174            }
10175    
10176            /**
10177             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10178             *
10179             * @param companyId the company ID
10180             * @param displayDate the display date
10181             * @param status the status
10182             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10183             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10184             * @throws SystemException if a system exception occurred
10185             */
10186            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
10187                    int status, OrderByComparator orderByComparator)
10188                    throws SystemException {
10189                    int count = countByC_LtD_S(companyId, displayDate, status);
10190    
10191                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10192                                    count - 1, count, orderByComparator);
10193    
10194                    if (!list.isEmpty()) {
10195                            return list.get(0);
10196                    }
10197    
10198                    return null;
10199            }
10200    
10201            /**
10202             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10203             *
10204             * @param entryId the primary key of the current blogs entry
10205             * @param companyId the company ID
10206             * @param displayDate the display date
10207             * @param status the status
10208             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10209             * @return the previous, current, and next blogs entry
10210             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10211             * @throws SystemException if a system exception occurred
10212             */
10213            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
10214                    Date displayDate, int status, OrderByComparator orderByComparator)
10215                    throws NoSuchEntryException, SystemException {
10216                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10217    
10218                    Session session = null;
10219    
10220                    try {
10221                            session = openSession();
10222    
10223                            BlogsEntry[] array = new BlogsEntryImpl[3];
10224    
10225                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10226                                            displayDate, status, orderByComparator, true);
10227    
10228                            array[1] = blogsEntry;
10229    
10230                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10231                                            displayDate, status, orderByComparator, false);
10232    
10233                            return array;
10234                    }
10235                    catch (Exception e) {
10236                            throw processException(e);
10237                    }
10238                    finally {
10239                            closeSession(session);
10240                    }
10241            }
10242    
10243            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
10244                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
10245                    OrderByComparator orderByComparator, boolean previous) {
10246                    StringBundler query = null;
10247    
10248                    if (orderByComparator != null) {
10249                            query = new StringBundler(6 +
10250                                            (orderByComparator.getOrderByFields().length * 6));
10251                    }
10252                    else {
10253                            query = new StringBundler(3);
10254                    }
10255    
10256                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10257    
10258                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10259    
10260                    if (displayDate == null) {
10261                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10262                    }
10263                    else {
10264                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10265                    }
10266    
10267                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10268    
10269                    if (orderByComparator != null) {
10270                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10271    
10272                            if (orderByConditionFields.length > 0) {
10273                                    query.append(WHERE_AND);
10274                            }
10275    
10276                            for (int i = 0; i < orderByConditionFields.length; i++) {
10277                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10278                                    query.append(orderByConditionFields[i]);
10279    
10280                                    if ((i + 1) < orderByConditionFields.length) {
10281                                            if (orderByComparator.isAscending() ^ previous) {
10282                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10283                                            }
10284                                            else {
10285                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10286                                            }
10287                                    }
10288                                    else {
10289                                            if (orderByComparator.isAscending() ^ previous) {
10290                                                    query.append(WHERE_GREATER_THAN);
10291                                            }
10292                                            else {
10293                                                    query.append(WHERE_LESSER_THAN);
10294                                            }
10295                                    }
10296                            }
10297    
10298                            query.append(ORDER_BY_CLAUSE);
10299    
10300                            String[] orderByFields = orderByComparator.getOrderByFields();
10301    
10302                            for (int i = 0; i < orderByFields.length; i++) {
10303                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10304                                    query.append(orderByFields[i]);
10305    
10306                                    if ((i + 1) < orderByFields.length) {
10307                                            if (orderByComparator.isAscending() ^ previous) {
10308                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10309                                            }
10310                                            else {
10311                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10312                                            }
10313                                    }
10314                                    else {
10315                                            if (orderByComparator.isAscending() ^ previous) {
10316                                                    query.append(ORDER_BY_ASC);
10317                                            }
10318                                            else {
10319                                                    query.append(ORDER_BY_DESC);
10320                                            }
10321                                    }
10322                            }
10323                    }
10324                    else {
10325                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10326                    }
10327    
10328                    String sql = query.toString();
10329    
10330                    Query q = session.createQuery(sql);
10331    
10332                    q.setFirstResult(0);
10333                    q.setMaxResults(2);
10334    
10335                    QueryPos qPos = QueryPos.getInstance(q);
10336    
10337                    qPos.add(companyId);
10338    
10339                    if (displayDate != null) {
10340                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10341                    }
10342    
10343                    qPos.add(status);
10344    
10345                    if (orderByComparator != null) {
10346                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10347    
10348                            for (Object value : values) {
10349                                    qPos.add(value);
10350                            }
10351                    }
10352    
10353                    List<BlogsEntry> list = q.list();
10354    
10355                    if (list.size() == 2) {
10356                            return list.get(1);
10357                    }
10358                    else {
10359                            return null;
10360                    }
10361            }
10362    
10363            /**
10364             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
10365             *
10366             * @param companyId the company ID
10367             * @param displayDate the display date
10368             * @param status the status
10369             * @throws SystemException if a system exception occurred
10370             */
10371            public void removeByC_LtD_S(long companyId, Date displayDate, int status)
10372                    throws SystemException {
10373                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
10374                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10375                            remove(blogsEntry);
10376                    }
10377            }
10378    
10379            /**
10380             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10381             *
10382             * @param companyId the company ID
10383             * @param displayDate the display date
10384             * @param status the status
10385             * @return the number of matching blogs entries
10386             * @throws SystemException if a system exception occurred
10387             */
10388            public int countByC_LtD_S(long companyId, Date displayDate, int status)
10389                    throws SystemException {
10390                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
10391    
10392                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
10393    
10394                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10395                                    this);
10396    
10397                    if (count == null) {
10398                            StringBundler query = new StringBundler(4);
10399    
10400                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10401    
10402                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10403    
10404                            if (displayDate == null) {
10405                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10406                            }
10407                            else {
10408                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10409                            }
10410    
10411                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10412    
10413                            String sql = query.toString();
10414    
10415                            Session session = null;
10416    
10417                            try {
10418                                    session = openSession();
10419    
10420                                    Query q = session.createQuery(sql);
10421    
10422                                    QueryPos qPos = QueryPos.getInstance(q);
10423    
10424                                    qPos.add(companyId);
10425    
10426                                    if (displayDate != null) {
10427                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10428                                    }
10429    
10430                                    qPos.add(status);
10431    
10432                                    count = (Long)q.uniqueResult();
10433    
10434                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10435                            }
10436                            catch (Exception e) {
10437                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10438    
10439                                    throw processException(e);
10440                            }
10441                            finally {
10442                                    closeSession(session);
10443                            }
10444                    }
10445    
10446                    return count.intValue();
10447            }
10448    
10449            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
10450            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
10451            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
10452            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
10453            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10454                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10455                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
10456                            new String[] {
10457                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
10458                                    
10459                            Integer.class.getName(), Integer.class.getName(),
10460                                    OrderByComparator.class.getName()
10461                            });
10462            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10463                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10464                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
10465                            new String[] {
10466                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
10467                            });
10468    
10469            /**
10470             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10471             *
10472             * @param groupId the group ID
10473             * @param userId the user ID
10474             * @param displayDate the display date
10475             * @return the matching blogs entries
10476             * @throws SystemException if a system exception occurred
10477             */
10478            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10479                    Date displayDate) throws SystemException {
10480                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
10481                            QueryUtil.ALL_POS, null);
10482            }
10483    
10484            /**
10485             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10486             *
10487             * <p>
10488             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10489             * </p>
10490             *
10491             * @param groupId the group ID
10492             * @param userId the user ID
10493             * @param displayDate the display date
10494             * @param start the lower bound of the range of blogs entries
10495             * @param end the upper bound of the range of blogs entries (not inclusive)
10496             * @return the range of matching blogs entries
10497             * @throws SystemException if a system exception occurred
10498             */
10499            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10500                    Date displayDate, int start, int end) throws SystemException {
10501                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
10502            }
10503    
10504            /**
10505             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10506             *
10507             * <p>
10508             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10509             * </p>
10510             *
10511             * @param groupId the group ID
10512             * @param userId the user ID
10513             * @param displayDate the display date
10514             * @param start the lower bound of the range of blogs entries
10515             * @param end the upper bound of the range of blogs entries (not inclusive)
10516             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10517             * @return the ordered range of matching blogs entries
10518             * @throws SystemException if a system exception occurred
10519             */
10520            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10521                    Date displayDate, int start, int end,
10522                    OrderByComparator orderByComparator) throws SystemException {
10523                    boolean pagination = true;
10524                    FinderPath finderPath = null;
10525                    Object[] finderArgs = null;
10526    
10527                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
10528                    finderArgs = new Object[] {
10529                                    groupId, userId, displayDate,
10530                                    
10531                                    start, end, orderByComparator
10532                            };
10533    
10534                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10535                                    finderArgs, this);
10536    
10537                    if ((list != null) && !list.isEmpty()) {
10538                            for (BlogsEntry blogsEntry : list) {
10539                                    if ((groupId != blogsEntry.getGroupId()) ||
10540                                                    (userId != blogsEntry.getUserId()) ||
10541                                                    !Validator.equals(displayDate,
10542                                                            blogsEntry.getDisplayDate())) {
10543                                            list = null;
10544    
10545                                            break;
10546                                    }
10547                            }
10548                    }
10549    
10550                    if (list == null) {
10551                            StringBundler query = null;
10552    
10553                            if (orderByComparator != null) {
10554                                    query = new StringBundler(5 +
10555                                                    (orderByComparator.getOrderByFields().length * 3));
10556                            }
10557                            else {
10558                                    query = new StringBundler(5);
10559                            }
10560    
10561                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10562    
10563                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10564    
10565                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10566    
10567                            if (displayDate == null) {
10568                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10569                            }
10570                            else {
10571                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10572                            }
10573    
10574                            if (orderByComparator != null) {
10575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10576                                            orderByComparator);
10577                            }
10578                            else
10579                             if (pagination) {
10580                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10581                            }
10582    
10583                            String sql = query.toString();
10584    
10585                            Session session = null;
10586    
10587                            try {
10588                                    session = openSession();
10589    
10590                                    Query q = session.createQuery(sql);
10591    
10592                                    QueryPos qPos = QueryPos.getInstance(q);
10593    
10594                                    qPos.add(groupId);
10595    
10596                                    qPos.add(userId);
10597    
10598                                    if (displayDate != null) {
10599                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10600                                    }
10601    
10602                                    if (!pagination) {
10603                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10604                                                            start, end, false);
10605    
10606                                            Collections.sort(list);
10607    
10608                                            list = new UnmodifiableList<BlogsEntry>(list);
10609                                    }
10610                                    else {
10611                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10612                                                            start, end);
10613                                    }
10614    
10615                                    cacheResult(list);
10616    
10617                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10618                            }
10619                            catch (Exception e) {
10620                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10621    
10622                                    throw processException(e);
10623                            }
10624                            finally {
10625                                    closeSession(session);
10626                            }
10627                    }
10628    
10629                    return list;
10630            }
10631    
10632            /**
10633             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10634             *
10635             * @param groupId the group ID
10636             * @param userId the user ID
10637             * @param displayDate the display date
10638             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10639             * @return the first matching blogs entry
10640             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10641             * @throws SystemException if a system exception occurred
10642             */
10643            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
10644                    Date displayDate, OrderByComparator orderByComparator)
10645                    throws NoSuchEntryException, SystemException {
10646                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
10647                                    displayDate, orderByComparator);
10648    
10649                    if (blogsEntry != null) {
10650                            return blogsEntry;
10651                    }
10652    
10653                    StringBundler msg = new StringBundler(8);
10654    
10655                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10656    
10657                    msg.append("groupId=");
10658                    msg.append(groupId);
10659    
10660                    msg.append(", userId=");
10661                    msg.append(userId);
10662    
10663                    msg.append(", displayDate=");
10664                    msg.append(displayDate);
10665    
10666                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10667    
10668                    throw new NoSuchEntryException(msg.toString());
10669            }
10670    
10671            /**
10672             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10673             *
10674             * @param groupId the group ID
10675             * @param userId the user ID
10676             * @param displayDate the display date
10677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10678             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10679             * @throws SystemException if a system exception occurred
10680             */
10681            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
10682                    Date displayDate, OrderByComparator orderByComparator)
10683                    throws SystemException {
10684                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
10685                                    1, orderByComparator);
10686    
10687                    if (!list.isEmpty()) {
10688                            return list.get(0);
10689                    }
10690    
10691                    return null;
10692            }
10693    
10694            /**
10695             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10696             *
10697             * @param groupId the group ID
10698             * @param userId the user ID
10699             * @param displayDate the display date
10700             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10701             * @return the last matching blogs entry
10702             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10703             * @throws SystemException if a system exception occurred
10704             */
10705            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
10706                    Date displayDate, OrderByComparator orderByComparator)
10707                    throws NoSuchEntryException, SystemException {
10708                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
10709                                    displayDate, orderByComparator);
10710    
10711                    if (blogsEntry != null) {
10712                            return blogsEntry;
10713                    }
10714    
10715                    StringBundler msg = new StringBundler(8);
10716    
10717                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10718    
10719                    msg.append("groupId=");
10720                    msg.append(groupId);
10721    
10722                    msg.append(", userId=");
10723                    msg.append(userId);
10724    
10725                    msg.append(", displayDate=");
10726                    msg.append(displayDate);
10727    
10728                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10729    
10730                    throw new NoSuchEntryException(msg.toString());
10731            }
10732    
10733            /**
10734             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10735             *
10736             * @param groupId the group ID
10737             * @param userId the user ID
10738             * @param displayDate the display date
10739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10740             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10741             * @throws SystemException if a system exception occurred
10742             */
10743            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
10744                    Date displayDate, OrderByComparator orderByComparator)
10745                    throws SystemException {
10746                    int count = countByG_U_LtD(groupId, userId, displayDate);
10747    
10748                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
10749                                    count - 1, count, orderByComparator);
10750    
10751                    if (!list.isEmpty()) {
10752                            return list.get(0);
10753                    }
10754    
10755                    return null;
10756            }
10757    
10758            /**
10759             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10760             *
10761             * @param entryId the primary key of the current blogs entry
10762             * @param groupId the group ID
10763             * @param userId the user ID
10764             * @param displayDate the display date
10765             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10766             * @return the previous, current, and next blogs entry
10767             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10768             * @throws SystemException if a system exception occurred
10769             */
10770            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
10771                    long userId, Date displayDate, OrderByComparator orderByComparator)
10772                    throws NoSuchEntryException, SystemException {
10773                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10774    
10775                    Session session = null;
10776    
10777                    try {
10778                            session = openSession();
10779    
10780                            BlogsEntry[] array = new BlogsEntryImpl[3];
10781    
10782                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
10783                                            userId, displayDate, orderByComparator, true);
10784    
10785                            array[1] = blogsEntry;
10786    
10787                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
10788                                            userId, displayDate, orderByComparator, false);
10789    
10790                            return array;
10791                    }
10792                    catch (Exception e) {
10793                            throw processException(e);
10794                    }
10795                    finally {
10796                            closeSession(session);
10797                    }
10798            }
10799    
10800            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
10801                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
10802                    OrderByComparator orderByComparator, boolean previous) {
10803                    StringBundler query = null;
10804    
10805                    if (orderByComparator != null) {
10806                            query = new StringBundler(6 +
10807                                            (orderByComparator.getOrderByFields().length * 6));
10808                    }
10809                    else {
10810                            query = new StringBundler(3);
10811                    }
10812    
10813                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10814    
10815                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10816    
10817                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10818    
10819                    if (displayDate == null) {
10820                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10821                    }
10822                    else {
10823                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10824                    }
10825    
10826                    if (orderByComparator != null) {
10827                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10828    
10829                            if (orderByConditionFields.length > 0) {
10830                                    query.append(WHERE_AND);
10831                            }
10832    
10833                            for (int i = 0; i < orderByConditionFields.length; i++) {
10834                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10835                                    query.append(orderByConditionFields[i]);
10836    
10837                                    if ((i + 1) < orderByConditionFields.length) {
10838                                            if (orderByComparator.isAscending() ^ previous) {
10839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10840                                            }
10841                                            else {
10842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10843                                            }
10844                                    }
10845                                    else {
10846                                            if (orderByComparator.isAscending() ^ previous) {
10847                                                    query.append(WHERE_GREATER_THAN);
10848                                            }
10849                                            else {
10850                                                    query.append(WHERE_LESSER_THAN);
10851                                            }
10852                                    }
10853                            }
10854    
10855                            query.append(ORDER_BY_CLAUSE);
10856    
10857                            String[] orderByFields = orderByComparator.getOrderByFields();
10858    
10859                            for (int i = 0; i < orderByFields.length; i++) {
10860                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10861                                    query.append(orderByFields[i]);
10862    
10863                                    if ((i + 1) < orderByFields.length) {
10864                                            if (orderByComparator.isAscending() ^ previous) {
10865                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10866                                            }
10867                                            else {
10868                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10869                                            }
10870                                    }
10871                                    else {
10872                                            if (orderByComparator.isAscending() ^ previous) {
10873                                                    query.append(ORDER_BY_ASC);
10874                                            }
10875                                            else {
10876                                                    query.append(ORDER_BY_DESC);
10877                                            }
10878                                    }
10879                            }
10880                    }
10881                    else {
10882                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10883                    }
10884    
10885                    String sql = query.toString();
10886    
10887                    Query q = session.createQuery(sql);
10888    
10889                    q.setFirstResult(0);
10890                    q.setMaxResults(2);
10891    
10892                    QueryPos qPos = QueryPos.getInstance(q);
10893    
10894                    qPos.add(groupId);
10895    
10896                    qPos.add(userId);
10897    
10898                    if (displayDate != null) {
10899                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10900                    }
10901    
10902                    if (orderByComparator != null) {
10903                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10904    
10905                            for (Object value : values) {
10906                                    qPos.add(value);
10907                            }
10908                    }
10909    
10910                    List<BlogsEntry> list = q.list();
10911    
10912                    if (list.size() == 2) {
10913                            return list.get(1);
10914                    }
10915                    else {
10916                            return null;
10917                    }
10918            }
10919    
10920            /**
10921             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10922             *
10923             * @param groupId the group ID
10924             * @param userId the user ID
10925             * @param displayDate the display date
10926             * @return the matching blogs entries that the user has permission to view
10927             * @throws SystemException if a system exception occurred
10928             */
10929            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
10930                    Date displayDate) throws SystemException {
10931                    return filterFindByG_U_LtD(groupId, userId, displayDate,
10932                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10933            }
10934    
10935            /**
10936             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10937             *
10938             * <p>
10939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10940             * </p>
10941             *
10942             * @param groupId the group ID
10943             * @param userId the user ID
10944             * @param displayDate the display date
10945             * @param start the lower bound of the range of blogs entries
10946             * @param end the upper bound of the range of blogs entries (not inclusive)
10947             * @return the range of matching blogs entries that the user has permission to view
10948             * @throws SystemException if a system exception occurred
10949             */
10950            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
10951                    Date displayDate, int start, int end) throws SystemException {
10952                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
10953                            null);
10954            }
10955    
10956            /**
10957             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10958             *
10959             * <p>
10960             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10961             * </p>
10962             *
10963             * @param groupId the group ID
10964             * @param userId the user ID
10965             * @param displayDate the display date
10966             * @param start the lower bound of the range of blogs entries
10967             * @param end the upper bound of the range of blogs entries (not inclusive)
10968             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10969             * @return the ordered range of matching blogs entries that the user has permission to view
10970             * @throws SystemException if a system exception occurred
10971             */
10972            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
10973                    Date displayDate, int start, int end,
10974                    OrderByComparator orderByComparator) throws SystemException {
10975                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10976                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
10977                                    orderByComparator);
10978                    }
10979    
10980                    StringBundler query = null;
10981    
10982                    if (orderByComparator != null) {
10983                            query = new StringBundler(5 +
10984                                            (orderByComparator.getOrderByFields().length * 3));
10985                    }
10986                    else {
10987                            query = new StringBundler(5);
10988                    }
10989    
10990                    if (getDB().isSupportsInlineDistinct()) {
10991                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10992                    }
10993                    else {
10994                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10995                    }
10996    
10997                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10998    
10999                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11000    
11001                    if (displayDate == null) {
11002                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11003                    }
11004                    else {
11005                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11006                    }
11007    
11008                    if (!getDB().isSupportsInlineDistinct()) {
11009                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11010                    }
11011    
11012                    if (orderByComparator != null) {
11013                            if (getDB().isSupportsInlineDistinct()) {
11014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11015                                            orderByComparator);
11016                            }
11017                            else {
11018                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11019                                            orderByComparator);
11020                            }
11021                    }
11022                    else {
11023                            if (getDB().isSupportsInlineDistinct()) {
11024                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11025                            }
11026                            else {
11027                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11028                            }
11029                    }
11030    
11031                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11032                                    BlogsEntry.class.getName(),
11033                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11034    
11035                    Session session = null;
11036    
11037                    try {
11038                            session = openSession();
11039    
11040                            SQLQuery q = session.createSQLQuery(sql);
11041    
11042                            if (getDB().isSupportsInlineDistinct()) {
11043                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11044                            }
11045                            else {
11046                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11047                            }
11048    
11049                            QueryPos qPos = QueryPos.getInstance(q);
11050    
11051                            qPos.add(groupId);
11052    
11053                            qPos.add(userId);
11054    
11055                            if (displayDate != null) {
11056                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11057                            }
11058    
11059                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11060                    }
11061                    catch (Exception e) {
11062                            throw processException(e);
11063                    }
11064                    finally {
11065                            closeSession(session);
11066                    }
11067            }
11068    
11069            /**
11070             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11071             *
11072             * @param entryId the primary key of the current blogs entry
11073             * @param groupId the group ID
11074             * @param userId the user ID
11075             * @param displayDate the display date
11076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11077             * @return the previous, current, and next blogs entry
11078             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11079             * @throws SystemException if a system exception occurred
11080             */
11081            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
11082                    long groupId, long userId, Date displayDate,
11083                    OrderByComparator orderByComparator)
11084                    throws NoSuchEntryException, SystemException {
11085                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11086                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
11087                                    displayDate, orderByComparator);
11088                    }
11089    
11090                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11091    
11092                    Session session = null;
11093    
11094                    try {
11095                            session = openSession();
11096    
11097                            BlogsEntry[] array = new BlogsEntryImpl[3];
11098    
11099                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11100                                            groupId, userId, displayDate, orderByComparator, true);
11101    
11102                            array[1] = blogsEntry;
11103    
11104                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11105                                            groupId, userId, displayDate, orderByComparator, false);
11106    
11107                            return array;
11108                    }
11109                    catch (Exception e) {
11110                            throw processException(e);
11111                    }
11112                    finally {
11113                            closeSession(session);
11114                    }
11115            }
11116    
11117            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
11118                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
11119                    OrderByComparator orderByComparator, boolean previous) {
11120                    StringBundler query = null;
11121    
11122                    if (orderByComparator != null) {
11123                            query = new StringBundler(6 +
11124                                            (orderByComparator.getOrderByFields().length * 6));
11125                    }
11126                    else {
11127                            query = new StringBundler(3);
11128                    }
11129    
11130                    if (getDB().isSupportsInlineDistinct()) {
11131                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11132                    }
11133                    else {
11134                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11135                    }
11136    
11137                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11138    
11139                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11140    
11141                    if (displayDate == null) {
11142                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11143                    }
11144                    else {
11145                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11146                    }
11147    
11148                    if (!getDB().isSupportsInlineDistinct()) {
11149                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11150                    }
11151    
11152                    if (orderByComparator != null) {
11153                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11154    
11155                            if (orderByConditionFields.length > 0) {
11156                                    query.append(WHERE_AND);
11157                            }
11158    
11159                            for (int i = 0; i < orderByConditionFields.length; i++) {
11160                                    if (getDB().isSupportsInlineDistinct()) {
11161                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11162                                    }
11163                                    else {
11164                                            query.append(_ORDER_BY_ENTITY_TABLE);
11165                                    }
11166    
11167                                    query.append(orderByConditionFields[i]);
11168    
11169                                    if ((i + 1) < orderByConditionFields.length) {
11170                                            if (orderByComparator.isAscending() ^ previous) {
11171                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11172                                            }
11173                                            else {
11174                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11175                                            }
11176                                    }
11177                                    else {
11178                                            if (orderByComparator.isAscending() ^ previous) {
11179                                                    query.append(WHERE_GREATER_THAN);
11180                                            }
11181                                            else {
11182                                                    query.append(WHERE_LESSER_THAN);
11183                                            }
11184                                    }
11185                            }
11186    
11187                            query.append(ORDER_BY_CLAUSE);
11188    
11189                            String[] orderByFields = orderByComparator.getOrderByFields();
11190    
11191                            for (int i = 0; i < orderByFields.length; i++) {
11192                                    if (getDB().isSupportsInlineDistinct()) {
11193                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11194                                    }
11195                                    else {
11196                                            query.append(_ORDER_BY_ENTITY_TABLE);
11197                                    }
11198    
11199                                    query.append(orderByFields[i]);
11200    
11201                                    if ((i + 1) < orderByFields.length) {
11202                                            if (orderByComparator.isAscending() ^ previous) {
11203                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11204                                            }
11205                                            else {
11206                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11207                                            }
11208                                    }
11209                                    else {
11210                                            if (orderByComparator.isAscending() ^ previous) {
11211                                                    query.append(ORDER_BY_ASC);
11212                                            }
11213                                            else {
11214                                                    query.append(ORDER_BY_DESC);
11215                                            }
11216                                    }
11217                            }
11218                    }
11219                    else {
11220                            if (getDB().isSupportsInlineDistinct()) {
11221                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11222                            }
11223                            else {
11224                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11225                            }
11226                    }
11227    
11228                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11229                                    BlogsEntry.class.getName(),
11230                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11231    
11232                    SQLQuery q = session.createSQLQuery(sql);
11233    
11234                    q.setFirstResult(0);
11235                    q.setMaxResults(2);
11236    
11237                    if (getDB().isSupportsInlineDistinct()) {
11238                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11239                    }
11240                    else {
11241                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11242                    }
11243    
11244                    QueryPos qPos = QueryPos.getInstance(q);
11245    
11246                    qPos.add(groupId);
11247    
11248                    qPos.add(userId);
11249    
11250                    if (displayDate != null) {
11251                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11252                    }
11253    
11254                    if (orderByComparator != null) {
11255                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11256    
11257                            for (Object value : values) {
11258                                    qPos.add(value);
11259                            }
11260                    }
11261    
11262                    List<BlogsEntry> list = q.list();
11263    
11264                    if (list.size() == 2) {
11265                            return list.get(1);
11266                    }
11267                    else {
11268                            return null;
11269                    }
11270            }
11271    
11272            /**
11273             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
11274             *
11275             * @param groupId the group ID
11276             * @param userId the user ID
11277             * @param displayDate the display date
11278             * @throws SystemException if a system exception occurred
11279             */
11280            public void removeByG_U_LtD(long groupId, long userId, Date displayDate)
11281                    throws SystemException {
11282                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
11283                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11284                            remove(blogsEntry);
11285                    }
11286            }
11287    
11288            /**
11289             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11290             *
11291             * @param groupId the group ID
11292             * @param userId the user ID
11293             * @param displayDate the display date
11294             * @return the number of matching blogs entries
11295             * @throws SystemException if a system exception occurred
11296             */
11297            public int countByG_U_LtD(long groupId, long userId, Date displayDate)
11298                    throws SystemException {
11299                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
11300    
11301                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
11302    
11303                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11304                                    this);
11305    
11306                    if (count == null) {
11307                            StringBundler query = new StringBundler(4);
11308    
11309                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11310    
11311                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11312    
11313                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11314    
11315                            if (displayDate == null) {
11316                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11317                            }
11318                            else {
11319                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11320                            }
11321    
11322                            String sql = query.toString();
11323    
11324                            Session session = null;
11325    
11326                            try {
11327                                    session = openSession();
11328    
11329                                    Query q = session.createQuery(sql);
11330    
11331                                    QueryPos qPos = QueryPos.getInstance(q);
11332    
11333                                    qPos.add(groupId);
11334    
11335                                    qPos.add(userId);
11336    
11337                                    if (displayDate != null) {
11338                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11339                                    }
11340    
11341                                    count = (Long)q.uniqueResult();
11342    
11343                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11344                            }
11345                            catch (Exception e) {
11346                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11347    
11348                                    throw processException(e);
11349                            }
11350                            finally {
11351                                    closeSession(session);
11352                            }
11353                    }
11354    
11355                    return count.intValue();
11356            }
11357    
11358            /**
11359             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11360             *
11361             * @param groupId the group ID
11362             * @param userId the user ID
11363             * @param displayDate the display date
11364             * @return the number of matching blogs entries that the user has permission to view
11365             * @throws SystemException if a system exception occurred
11366             */
11367            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate)
11368                    throws SystemException {
11369                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11370                            return countByG_U_LtD(groupId, userId, displayDate);
11371                    }
11372    
11373                    StringBundler query = new StringBundler(4);
11374    
11375                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11376    
11377                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11378    
11379                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11380    
11381                    if (displayDate == null) {
11382                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11383                    }
11384                    else {
11385                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11386                    }
11387    
11388                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11389                                    BlogsEntry.class.getName(),
11390                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11391    
11392                    Session session = null;
11393    
11394                    try {
11395                            session = openSession();
11396    
11397                            SQLQuery q = session.createSQLQuery(sql);
11398    
11399                            q.addScalar(COUNT_COLUMN_NAME,
11400                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11401    
11402                            QueryPos qPos = QueryPos.getInstance(q);
11403    
11404                            qPos.add(groupId);
11405    
11406                            qPos.add(userId);
11407    
11408                            if (displayDate != null) {
11409                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11410                            }
11411    
11412                            Long count = (Long)q.uniqueResult();
11413    
11414                            return count.intValue();
11415                    }
11416                    catch (Exception e) {
11417                            throw processException(e);
11418                    }
11419                    finally {
11420                            closeSession(session);
11421                    }
11422            }
11423    
11424            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11425            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
11426            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
11427            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
11428            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11429                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11430                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
11431                            new String[] {
11432                                    Long.class.getName(), Long.class.getName(),
11433                                    Integer.class.getName(),
11434                                    
11435                            Integer.class.getName(), Integer.class.getName(),
11436                                    OrderByComparator.class.getName()
11437                            });
11438            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
11439                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11440                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11441                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
11442                            new String[] {
11443                                    Long.class.getName(), Long.class.getName(),
11444                                    Integer.class.getName()
11445                            });
11446    
11447            /**
11448             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11449             *
11450             * @param groupId the group ID
11451             * @param userId the user ID
11452             * @param status the status
11453             * @return the matching blogs entries
11454             * @throws SystemException if a system exception occurred
11455             */
11456            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status)
11457                    throws SystemException {
11458                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11459                            QueryUtil.ALL_POS, null);
11460            }
11461    
11462            /**
11463             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11464             *
11465             * <p>
11466             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11467             * </p>
11468             *
11469             * @param groupId the group ID
11470             * @param userId the user ID
11471             * @param status the status
11472             * @param start the lower bound of the range of blogs entries
11473             * @param end the upper bound of the range of blogs entries (not inclusive)
11474             * @return the range of matching blogs entries
11475             * @throws SystemException if a system exception occurred
11476             */
11477            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11478                    int status, int start, int end) throws SystemException {
11479                    return findByG_U_NotS(groupId, userId, status, start, end, null);
11480            }
11481    
11482            /**
11483             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11484             *
11485             * <p>
11486             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11487             * </p>
11488             *
11489             * @param groupId the group ID
11490             * @param userId the user ID
11491             * @param status the status
11492             * @param start the lower bound of the range of blogs entries
11493             * @param end the upper bound of the range of blogs entries (not inclusive)
11494             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11495             * @return the ordered range of matching blogs entries
11496             * @throws SystemException if a system exception occurred
11497             */
11498            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11499                    int status, int start, int end, OrderByComparator orderByComparator)
11500                    throws SystemException {
11501                    boolean pagination = true;
11502                    FinderPath finderPath = null;
11503                    Object[] finderArgs = null;
11504    
11505                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
11506                    finderArgs = new Object[] {
11507                                    groupId, userId, status,
11508                                    
11509                                    start, end, orderByComparator
11510                            };
11511    
11512                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11513                                    finderArgs, this);
11514    
11515                    if ((list != null) && !list.isEmpty()) {
11516                            for (BlogsEntry blogsEntry : list) {
11517                                    if ((groupId != blogsEntry.getGroupId()) ||
11518                                                    (userId != blogsEntry.getUserId()) ||
11519                                                    (status != blogsEntry.getStatus())) {
11520                                            list = null;
11521    
11522                                            break;
11523                                    }
11524                            }
11525                    }
11526    
11527                    if (list == null) {
11528                            StringBundler query = null;
11529    
11530                            if (orderByComparator != null) {
11531                                    query = new StringBundler(5 +
11532                                                    (orderByComparator.getOrderByFields().length * 3));
11533                            }
11534                            else {
11535                                    query = new StringBundler(5);
11536                            }
11537    
11538                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11539    
11540                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11541    
11542                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11543    
11544                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11545    
11546                            if (orderByComparator != null) {
11547                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11548                                            orderByComparator);
11549                            }
11550                            else
11551                             if (pagination) {
11552                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11553                            }
11554    
11555                            String sql = query.toString();
11556    
11557                            Session session = null;
11558    
11559                            try {
11560                                    session = openSession();
11561    
11562                                    Query q = session.createQuery(sql);
11563    
11564                                    QueryPos qPos = QueryPos.getInstance(q);
11565    
11566                                    qPos.add(groupId);
11567    
11568                                    qPos.add(userId);
11569    
11570                                    qPos.add(status);
11571    
11572                                    if (!pagination) {
11573                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11574                                                            start, end, false);
11575    
11576                                            Collections.sort(list);
11577    
11578                                            list = new UnmodifiableList<BlogsEntry>(list);
11579                                    }
11580                                    else {
11581                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11582                                                            start, end);
11583                                    }
11584    
11585                                    cacheResult(list);
11586    
11587                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11588                            }
11589                            catch (Exception e) {
11590                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11591    
11592                                    throw processException(e);
11593                            }
11594                            finally {
11595                                    closeSession(session);
11596                            }
11597                    }
11598    
11599                    return list;
11600            }
11601    
11602            /**
11603             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11604             *
11605             * @param groupId the group ID
11606             * @param userId the user ID
11607             * @param status the status
11608             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11609             * @return the first matching blogs entry
11610             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11611             * @throws SystemException if a system exception occurred
11612             */
11613            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
11614                    int status, OrderByComparator orderByComparator)
11615                    throws NoSuchEntryException, SystemException {
11616                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
11617                                    orderByComparator);
11618    
11619                    if (blogsEntry != null) {
11620                            return blogsEntry;
11621                    }
11622    
11623                    StringBundler msg = new StringBundler(8);
11624    
11625                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11626    
11627                    msg.append("groupId=");
11628                    msg.append(groupId);
11629    
11630                    msg.append(", userId=");
11631                    msg.append(userId);
11632    
11633                    msg.append(", status=");
11634                    msg.append(status);
11635    
11636                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11637    
11638                    throw new NoSuchEntryException(msg.toString());
11639            }
11640    
11641            /**
11642             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11643             *
11644             * @param groupId the group ID
11645             * @param userId the user ID
11646             * @param status the status
11647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11648             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11649             * @throws SystemException if a system exception occurred
11650             */
11651            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
11652                    int status, OrderByComparator orderByComparator)
11653                    throws SystemException {
11654                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
11655                                    orderByComparator);
11656    
11657                    if (!list.isEmpty()) {
11658                            return list.get(0);
11659                    }
11660    
11661                    return null;
11662            }
11663    
11664            /**
11665             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11666             *
11667             * @param groupId the group ID
11668             * @param userId the user ID
11669             * @param status the status
11670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11671             * @return the last matching blogs entry
11672             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11673             * @throws SystemException if a system exception occurred
11674             */
11675            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
11676                    int status, OrderByComparator orderByComparator)
11677                    throws NoSuchEntryException, SystemException {
11678                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
11679                                    orderByComparator);
11680    
11681                    if (blogsEntry != null) {
11682                            return blogsEntry;
11683                    }
11684    
11685                    StringBundler msg = new StringBundler(8);
11686    
11687                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11688    
11689                    msg.append("groupId=");
11690                    msg.append(groupId);
11691    
11692                    msg.append(", userId=");
11693                    msg.append(userId);
11694    
11695                    msg.append(", status=");
11696                    msg.append(status);
11697    
11698                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11699    
11700                    throw new NoSuchEntryException(msg.toString());
11701            }
11702    
11703            /**
11704             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11705             *
11706             * @param groupId the group ID
11707             * @param userId the user ID
11708             * @param status the status
11709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11710             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11711             * @throws SystemException if a system exception occurred
11712             */
11713            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
11714                    int status, OrderByComparator orderByComparator)
11715                    throws SystemException {
11716                    int count = countByG_U_NotS(groupId, userId, status);
11717    
11718                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
11719                                    count - 1, count, orderByComparator);
11720    
11721                    if (!list.isEmpty()) {
11722                            return list.get(0);
11723                    }
11724    
11725                    return null;
11726            }
11727    
11728            /**
11729             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11730             *
11731             * @param entryId the primary key of the current blogs entry
11732             * @param groupId the group ID
11733             * @param userId the user ID
11734             * @param status the status
11735             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11736             * @return the previous, current, and next blogs entry
11737             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11738             * @throws SystemException if a system exception occurred
11739             */
11740            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
11741                    long userId, int status, OrderByComparator orderByComparator)
11742                    throws NoSuchEntryException, SystemException {
11743                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11744    
11745                    Session session = null;
11746    
11747                    try {
11748                            session = openSession();
11749    
11750                            BlogsEntry[] array = new BlogsEntryImpl[3];
11751    
11752                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11753                                            userId, status, orderByComparator, true);
11754    
11755                            array[1] = blogsEntry;
11756    
11757                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11758                                            userId, status, orderByComparator, false);
11759    
11760                            return array;
11761                    }
11762                    catch (Exception e) {
11763                            throw processException(e);
11764                    }
11765                    finally {
11766                            closeSession(session);
11767                    }
11768            }
11769    
11770            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
11771                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11772                    OrderByComparator orderByComparator, boolean previous) {
11773                    StringBundler query = null;
11774    
11775                    if (orderByComparator != null) {
11776                            query = new StringBundler(6 +
11777                                            (orderByComparator.getOrderByFields().length * 6));
11778                    }
11779                    else {
11780                            query = new StringBundler(3);
11781                    }
11782    
11783                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11784    
11785                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11786    
11787                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11788    
11789                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11790    
11791                    if (orderByComparator != null) {
11792                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11793    
11794                            if (orderByConditionFields.length > 0) {
11795                                    query.append(WHERE_AND);
11796                            }
11797    
11798                            for (int i = 0; i < orderByConditionFields.length; i++) {
11799                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11800                                    query.append(orderByConditionFields[i]);
11801    
11802                                    if ((i + 1) < orderByConditionFields.length) {
11803                                            if (orderByComparator.isAscending() ^ previous) {
11804                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11805                                            }
11806                                            else {
11807                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11808                                            }
11809                                    }
11810                                    else {
11811                                            if (orderByComparator.isAscending() ^ previous) {
11812                                                    query.append(WHERE_GREATER_THAN);
11813                                            }
11814                                            else {
11815                                                    query.append(WHERE_LESSER_THAN);
11816                                            }
11817                                    }
11818                            }
11819    
11820                            query.append(ORDER_BY_CLAUSE);
11821    
11822                            String[] orderByFields = orderByComparator.getOrderByFields();
11823    
11824                            for (int i = 0; i < orderByFields.length; i++) {
11825                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11826                                    query.append(orderByFields[i]);
11827    
11828                                    if ((i + 1) < orderByFields.length) {
11829                                            if (orderByComparator.isAscending() ^ previous) {
11830                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11831                                            }
11832                                            else {
11833                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11834                                            }
11835                                    }
11836                                    else {
11837                                            if (orderByComparator.isAscending() ^ previous) {
11838                                                    query.append(ORDER_BY_ASC);
11839                                            }
11840                                            else {
11841                                                    query.append(ORDER_BY_DESC);
11842                                            }
11843                                    }
11844                            }
11845                    }
11846                    else {
11847                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11848                    }
11849    
11850                    String sql = query.toString();
11851    
11852                    Query q = session.createQuery(sql);
11853    
11854                    q.setFirstResult(0);
11855                    q.setMaxResults(2);
11856    
11857                    QueryPos qPos = QueryPos.getInstance(q);
11858    
11859                    qPos.add(groupId);
11860    
11861                    qPos.add(userId);
11862    
11863                    qPos.add(status);
11864    
11865                    if (orderByComparator != null) {
11866                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11867    
11868                            for (Object value : values) {
11869                                    qPos.add(value);
11870                            }
11871                    }
11872    
11873                    List<BlogsEntry> list = q.list();
11874    
11875                    if (list.size() == 2) {
11876                            return list.get(1);
11877                    }
11878                    else {
11879                            return null;
11880                    }
11881            }
11882    
11883            /**
11884             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11885             *
11886             * @param groupId the group ID
11887             * @param userId the user ID
11888             * @param status the status
11889             * @return the matching blogs entries that the user has permission to view
11890             * @throws SystemException if a system exception occurred
11891             */
11892            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11893                    int status) throws SystemException {
11894                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11895                            QueryUtil.ALL_POS, null);
11896            }
11897    
11898            /**
11899             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11900             *
11901             * <p>
11902             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11903             * </p>
11904             *
11905             * @param groupId the group ID
11906             * @param userId the user ID
11907             * @param status the status
11908             * @param start the lower bound of the range of blogs entries
11909             * @param end the upper bound of the range of blogs entries (not inclusive)
11910             * @return the range of matching blogs entries that the user has permission to view
11911             * @throws SystemException if a system exception occurred
11912             */
11913            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11914                    int status, int start, int end) throws SystemException {
11915                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
11916            }
11917    
11918            /**
11919             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11920             *
11921             * <p>
11922             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11923             * </p>
11924             *
11925             * @param groupId the group ID
11926             * @param userId the user ID
11927             * @param status the status
11928             * @param start the lower bound of the range of blogs entries
11929             * @param end the upper bound of the range of blogs entries (not inclusive)
11930             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11931             * @return the ordered range of matching blogs entries that the user has permission to view
11932             * @throws SystemException if a system exception occurred
11933             */
11934            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11935                    int status, int start, int end, OrderByComparator orderByComparator)
11936                    throws SystemException {
11937                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11938                            return findByG_U_NotS(groupId, userId, status, start, end,
11939                                    orderByComparator);
11940                    }
11941    
11942                    StringBundler query = null;
11943    
11944                    if (orderByComparator != null) {
11945                            query = new StringBundler(5 +
11946                                            (orderByComparator.getOrderByFields().length * 3));
11947                    }
11948                    else {
11949                            query = new StringBundler(5);
11950                    }
11951    
11952                    if (getDB().isSupportsInlineDistinct()) {
11953                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11954                    }
11955                    else {
11956                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11957                    }
11958    
11959                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11960    
11961                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11962    
11963                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11964    
11965                    if (!getDB().isSupportsInlineDistinct()) {
11966                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11967                    }
11968    
11969                    if (orderByComparator != null) {
11970                            if (getDB().isSupportsInlineDistinct()) {
11971                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11972                                            orderByComparator);
11973                            }
11974                            else {
11975                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11976                                            orderByComparator);
11977                            }
11978                    }
11979                    else {
11980                            if (getDB().isSupportsInlineDistinct()) {
11981                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11982                            }
11983                            else {
11984                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11985                            }
11986                    }
11987    
11988                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11989                                    BlogsEntry.class.getName(),
11990                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11991    
11992                    Session session = null;
11993    
11994                    try {
11995                            session = openSession();
11996    
11997                            SQLQuery q = session.createSQLQuery(sql);
11998    
11999                            if (getDB().isSupportsInlineDistinct()) {
12000                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12001                            }
12002                            else {
12003                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12004                            }
12005    
12006                            QueryPos qPos = QueryPos.getInstance(q);
12007    
12008                            qPos.add(groupId);
12009    
12010                            qPos.add(userId);
12011    
12012                            qPos.add(status);
12013    
12014                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12015                    }
12016                    catch (Exception e) {
12017                            throw processException(e);
12018                    }
12019                    finally {
12020                            closeSession(session);
12021                    }
12022            }
12023    
12024            /**
12025             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12026             *
12027             * @param entryId the primary key of the current blogs entry
12028             * @param groupId the group ID
12029             * @param userId the user ID
12030             * @param status the status
12031             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12032             * @return the previous, current, and next blogs entry
12033             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12034             * @throws SystemException if a system exception occurred
12035             */
12036            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
12037                    long groupId, long userId, int status,
12038                    OrderByComparator orderByComparator)
12039                    throws NoSuchEntryException, SystemException {
12040                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12041                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
12042                                    orderByComparator);
12043                    }
12044    
12045                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12046    
12047                    Session session = null;
12048    
12049                    try {
12050                            session = openSession();
12051    
12052                            BlogsEntry[] array = new BlogsEntryImpl[3];
12053    
12054                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12055                                            groupId, userId, status, orderByComparator, true);
12056    
12057                            array[1] = blogsEntry;
12058    
12059                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12060                                            groupId, userId, status, orderByComparator, false);
12061    
12062                            return array;
12063                    }
12064                    catch (Exception e) {
12065                            throw processException(e);
12066                    }
12067                    finally {
12068                            closeSession(session);
12069                    }
12070            }
12071    
12072            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
12073                    BlogsEntry blogsEntry, long groupId, long userId, int status,
12074                    OrderByComparator orderByComparator, boolean previous) {
12075                    StringBundler query = null;
12076    
12077                    if (orderByComparator != null) {
12078                            query = new StringBundler(6 +
12079                                            (orderByComparator.getOrderByFields().length * 6));
12080                    }
12081                    else {
12082                            query = new StringBundler(3);
12083                    }
12084    
12085                    if (getDB().isSupportsInlineDistinct()) {
12086                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12087                    }
12088                    else {
12089                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12090                    }
12091    
12092                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12093    
12094                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12095    
12096                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12097    
12098                    if (!getDB().isSupportsInlineDistinct()) {
12099                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12100                    }
12101    
12102                    if (orderByComparator != null) {
12103                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12104    
12105                            if (orderByConditionFields.length > 0) {
12106                                    query.append(WHERE_AND);
12107                            }
12108    
12109                            for (int i = 0; i < orderByConditionFields.length; i++) {
12110                                    if (getDB().isSupportsInlineDistinct()) {
12111                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12112                                    }
12113                                    else {
12114                                            query.append(_ORDER_BY_ENTITY_TABLE);
12115                                    }
12116    
12117                                    query.append(orderByConditionFields[i]);
12118    
12119                                    if ((i + 1) < orderByConditionFields.length) {
12120                                            if (orderByComparator.isAscending() ^ previous) {
12121                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12122                                            }
12123                                            else {
12124                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12125                                            }
12126                                    }
12127                                    else {
12128                                            if (orderByComparator.isAscending() ^ previous) {
12129                                                    query.append(WHERE_GREATER_THAN);
12130                                            }
12131                                            else {
12132                                                    query.append(WHERE_LESSER_THAN);
12133                                            }
12134                                    }
12135                            }
12136    
12137                            query.append(ORDER_BY_CLAUSE);
12138    
12139                            String[] orderByFields = orderByComparator.getOrderByFields();
12140    
12141                            for (int i = 0; i < orderByFields.length; i++) {
12142                                    if (getDB().isSupportsInlineDistinct()) {
12143                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12144                                    }
12145                                    else {
12146                                            query.append(_ORDER_BY_ENTITY_TABLE);
12147                                    }
12148    
12149                                    query.append(orderByFields[i]);
12150    
12151                                    if ((i + 1) < orderByFields.length) {
12152                                            if (orderByComparator.isAscending() ^ previous) {
12153                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12154                                            }
12155                                            else {
12156                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12157                                            }
12158                                    }
12159                                    else {
12160                                            if (orderByComparator.isAscending() ^ previous) {
12161                                                    query.append(ORDER_BY_ASC);
12162                                            }
12163                                            else {
12164                                                    query.append(ORDER_BY_DESC);
12165                                            }
12166                                    }
12167                            }
12168                    }
12169                    else {
12170                            if (getDB().isSupportsInlineDistinct()) {
12171                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12172                            }
12173                            else {
12174                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12175                            }
12176                    }
12177    
12178                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12179                                    BlogsEntry.class.getName(),
12180                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12181    
12182                    SQLQuery q = session.createSQLQuery(sql);
12183    
12184                    q.setFirstResult(0);
12185                    q.setMaxResults(2);
12186    
12187                    if (getDB().isSupportsInlineDistinct()) {
12188                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12189                    }
12190                    else {
12191                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12192                    }
12193    
12194                    QueryPos qPos = QueryPos.getInstance(q);
12195    
12196                    qPos.add(groupId);
12197    
12198                    qPos.add(userId);
12199    
12200                    qPos.add(status);
12201    
12202                    if (orderByComparator != null) {
12203                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12204    
12205                            for (Object value : values) {
12206                                    qPos.add(value);
12207                            }
12208                    }
12209    
12210                    List<BlogsEntry> list = q.list();
12211    
12212                    if (list.size() == 2) {
12213                            return list.get(1);
12214                    }
12215                    else {
12216                            return null;
12217                    }
12218            }
12219    
12220            /**
12221             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
12222             *
12223             * @param groupId the group ID
12224             * @param userId the user ID
12225             * @param status the status
12226             * @throws SystemException if a system exception occurred
12227             */
12228            public void removeByG_U_NotS(long groupId, long userId, int status)
12229                    throws SystemException {
12230                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
12231                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12232                            remove(blogsEntry);
12233                    }
12234            }
12235    
12236            /**
12237             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12238             *
12239             * @param groupId the group ID
12240             * @param userId the user ID
12241             * @param status the status
12242             * @return the number of matching blogs entries
12243             * @throws SystemException if a system exception occurred
12244             */
12245            public int countByG_U_NotS(long groupId, long userId, int status)
12246                    throws SystemException {
12247                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
12248    
12249                    Object[] finderArgs = new Object[] { groupId, userId, status };
12250    
12251                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12252                                    this);
12253    
12254                    if (count == null) {
12255                            StringBundler query = new StringBundler(4);
12256    
12257                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12258    
12259                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12260    
12261                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12262    
12263                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12264    
12265                            String sql = query.toString();
12266    
12267                            Session session = null;
12268    
12269                            try {
12270                                    session = openSession();
12271    
12272                                    Query q = session.createQuery(sql);
12273    
12274                                    QueryPos qPos = QueryPos.getInstance(q);
12275    
12276                                    qPos.add(groupId);
12277    
12278                                    qPos.add(userId);
12279    
12280                                    qPos.add(status);
12281    
12282                                    count = (Long)q.uniqueResult();
12283    
12284                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12285                            }
12286                            catch (Exception e) {
12287                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12288    
12289                                    throw processException(e);
12290                            }
12291                            finally {
12292                                    closeSession(session);
12293                            }
12294                    }
12295    
12296                    return count.intValue();
12297            }
12298    
12299            /**
12300             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12301             *
12302             * @param groupId the group ID
12303             * @param userId the user ID
12304             * @param status the status
12305             * @return the number of matching blogs entries that the user has permission to view
12306             * @throws SystemException if a system exception occurred
12307             */
12308            public int filterCountByG_U_NotS(long groupId, long userId, int status)
12309                    throws SystemException {
12310                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12311                            return countByG_U_NotS(groupId, userId, status);
12312                    }
12313    
12314                    StringBundler query = new StringBundler(4);
12315    
12316                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12317    
12318                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12319    
12320                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12321    
12322                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12323    
12324                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12325                                    BlogsEntry.class.getName(),
12326                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12327    
12328                    Session session = null;
12329    
12330                    try {
12331                            session = openSession();
12332    
12333                            SQLQuery q = session.createSQLQuery(sql);
12334    
12335                            q.addScalar(COUNT_COLUMN_NAME,
12336                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12337    
12338                            QueryPos qPos = QueryPos.getInstance(q);
12339    
12340                            qPos.add(groupId);
12341    
12342                            qPos.add(userId);
12343    
12344                            qPos.add(status);
12345    
12346                            Long count = (Long)q.uniqueResult();
12347    
12348                            return count.intValue();
12349                    }
12350                    catch (Exception e) {
12351                            throw processException(e);
12352                    }
12353                    finally {
12354                            closeSession(session);
12355                    }
12356            }
12357    
12358            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12359            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
12360            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
12361            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12362                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12363                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
12364                            new String[] {
12365                                    Long.class.getName(), Long.class.getName(),
12366                                    Integer.class.getName(),
12367                                    
12368                            Integer.class.getName(), Integer.class.getName(),
12369                                    OrderByComparator.class.getName()
12370                            });
12371            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12372                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12373                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
12374                            new String[] {
12375                                    Long.class.getName(), Long.class.getName(),
12376                                    Integer.class.getName()
12377                            },
12378                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
12379                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
12380                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
12381                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
12382                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
12383            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12384                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12385                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
12386                            new String[] {
12387                                    Long.class.getName(), Long.class.getName(),
12388                                    Integer.class.getName()
12389                            });
12390    
12391            /**
12392             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12393             *
12394             * @param groupId the group ID
12395             * @param userId the user ID
12396             * @param status the status
12397             * @return the matching blogs entries
12398             * @throws SystemException if a system exception occurred
12399             */
12400            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status)
12401                    throws SystemException {
12402                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
12403                            QueryUtil.ALL_POS, null);
12404            }
12405    
12406            /**
12407             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12408             *
12409             * <p>
12410             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12411             * </p>
12412             *
12413             * @param groupId the group ID
12414             * @param userId the user ID
12415             * @param status the status
12416             * @param start the lower bound of the range of blogs entries
12417             * @param end the upper bound of the range of blogs entries (not inclusive)
12418             * @return the range of matching blogs entries
12419             * @throws SystemException if a system exception occurred
12420             */
12421            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12422                    int start, int end) throws SystemException {
12423                    return findByG_U_S(groupId, userId, status, start, end, null);
12424            }
12425    
12426            /**
12427             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12428             *
12429             * <p>
12430             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12431             * </p>
12432             *
12433             * @param groupId the group ID
12434             * @param userId the user ID
12435             * @param status the status
12436             * @param start the lower bound of the range of blogs entries
12437             * @param end the upper bound of the range of blogs entries (not inclusive)
12438             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12439             * @return the ordered range of matching blogs entries
12440             * @throws SystemException if a system exception occurred
12441             */
12442            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12443                    int start, int end, OrderByComparator orderByComparator)
12444                    throws SystemException {
12445                    boolean pagination = true;
12446                    FinderPath finderPath = null;
12447                    Object[] finderArgs = null;
12448    
12449                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12450                                    (orderByComparator == null)) {
12451                            pagination = false;
12452                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
12453                            finderArgs = new Object[] { groupId, userId, status };
12454                    }
12455                    else {
12456                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
12457                            finderArgs = new Object[] {
12458                                            groupId, userId, status,
12459                                            
12460                                            start, end, orderByComparator
12461                                    };
12462                    }
12463    
12464                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
12465                                    finderArgs, this);
12466    
12467                    if ((list != null) && !list.isEmpty()) {
12468                            for (BlogsEntry blogsEntry : list) {
12469                                    if ((groupId != blogsEntry.getGroupId()) ||
12470                                                    (userId != blogsEntry.getUserId()) ||
12471                                                    (status != blogsEntry.getStatus())) {
12472                                            list = null;
12473    
12474                                            break;
12475                                    }
12476                            }
12477                    }
12478    
12479                    if (list == null) {
12480                            StringBundler query = null;
12481    
12482                            if (orderByComparator != null) {
12483                                    query = new StringBundler(5 +
12484                                                    (orderByComparator.getOrderByFields().length * 3));
12485                            }
12486                            else {
12487                                    query = new StringBundler(5);
12488                            }
12489    
12490                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12491    
12492                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
12493    
12494                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
12495    
12496                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
12497    
12498                            if (orderByComparator != null) {
12499                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12500                                            orderByComparator);
12501                            }
12502                            else
12503                             if (pagination) {
12504                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12505                            }
12506    
12507                            String sql = query.toString();
12508    
12509                            Session session = null;
12510    
12511                            try {
12512                                    session = openSession();
12513    
12514                                    Query q = session.createQuery(sql);
12515    
12516                                    QueryPos qPos = QueryPos.getInstance(q);
12517    
12518                                    qPos.add(groupId);
12519    
12520                                    qPos.add(userId);
12521    
12522                                    qPos.add(status);
12523    
12524                                    if (!pagination) {
12525                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12526                                                            start, end, false);
12527    
12528                                            Collections.sort(list);
12529    
12530                                            list = new UnmodifiableList<BlogsEntry>(list);
12531                                    }
12532                                    else {
12533                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12534                                                            start, end);
12535                                    }
12536    
12537                                    cacheResult(list);
12538    
12539                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12540                            }
12541                            catch (Exception e) {
12542                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12543    
12544                                    throw processException(e);
12545                            }
12546                            finally {
12547                                    closeSession(session);
12548                            }
12549                    }
12550    
12551                    return list;
12552            }
12553    
12554            /**
12555             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
12556             *
12557             * @param groupId the group ID
12558             * @param userId the user ID
12559             * @param status the status
12560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12561             * @return the first matching blogs entry
12562             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12563             * @throws SystemException if a system exception occurred
12564             */
12565            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
12566                    OrderByComparator orderByComparator)
12567                    throws NoSuchEntryException, SystemException {
12568                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
12569                                    orderByComparator);
12570    
12571                    if (blogsEntry != null) {
12572                            return blogsEntry;
12573                    }
12574    
12575                    StringBundler msg = new StringBundler(8);
12576    
12577                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12578    
12579                    msg.append("groupId=");
12580                    msg.append(groupId);
12581    
12582                    msg.append(", userId=");
12583                    msg.append(userId);
12584    
12585                    msg.append(", status=");
12586                    msg.append(status);
12587    
12588                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12589    
12590                    throw new NoSuchEntryException(msg.toString());
12591            }
12592    
12593            /**
12594             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
12595             *
12596             * @param groupId the group ID
12597             * @param userId the user ID
12598             * @param status the status
12599             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12600             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12601             * @throws SystemException if a system exception occurred
12602             */
12603            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
12604                    OrderByComparator orderByComparator) throws SystemException {
12605                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
12606                                    orderByComparator);
12607    
12608                    if (!list.isEmpty()) {
12609                            return list.get(0);
12610                    }
12611    
12612                    return null;
12613            }
12614    
12615            /**
12616             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
12617             *
12618             * @param groupId the group ID
12619             * @param userId the user ID
12620             * @param status the status
12621             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12622             * @return the last matching blogs entry
12623             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12624             * @throws SystemException if a system exception occurred
12625             */
12626            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
12627                    OrderByComparator orderByComparator)
12628                    throws NoSuchEntryException, SystemException {
12629                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
12630                                    orderByComparator);
12631    
12632                    if (blogsEntry != null) {
12633                            return blogsEntry;
12634                    }
12635    
12636                    StringBundler msg = new StringBundler(8);
12637    
12638                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12639    
12640                    msg.append("groupId=");
12641                    msg.append(groupId);
12642    
12643                    msg.append(", userId=");
12644                    msg.append(userId);
12645    
12646                    msg.append(", status=");
12647                    msg.append(status);
12648    
12649                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12650    
12651                    throw new NoSuchEntryException(msg.toString());
12652            }
12653    
12654            /**
12655             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
12656             *
12657             * @param groupId the group ID
12658             * @param userId the user ID
12659             * @param status the status
12660             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12661             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12662             * @throws SystemException if a system exception occurred
12663             */
12664            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
12665                    OrderByComparator orderByComparator) throws SystemException {
12666                    int count = countByG_U_S(groupId, userId, status);
12667    
12668                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
12669                                    count, orderByComparator);
12670    
12671                    if (!list.isEmpty()) {
12672                            return list.get(0);
12673                    }
12674    
12675                    return null;
12676            }
12677    
12678            /**
12679             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
12680             *
12681             * @param entryId the primary key of the current blogs entry
12682             * @param groupId the group ID
12683             * @param userId the user ID
12684             * @param status the status
12685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12686             * @return the previous, current, and next blogs entry
12687             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12688             * @throws SystemException if a system exception occurred
12689             */
12690            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
12691                    long userId, int status, OrderByComparator orderByComparator)
12692                    throws NoSuchEntryException, SystemException {
12693                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12694    
12695                    Session session = null;
12696    
12697                    try {
12698                            session = openSession();
12699    
12700                            BlogsEntry[] array = new BlogsEntryImpl[3];
12701    
12702                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
12703                                            userId, status, orderByComparator, true);
12704    
12705                            array[1] = blogsEntry;
12706    
12707                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
12708                                            userId, status, orderByComparator, false);
12709    
12710                            return array;
12711                    }
12712                    catch (Exception e) {
12713                            throw processException(e);
12714                    }
12715                    finally {
12716                            closeSession(session);
12717                    }
12718            }
12719    
12720            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
12721                    BlogsEntry blogsEntry, long groupId, long userId, int status,
12722                    OrderByComparator orderByComparator, boolean previous) {
12723                    StringBundler query = null;
12724    
12725                    if (orderByComparator != null) {
12726                            query = new StringBundler(6 +
12727                                            (orderByComparator.getOrderByFields().length * 6));
12728                    }
12729                    else {
12730                            query = new StringBundler(3);
12731                    }
12732    
12733                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12734    
12735                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
12736    
12737                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
12738    
12739                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
12740    
12741                    if (orderByComparator != null) {
12742                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12743    
12744                            if (orderByConditionFields.length > 0) {
12745                                    query.append(WHERE_AND);
12746                            }
12747    
12748                            for (int i = 0; i < orderByConditionFields.length; i++) {
12749                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12750                                    query.append(orderByConditionFields[i]);
12751    
12752                                    if ((i + 1) < orderByConditionFields.length) {
12753                                            if (orderByComparator.isAscending() ^ previous) {
12754                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12755                                            }
12756                                            else {
12757                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12758                                            }
12759                                    }
12760                                    else {
12761                                            if (orderByComparator.isAscending() ^ previous) {
12762                                                    query.append(WHERE_GREATER_THAN);
12763                                            }
12764                                            else {
12765                                                    query.append(WHERE_LESSER_THAN);
12766                                            }
12767                                    }
12768                            }
12769    
12770                            query.append(ORDER_BY_CLAUSE);
12771    
12772                            String[] orderByFields = orderByComparator.getOrderByFields();
12773    
12774                            for (int i = 0; i < orderByFields.length; i++) {
12775                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12776                                    query.append(orderByFields[i]);
12777    
12778                                    if ((i + 1) < orderByFields.length) {
12779                                            if (orderByComparator.isAscending() ^ previous) {
12780                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12781                                            }
12782                                            else {
12783                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12784                                            }
12785                                    }
12786                                    else {
12787                                            if (orderByComparator.isAscending() ^ previous) {
12788                                                    query.append(ORDER_BY_ASC);
12789                                            }
12790                                            else {
12791                                                    query.append(ORDER_BY_DESC);
12792                                            }
12793                                    }
12794                            }
12795                    }
12796                    else {
12797                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12798                    }
12799    
12800                    String sql = query.toString();
12801    
12802                    Query q = session.createQuery(sql);
12803    
12804                    q.setFirstResult(0);
12805                    q.setMaxResults(2);
12806    
12807                    QueryPos qPos = QueryPos.getInstance(q);
12808    
12809                    qPos.add(groupId);
12810    
12811                    qPos.add(userId);
12812    
12813                    qPos.add(status);
12814    
12815                    if (orderByComparator != null) {
12816                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12817    
12818                            for (Object value : values) {
12819                                    qPos.add(value);
12820                            }
12821                    }
12822    
12823                    List<BlogsEntry> list = q.list();
12824    
12825                    if (list.size() == 2) {
12826                            return list.get(1);
12827                    }
12828                    else {
12829                            return null;
12830                    }
12831            }
12832    
12833            /**
12834             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
12835             *
12836             * @param groupId the group ID
12837             * @param userId the user ID
12838             * @param status the status
12839             * @return the matching blogs entries that the user has permission to view
12840             * @throws SystemException if a system exception occurred
12841             */
12842            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
12843                    int status) throws SystemException {
12844                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
12845                            QueryUtil.ALL_POS, null);
12846            }
12847    
12848            /**
12849             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
12850             *
12851             * <p>
12852             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12853             * </p>
12854             *
12855             * @param groupId the group ID
12856             * @param userId the user ID
12857             * @param status the status
12858             * @param start the lower bound of the range of blogs entries
12859             * @param end the upper bound of the range of blogs entries (not inclusive)
12860             * @return the range of matching blogs entries that the user has permission to view
12861             * @throws SystemException if a system exception occurred
12862             */
12863            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
12864                    int status, int start, int end) throws SystemException {
12865                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
12866            }
12867    
12868            /**
12869             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and status = &#63;.
12870             *
12871             * <p>
12872             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12873             * </p>
12874             *
12875             * @param groupId the group ID
12876             * @param userId the user ID
12877             * @param status the status
12878             * @param start the lower bound of the range of blogs entries
12879             * @param end the upper bound of the range of blogs entries (not inclusive)
12880             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12881             * @return the ordered range of matching blogs entries that the user has permission to view
12882             * @throws SystemException if a system exception occurred
12883             */
12884            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
12885                    int status, int start, int end, OrderByComparator orderByComparator)
12886                    throws SystemException {
12887                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12888                            return findByG_U_S(groupId, userId, status, start, end,
12889                                    orderByComparator);
12890                    }
12891    
12892                    StringBundler query = null;
12893    
12894                    if (orderByComparator != null) {
12895                            query = new StringBundler(5 +
12896                                            (orderByComparator.getOrderByFields().length * 3));
12897                    }
12898                    else {
12899                            query = new StringBundler(5);
12900                    }
12901    
12902                    if (getDB().isSupportsInlineDistinct()) {
12903                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12904                    }
12905                    else {
12906                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12907                    }
12908    
12909                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
12910    
12911                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
12912    
12913                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
12914    
12915                    if (!getDB().isSupportsInlineDistinct()) {
12916                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12917                    }
12918    
12919                    if (orderByComparator != null) {
12920                            if (getDB().isSupportsInlineDistinct()) {
12921                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12922                                            orderByComparator);
12923                            }
12924                            else {
12925                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12926                                            orderByComparator);
12927                            }
12928                    }
12929                    else {
12930                            if (getDB().isSupportsInlineDistinct()) {
12931                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12932                            }
12933                            else {
12934                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12935                            }
12936                    }
12937    
12938                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12939                                    BlogsEntry.class.getName(),
12940                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12941    
12942                    Session session = null;
12943    
12944                    try {
12945                            session = openSession();
12946    
12947                            SQLQuery q = session.createSQLQuery(sql);
12948    
12949                            if (getDB().isSupportsInlineDistinct()) {
12950                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12951                            }
12952                            else {
12953                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12954                            }
12955    
12956                            QueryPos qPos = QueryPos.getInstance(q);
12957    
12958                            qPos.add(groupId);
12959    
12960                            qPos.add(userId);
12961    
12962                            qPos.add(status);
12963    
12964                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12965                    }
12966                    catch (Exception e) {
12967                            throw processException(e);
12968                    }
12969                    finally {
12970                            closeSession(session);
12971                    }
12972            }
12973    
12974            /**
12975             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
12976             *
12977             * @param entryId the primary key of the current blogs entry
12978             * @param groupId the group ID
12979             * @param userId the user ID
12980             * @param status the status
12981             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12982             * @return the previous, current, and next blogs entry
12983             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12984             * @throws SystemException if a system exception occurred
12985             */
12986            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
12987                    long groupId, long userId, int status,
12988                    OrderByComparator orderByComparator)
12989                    throws NoSuchEntryException, SystemException {
12990                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12991                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
12992                                    orderByComparator);
12993                    }
12994    
12995                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12996    
12997                    Session session = null;
12998    
12999                    try {
13000                            session = openSession();
13001    
13002                            BlogsEntry[] array = new BlogsEntryImpl[3];
13003    
13004                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13005                                            groupId, userId, status, orderByComparator, true);
13006    
13007                            array[1] = blogsEntry;
13008    
13009                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13010                                            groupId, userId, status, orderByComparator, false);
13011    
13012                            return array;
13013                    }
13014                    catch (Exception e) {
13015                            throw processException(e);
13016                    }
13017                    finally {
13018                            closeSession(session);
13019                    }
13020            }
13021    
13022            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
13023                    BlogsEntry blogsEntry, long groupId, long userId, int status,
13024                    OrderByComparator orderByComparator, boolean previous) {
13025                    StringBundler query = null;
13026    
13027                    if (orderByComparator != null) {
13028                            query = new StringBundler(6 +
13029                                            (orderByComparator.getOrderByFields().length * 6));
13030                    }
13031                    else {
13032                            query = new StringBundler(3);
13033                    }
13034    
13035                    if (getDB().isSupportsInlineDistinct()) {
13036                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13037                    }
13038                    else {
13039                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13040                    }
13041    
13042                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13043    
13044                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13045    
13046                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13047    
13048                    if (!getDB().isSupportsInlineDistinct()) {
13049                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13050                    }
13051    
13052                    if (orderByComparator != null) {
13053                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13054    
13055                            if (orderByConditionFields.length > 0) {
13056                                    query.append(WHERE_AND);
13057                            }
13058    
13059                            for (int i = 0; i < orderByConditionFields.length; i++) {
13060                                    if (getDB().isSupportsInlineDistinct()) {
13061                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13062                                    }
13063                                    else {
13064                                            query.append(_ORDER_BY_ENTITY_TABLE);
13065                                    }
13066    
13067                                    query.append(orderByConditionFields[i]);
13068    
13069                                    if ((i + 1) < orderByConditionFields.length) {
13070                                            if (orderByComparator.isAscending() ^ previous) {
13071                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13072                                            }
13073                                            else {
13074                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13075                                            }
13076                                    }
13077                                    else {
13078                                            if (orderByComparator.isAscending() ^ previous) {
13079                                                    query.append(WHERE_GREATER_THAN);
13080                                            }
13081                                            else {
13082                                                    query.append(WHERE_LESSER_THAN);
13083                                            }
13084                                    }
13085                            }
13086    
13087                            query.append(ORDER_BY_CLAUSE);
13088    
13089                            String[] orderByFields = orderByComparator.getOrderByFields();
13090    
13091                            for (int i = 0; i < orderByFields.length; i++) {
13092                                    if (getDB().isSupportsInlineDistinct()) {
13093                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13094                                    }
13095                                    else {
13096                                            query.append(_ORDER_BY_ENTITY_TABLE);
13097                                    }
13098    
13099                                    query.append(orderByFields[i]);
13100    
13101                                    if ((i + 1) < orderByFields.length) {
13102                                            if (orderByComparator.isAscending() ^ previous) {
13103                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13104                                            }
13105                                            else {
13106                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13107                                            }
13108                                    }
13109                                    else {
13110                                            if (orderByComparator.isAscending() ^ previous) {
13111                                                    query.append(ORDER_BY_ASC);
13112                                            }
13113                                            else {
13114                                                    query.append(ORDER_BY_DESC);
13115                                            }
13116                                    }
13117                            }
13118                    }
13119                    else {
13120                            if (getDB().isSupportsInlineDistinct()) {
13121                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13122                            }
13123                            else {
13124                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13125                            }
13126                    }
13127    
13128                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13129                                    BlogsEntry.class.getName(),
13130                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13131    
13132                    SQLQuery q = session.createSQLQuery(sql);
13133    
13134                    q.setFirstResult(0);
13135                    q.setMaxResults(2);
13136    
13137                    if (getDB().isSupportsInlineDistinct()) {
13138                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13139                    }
13140                    else {
13141                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13142                    }
13143    
13144                    QueryPos qPos = QueryPos.getInstance(q);
13145    
13146                    qPos.add(groupId);
13147    
13148                    qPos.add(userId);
13149    
13150                    qPos.add(status);
13151    
13152                    if (orderByComparator != null) {
13153                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13154    
13155                            for (Object value : values) {
13156                                    qPos.add(value);
13157                            }
13158                    }
13159    
13160                    List<BlogsEntry> list = q.list();
13161    
13162                    if (list.size() == 2) {
13163                            return list.get(1);
13164                    }
13165                    else {
13166                            return null;
13167                    }
13168            }
13169    
13170            /**
13171             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
13172             *
13173             * @param groupId the group ID
13174             * @param userId the user ID
13175             * @param status the status
13176             * @throws SystemException if a system exception occurred
13177             */
13178            public void removeByG_U_S(long groupId, long userId, int status)
13179                    throws SystemException {
13180                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
13181                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13182                            remove(blogsEntry);
13183                    }
13184            }
13185    
13186            /**
13187             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
13188             *
13189             * @param groupId the group ID
13190             * @param userId the user ID
13191             * @param status the status
13192             * @return the number of matching blogs entries
13193             * @throws SystemException if a system exception occurred
13194             */
13195            public int countByG_U_S(long groupId, long userId, int status)
13196                    throws SystemException {
13197                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
13198    
13199                    Object[] finderArgs = new Object[] { groupId, userId, status };
13200    
13201                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13202                                    this);
13203    
13204                    if (count == null) {
13205                            StringBundler query = new StringBundler(4);
13206    
13207                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13208    
13209                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13210    
13211                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13212    
13213                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13214    
13215                            String sql = query.toString();
13216    
13217                            Session session = null;
13218    
13219                            try {
13220                                    session = openSession();
13221    
13222                                    Query q = session.createQuery(sql);
13223    
13224                                    QueryPos qPos = QueryPos.getInstance(q);
13225    
13226                                    qPos.add(groupId);
13227    
13228                                    qPos.add(userId);
13229    
13230                                    qPos.add(status);
13231    
13232                                    count = (Long)q.uniqueResult();
13233    
13234                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13235                            }
13236                            catch (Exception e) {
13237                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13238    
13239                                    throw processException(e);
13240                            }
13241                            finally {
13242                                    closeSession(session);
13243                            }
13244                    }
13245    
13246                    return count.intValue();
13247            }
13248    
13249            /**
13250             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
13251             *
13252             * @param groupId the group ID
13253             * @param userId the user ID
13254             * @param status the status
13255             * @return the number of matching blogs entries that the user has permission to view
13256             * @throws SystemException if a system exception occurred
13257             */
13258            public int filterCountByG_U_S(long groupId, long userId, int status)
13259                    throws SystemException {
13260                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13261                            return countByG_U_S(groupId, userId, status);
13262                    }
13263    
13264                    StringBundler query = new StringBundler(4);
13265    
13266                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13267    
13268                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13269    
13270                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13271    
13272                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13273    
13274                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13275                                    BlogsEntry.class.getName(),
13276                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13277    
13278                    Session session = null;
13279    
13280                    try {
13281                            session = openSession();
13282    
13283                            SQLQuery q = session.createSQLQuery(sql);
13284    
13285                            q.addScalar(COUNT_COLUMN_NAME,
13286                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13287    
13288                            QueryPos qPos = QueryPos.getInstance(q);
13289    
13290                            qPos.add(groupId);
13291    
13292                            qPos.add(userId);
13293    
13294                            qPos.add(status);
13295    
13296                            Long count = (Long)q.uniqueResult();
13297    
13298                            return count.intValue();
13299                    }
13300                    catch (Exception e) {
13301                            throw processException(e);
13302                    }
13303                    finally {
13304                            closeSession(session);
13305                    }
13306            }
13307    
13308            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13309            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
13310            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
13311            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
13312                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13313                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13314                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
13315                            new String[] {
13316                                    Long.class.getName(), Date.class.getName(),
13317                                    Integer.class.getName(),
13318                                    
13319                            Integer.class.getName(), Integer.class.getName(),
13320                                    OrderByComparator.class.getName()
13321                            });
13322            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
13323                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13324                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13325                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
13326                            new String[] {
13327                                    Long.class.getName(), Date.class.getName(),
13328                                    Integer.class.getName()
13329                            });
13330    
13331            /**
13332             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13333             *
13334             * @param groupId the group ID
13335             * @param displayDate the display date
13336             * @param status the status
13337             * @return the matching blogs entries
13338             * @throws SystemException if a system exception occurred
13339             */
13340            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13341                    int status) throws SystemException {
13342                    return findByG_LtD_NotS(groupId, displayDate, status,
13343                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13344            }
13345    
13346            /**
13347             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13348             *
13349             * <p>
13350             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13351             * </p>
13352             *
13353             * @param groupId the group ID
13354             * @param displayDate the display date
13355             * @param status the status
13356             * @param start the lower bound of the range of blogs entries
13357             * @param end the upper bound of the range of blogs entries (not inclusive)
13358             * @return the range of matching blogs entries
13359             * @throws SystemException if a system exception occurred
13360             */
13361            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13362                    int status, int start, int end) throws SystemException {
13363                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
13364            }
13365    
13366            /**
13367             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13368             *
13369             * <p>
13370             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13371             * </p>
13372             *
13373             * @param groupId the group ID
13374             * @param displayDate the display date
13375             * @param status the status
13376             * @param start the lower bound of the range of blogs entries
13377             * @param end the upper bound of the range of blogs entries (not inclusive)
13378             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13379             * @return the ordered range of matching blogs entries
13380             * @throws SystemException if a system exception occurred
13381             */
13382            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13383                    int status, int start, int end, OrderByComparator orderByComparator)
13384                    throws SystemException {
13385                    boolean pagination = true;
13386                    FinderPath finderPath = null;
13387                    Object[] finderArgs = null;
13388    
13389                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
13390                    finderArgs = new Object[] {
13391                                    groupId, displayDate, status,
13392                                    
13393                                    start, end, orderByComparator
13394                            };
13395    
13396                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13397                                    finderArgs, this);
13398    
13399                    if ((list != null) && !list.isEmpty()) {
13400                            for (BlogsEntry blogsEntry : list) {
13401                                    if ((groupId != blogsEntry.getGroupId()) ||
13402                                                    !Validator.equals(displayDate,
13403                                                            blogsEntry.getDisplayDate()) ||
13404                                                    (status != blogsEntry.getStatus())) {
13405                                            list = null;
13406    
13407                                            break;
13408                                    }
13409                            }
13410                    }
13411    
13412                    if (list == null) {
13413                            StringBundler query = null;
13414    
13415                            if (orderByComparator != null) {
13416                                    query = new StringBundler(5 +
13417                                                    (orderByComparator.getOrderByFields().length * 3));
13418                            }
13419                            else {
13420                                    query = new StringBundler(5);
13421                            }
13422    
13423                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13424    
13425                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13426    
13427                            if (displayDate == null) {
13428                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13429                            }
13430                            else {
13431                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13432                            }
13433    
13434                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13435    
13436                            if (orderByComparator != null) {
13437                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13438                                            orderByComparator);
13439                            }
13440                            else
13441                             if (pagination) {
13442                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13443                            }
13444    
13445                            String sql = query.toString();
13446    
13447                            Session session = null;
13448    
13449                            try {
13450                                    session = openSession();
13451    
13452                                    Query q = session.createQuery(sql);
13453    
13454                                    QueryPos qPos = QueryPos.getInstance(q);
13455    
13456                                    qPos.add(groupId);
13457    
13458                                    if (displayDate != null) {
13459                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13460                                    }
13461    
13462                                    qPos.add(status);
13463    
13464                                    if (!pagination) {
13465                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13466                                                            start, end, false);
13467    
13468                                            Collections.sort(list);
13469    
13470                                            list = new UnmodifiableList<BlogsEntry>(list);
13471                                    }
13472                                    else {
13473                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13474                                                            start, end);
13475                                    }
13476    
13477                                    cacheResult(list);
13478    
13479                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13480                            }
13481                            catch (Exception e) {
13482                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13483    
13484                                    throw processException(e);
13485                            }
13486                            finally {
13487                                    closeSession(session);
13488                            }
13489                    }
13490    
13491                    return list;
13492            }
13493    
13494            /**
13495             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13496             *
13497             * @param groupId the group ID
13498             * @param displayDate the display date
13499             * @param status the status
13500             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13501             * @return the first matching blogs entry
13502             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13503             * @throws SystemException if a system exception occurred
13504             */
13505            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
13506                    int status, OrderByComparator orderByComparator)
13507                    throws NoSuchEntryException, SystemException {
13508                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
13509                                    status, orderByComparator);
13510    
13511                    if (blogsEntry != null) {
13512                            return blogsEntry;
13513                    }
13514    
13515                    StringBundler msg = new StringBundler(8);
13516    
13517                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13518    
13519                    msg.append("groupId=");
13520                    msg.append(groupId);
13521    
13522                    msg.append(", displayDate=");
13523                    msg.append(displayDate);
13524    
13525                    msg.append(", status=");
13526                    msg.append(status);
13527    
13528                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13529    
13530                    throw new NoSuchEntryException(msg.toString());
13531            }
13532    
13533            /**
13534             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13535             *
13536             * @param groupId the group ID
13537             * @param displayDate the display date
13538             * @param status the status
13539             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13540             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13541             * @throws SystemException if a system exception occurred
13542             */
13543            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
13544                    int status, OrderByComparator orderByComparator)
13545                    throws SystemException {
13546                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13547                                    0, 1, orderByComparator);
13548    
13549                    if (!list.isEmpty()) {
13550                            return list.get(0);
13551                    }
13552    
13553                    return null;
13554            }
13555    
13556            /**
13557             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13558             *
13559             * @param groupId the group ID
13560             * @param displayDate the display date
13561             * @param status the status
13562             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13563             * @return the last matching blogs entry
13564             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13565             * @throws SystemException if a system exception occurred
13566             */
13567            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
13568                    int status, OrderByComparator orderByComparator)
13569                    throws NoSuchEntryException, SystemException {
13570                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
13571                                    status, orderByComparator);
13572    
13573                    if (blogsEntry != null) {
13574                            return blogsEntry;
13575                    }
13576    
13577                    StringBundler msg = new StringBundler(8);
13578    
13579                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13580    
13581                    msg.append("groupId=");
13582                    msg.append(groupId);
13583    
13584                    msg.append(", displayDate=");
13585                    msg.append(displayDate);
13586    
13587                    msg.append(", status=");
13588                    msg.append(status);
13589    
13590                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13591    
13592                    throw new NoSuchEntryException(msg.toString());
13593            }
13594    
13595            /**
13596             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13597             *
13598             * @param groupId the group ID
13599             * @param displayDate the display date
13600             * @param status the status
13601             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13602             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13603             * @throws SystemException if a system exception occurred
13604             */
13605            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
13606                    int status, OrderByComparator orderByComparator)
13607                    throws SystemException {
13608                    int count = countByG_LtD_NotS(groupId, displayDate, status);
13609    
13610                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13611                                    count - 1, count, orderByComparator);
13612    
13613                    if (!list.isEmpty()) {
13614                            return list.get(0);
13615                    }
13616    
13617                    return null;
13618            }
13619    
13620            /**
13621             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13622             *
13623             * @param entryId the primary key of the current blogs entry
13624             * @param groupId the group ID
13625             * @param displayDate the display date
13626             * @param status the status
13627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13628             * @return the previous, current, and next blogs entry
13629             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13630             * @throws SystemException if a system exception occurred
13631             */
13632            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
13633                    long groupId, Date displayDate, int status,
13634                    OrderByComparator orderByComparator)
13635                    throws NoSuchEntryException, SystemException {
13636                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13637    
13638                    Session session = null;
13639    
13640                    try {
13641                            session = openSession();
13642    
13643                            BlogsEntry[] array = new BlogsEntryImpl[3];
13644    
13645                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13646                                            groupId, displayDate, status, orderByComparator, true);
13647    
13648                            array[1] = blogsEntry;
13649    
13650                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13651                                            groupId, displayDate, status, orderByComparator, false);
13652    
13653                            return array;
13654                    }
13655                    catch (Exception e) {
13656                            throw processException(e);
13657                    }
13658                    finally {
13659                            closeSession(session);
13660                    }
13661            }
13662    
13663            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
13664                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13665                    OrderByComparator orderByComparator, boolean previous) {
13666                    StringBundler query = null;
13667    
13668                    if (orderByComparator != null) {
13669                            query = new StringBundler(6 +
13670                                            (orderByComparator.getOrderByFields().length * 6));
13671                    }
13672                    else {
13673                            query = new StringBundler(3);
13674                    }
13675    
13676                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13677    
13678                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13679    
13680                    if (displayDate == null) {
13681                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13682                    }
13683                    else {
13684                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13685                    }
13686    
13687                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13688    
13689                    if (orderByComparator != null) {
13690                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13691    
13692                            if (orderByConditionFields.length > 0) {
13693                                    query.append(WHERE_AND);
13694                            }
13695    
13696                            for (int i = 0; i < orderByConditionFields.length; i++) {
13697                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13698                                    query.append(orderByConditionFields[i]);
13699    
13700                                    if ((i + 1) < orderByConditionFields.length) {
13701                                            if (orderByComparator.isAscending() ^ previous) {
13702                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13703                                            }
13704                                            else {
13705                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13706                                            }
13707                                    }
13708                                    else {
13709                                            if (orderByComparator.isAscending() ^ previous) {
13710                                                    query.append(WHERE_GREATER_THAN);
13711                                            }
13712                                            else {
13713                                                    query.append(WHERE_LESSER_THAN);
13714                                            }
13715                                    }
13716                            }
13717    
13718                            query.append(ORDER_BY_CLAUSE);
13719    
13720                            String[] orderByFields = orderByComparator.getOrderByFields();
13721    
13722                            for (int i = 0; i < orderByFields.length; i++) {
13723                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13724                                    query.append(orderByFields[i]);
13725    
13726                                    if ((i + 1) < orderByFields.length) {
13727                                            if (orderByComparator.isAscending() ^ previous) {
13728                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13729                                            }
13730                                            else {
13731                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13732                                            }
13733                                    }
13734                                    else {
13735                                            if (orderByComparator.isAscending() ^ previous) {
13736                                                    query.append(ORDER_BY_ASC);
13737                                            }
13738                                            else {
13739                                                    query.append(ORDER_BY_DESC);
13740                                            }
13741                                    }
13742                            }
13743                    }
13744                    else {
13745                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13746                    }
13747    
13748                    String sql = query.toString();
13749    
13750                    Query q = session.createQuery(sql);
13751    
13752                    q.setFirstResult(0);
13753                    q.setMaxResults(2);
13754    
13755                    QueryPos qPos = QueryPos.getInstance(q);
13756    
13757                    qPos.add(groupId);
13758    
13759                    if (displayDate != null) {
13760                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13761                    }
13762    
13763                    qPos.add(status);
13764    
13765                    if (orderByComparator != null) {
13766                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13767    
13768                            for (Object value : values) {
13769                                    qPos.add(value);
13770                            }
13771                    }
13772    
13773                    List<BlogsEntry> list = q.list();
13774    
13775                    if (list.size() == 2) {
13776                            return list.get(1);
13777                    }
13778                    else {
13779                            return null;
13780                    }
13781            }
13782    
13783            /**
13784             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13785             *
13786             * @param groupId the group ID
13787             * @param displayDate the display date
13788             * @param status the status
13789             * @return the matching blogs entries that the user has permission to view
13790             * @throws SystemException if a system exception occurred
13791             */
13792            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13793                    Date displayDate, int status) throws SystemException {
13794                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
13795                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13796            }
13797    
13798            /**
13799             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13800             *
13801             * <p>
13802             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13803             * </p>
13804             *
13805             * @param groupId the group ID
13806             * @param displayDate the display date
13807             * @param status the status
13808             * @param start the lower bound of the range of blogs entries
13809             * @param end the upper bound of the range of blogs entries (not inclusive)
13810             * @return the range of matching blogs entries that the user has permission to view
13811             * @throws SystemException if a system exception occurred
13812             */
13813            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13814                    Date displayDate, int status, int start, int end)
13815                    throws SystemException {
13816                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13817                            null);
13818            }
13819    
13820            /**
13821             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13822             *
13823             * <p>
13824             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13825             * </p>
13826             *
13827             * @param groupId the group ID
13828             * @param displayDate the display date
13829             * @param status the status
13830             * @param start the lower bound of the range of blogs entries
13831             * @param end the upper bound of the range of blogs entries (not inclusive)
13832             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13833             * @return the ordered range of matching blogs entries that the user has permission to view
13834             * @throws SystemException if a system exception occurred
13835             */
13836            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13837                    Date displayDate, int status, int start, int end,
13838                    OrderByComparator orderByComparator) throws SystemException {
13839                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13840                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13841                                    orderByComparator);
13842                    }
13843    
13844                    StringBundler query = null;
13845    
13846                    if (orderByComparator != null) {
13847                            query = new StringBundler(5 +
13848                                            (orderByComparator.getOrderByFields().length * 3));
13849                    }
13850                    else {
13851                            query = new StringBundler(5);
13852                    }
13853    
13854                    if (getDB().isSupportsInlineDistinct()) {
13855                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13856                    }
13857                    else {
13858                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13859                    }
13860    
13861                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13862    
13863                    if (displayDate == null) {
13864                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13865                    }
13866                    else {
13867                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13868                    }
13869    
13870                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13871    
13872                    if (!getDB().isSupportsInlineDistinct()) {
13873                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13874                    }
13875    
13876                    if (orderByComparator != null) {
13877                            if (getDB().isSupportsInlineDistinct()) {
13878                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13879                                            orderByComparator);
13880                            }
13881                            else {
13882                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13883                                            orderByComparator);
13884                            }
13885                    }
13886                    else {
13887                            if (getDB().isSupportsInlineDistinct()) {
13888                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13889                            }
13890                            else {
13891                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13892                            }
13893                    }
13894    
13895                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13896                                    BlogsEntry.class.getName(),
13897                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13898    
13899                    Session session = null;
13900    
13901                    try {
13902                            session = openSession();
13903    
13904                            SQLQuery q = session.createSQLQuery(sql);
13905    
13906                            if (getDB().isSupportsInlineDistinct()) {
13907                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13908                            }
13909                            else {
13910                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13911                            }
13912    
13913                            QueryPos qPos = QueryPos.getInstance(q);
13914    
13915                            qPos.add(groupId);
13916    
13917                            if (displayDate != null) {
13918                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
13919                            }
13920    
13921                            qPos.add(status);
13922    
13923                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13924                    }
13925                    catch (Exception e) {
13926                            throw processException(e);
13927                    }
13928                    finally {
13929                            closeSession(session);
13930                    }
13931            }
13932    
13933            /**
13934             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13935             *
13936             * @param entryId the primary key of the current blogs entry
13937             * @param groupId the group ID
13938             * @param displayDate the display date
13939             * @param status the status
13940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13941             * @return the previous, current, and next blogs entry
13942             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13943             * @throws SystemException if a system exception occurred
13944             */
13945            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
13946                    long groupId, Date displayDate, int status,
13947                    OrderByComparator orderByComparator)
13948                    throws NoSuchEntryException, SystemException {
13949                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13950                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
13951                                    status, orderByComparator);
13952                    }
13953    
13954                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13955    
13956                    Session session = null;
13957    
13958                    try {
13959                            session = openSession();
13960    
13961                            BlogsEntry[] array = new BlogsEntryImpl[3];
13962    
13963                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13964                                            groupId, displayDate, status, orderByComparator, true);
13965    
13966                            array[1] = blogsEntry;
13967    
13968                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13969                                            groupId, displayDate, status, orderByComparator, false);
13970    
13971                            return array;
13972                    }
13973                    catch (Exception e) {
13974                            throw processException(e);
13975                    }
13976                    finally {
13977                            closeSession(session);
13978                    }
13979            }
13980    
13981            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
13982                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13983                    OrderByComparator orderByComparator, boolean previous) {
13984                    StringBundler query = null;
13985    
13986                    if (orderByComparator != null) {
13987                            query = new StringBundler(6 +
13988                                            (orderByComparator.getOrderByFields().length * 6));
13989                    }
13990                    else {
13991                            query = new StringBundler(3);
13992                    }
13993    
13994                    if (getDB().isSupportsInlineDistinct()) {
13995                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13996                    }
13997                    else {
13998                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13999                    }
14000    
14001                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14002    
14003                    if (displayDate == null) {
14004                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14005                    }
14006                    else {
14007                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14008                    }
14009    
14010                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14011    
14012                    if (!getDB().isSupportsInlineDistinct()) {
14013                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14014                    }
14015    
14016                    if (orderByComparator != null) {
14017                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14018    
14019                            if (orderByConditionFields.length > 0) {
14020                                    query.append(WHERE_AND);
14021                            }
14022    
14023                            for (int i = 0; i < orderByConditionFields.length; i++) {
14024                                    if (getDB().isSupportsInlineDistinct()) {
14025                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14026                                    }
14027                                    else {
14028                                            query.append(_ORDER_BY_ENTITY_TABLE);
14029                                    }
14030    
14031                                    query.append(orderByConditionFields[i]);
14032    
14033                                    if ((i + 1) < orderByConditionFields.length) {
14034                                            if (orderByComparator.isAscending() ^ previous) {
14035                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14036                                            }
14037                                            else {
14038                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14039                                            }
14040                                    }
14041                                    else {
14042                                            if (orderByComparator.isAscending() ^ previous) {
14043                                                    query.append(WHERE_GREATER_THAN);
14044                                            }
14045                                            else {
14046                                                    query.append(WHERE_LESSER_THAN);
14047                                            }
14048                                    }
14049                            }
14050    
14051                            query.append(ORDER_BY_CLAUSE);
14052    
14053                            String[] orderByFields = orderByComparator.getOrderByFields();
14054    
14055                            for (int i = 0; i < orderByFields.length; i++) {
14056                                    if (getDB().isSupportsInlineDistinct()) {
14057                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14058                                    }
14059                                    else {
14060                                            query.append(_ORDER_BY_ENTITY_TABLE);
14061                                    }
14062    
14063                                    query.append(orderByFields[i]);
14064    
14065                                    if ((i + 1) < orderByFields.length) {
14066                                            if (orderByComparator.isAscending() ^ previous) {
14067                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14068                                            }
14069                                            else {
14070                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14071                                            }
14072                                    }
14073                                    else {
14074                                            if (orderByComparator.isAscending() ^ previous) {
14075                                                    query.append(ORDER_BY_ASC);
14076                                            }
14077                                            else {
14078                                                    query.append(ORDER_BY_DESC);
14079                                            }
14080                                    }
14081                            }
14082                    }
14083                    else {
14084                            if (getDB().isSupportsInlineDistinct()) {
14085                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14086                            }
14087                            else {
14088                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14089                            }
14090                    }
14091    
14092                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14093                                    BlogsEntry.class.getName(),
14094                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14095    
14096                    SQLQuery q = session.createSQLQuery(sql);
14097    
14098                    q.setFirstResult(0);
14099                    q.setMaxResults(2);
14100    
14101                    if (getDB().isSupportsInlineDistinct()) {
14102                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14103                    }
14104                    else {
14105                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14106                    }
14107    
14108                    QueryPos qPos = QueryPos.getInstance(q);
14109    
14110                    qPos.add(groupId);
14111    
14112                    if (displayDate != null) {
14113                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14114                    }
14115    
14116                    qPos.add(status);
14117    
14118                    if (orderByComparator != null) {
14119                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14120    
14121                            for (Object value : values) {
14122                                    qPos.add(value);
14123                            }
14124                    }
14125    
14126                    List<BlogsEntry> list = q.list();
14127    
14128                    if (list.size() == 2) {
14129                            return list.get(1);
14130                    }
14131                    else {
14132                            return null;
14133                    }
14134            }
14135    
14136            /**
14137             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
14138             *
14139             * @param groupId the group ID
14140             * @param displayDate the display date
14141             * @param status the status
14142             * @throws SystemException if a system exception occurred
14143             */
14144            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status)
14145                    throws SystemException {
14146                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
14147                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14148                            remove(blogsEntry);
14149                    }
14150            }
14151    
14152            /**
14153             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14154             *
14155             * @param groupId the group ID
14156             * @param displayDate the display date
14157             * @param status the status
14158             * @return the number of matching blogs entries
14159             * @throws SystemException if a system exception occurred
14160             */
14161            public int countByG_LtD_NotS(long groupId, Date displayDate, int status)
14162                    throws SystemException {
14163                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
14164    
14165                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
14166    
14167                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14168                                    this);
14169    
14170                    if (count == null) {
14171                            StringBundler query = new StringBundler(4);
14172    
14173                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14174    
14175                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14176    
14177                            if (displayDate == null) {
14178                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14179                            }
14180                            else {
14181                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14182                            }
14183    
14184                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14185    
14186                            String sql = query.toString();
14187    
14188                            Session session = null;
14189    
14190                            try {
14191                                    session = openSession();
14192    
14193                                    Query q = session.createQuery(sql);
14194    
14195                                    QueryPos qPos = QueryPos.getInstance(q);
14196    
14197                                    qPos.add(groupId);
14198    
14199                                    if (displayDate != null) {
14200                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14201                                    }
14202    
14203                                    qPos.add(status);
14204    
14205                                    count = (Long)q.uniqueResult();
14206    
14207                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14208                            }
14209                            catch (Exception e) {
14210                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14211    
14212                                    throw processException(e);
14213                            }
14214                            finally {
14215                                    closeSession(session);
14216                            }
14217                    }
14218    
14219                    return count.intValue();
14220            }
14221    
14222            /**
14223             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14224             *
14225             * @param groupId the group ID
14226             * @param displayDate the display date
14227             * @param status the status
14228             * @return the number of matching blogs entries that the user has permission to view
14229             * @throws SystemException if a system exception occurred
14230             */
14231            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
14232                    int status) throws SystemException {
14233                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14234                            return countByG_LtD_NotS(groupId, displayDate, status);
14235                    }
14236    
14237                    StringBundler query = new StringBundler(4);
14238    
14239                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
14240    
14241                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14242    
14243                    if (displayDate == null) {
14244                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14245                    }
14246                    else {
14247                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14248                    }
14249    
14250                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14251    
14252                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14253                                    BlogsEntry.class.getName(),
14254                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14255    
14256                    Session session = null;
14257    
14258                    try {
14259                            session = openSession();
14260    
14261                            SQLQuery q = session.createSQLQuery(sql);
14262    
14263                            q.addScalar(COUNT_COLUMN_NAME,
14264                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14265    
14266                            QueryPos qPos = QueryPos.getInstance(q);
14267    
14268                            qPos.add(groupId);
14269    
14270                            if (displayDate != null) {
14271                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14272                            }
14273    
14274                            qPos.add(status);
14275    
14276                            Long count = (Long)q.uniqueResult();
14277    
14278                            return count.intValue();
14279                    }
14280                    catch (Exception e) {
14281                            throw processException(e);
14282                    }
14283                    finally {
14284                            closeSession(session);
14285                    }
14286            }
14287    
14288            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
14289            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
14290            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14291            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
14292            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14293                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14294                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
14295                            new String[] {
14296                                    Long.class.getName(), Date.class.getName(),
14297                                    Integer.class.getName(),
14298                                    
14299                            Integer.class.getName(), Integer.class.getName(),
14300                                    OrderByComparator.class.getName()
14301                            });
14302            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14303                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14304                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
14305                            new String[] {
14306                                    Long.class.getName(), Date.class.getName(),
14307                                    Integer.class.getName()
14308                            });
14309    
14310            /**
14311             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14312             *
14313             * @param groupId the group ID
14314             * @param displayDate the display date
14315             * @param status the status
14316             * @return the matching blogs entries
14317             * @throws SystemException if a system exception occurred
14318             */
14319            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14320                    int status) throws SystemException {
14321                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
14322                            QueryUtil.ALL_POS, null);
14323            }
14324    
14325            /**
14326             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14327             *
14328             * <p>
14329             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14330             * </p>
14331             *
14332             * @param groupId the group ID
14333             * @param displayDate the display date
14334             * @param status the status
14335             * @param start the lower bound of the range of blogs entries
14336             * @param end the upper bound of the range of blogs entries (not inclusive)
14337             * @return the range of matching blogs entries
14338             * @throws SystemException if a system exception occurred
14339             */
14340            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14341                    int status, int start, int end) throws SystemException {
14342                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
14343            }
14344    
14345            /**
14346             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14347             *
14348             * <p>
14349             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14350             * </p>
14351             *
14352             * @param groupId the group ID
14353             * @param displayDate the display date
14354             * @param status the status
14355             * @param start the lower bound of the range of blogs entries
14356             * @param end the upper bound of the range of blogs entries (not inclusive)
14357             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14358             * @return the ordered range of matching blogs entries
14359             * @throws SystemException if a system exception occurred
14360             */
14361            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14362                    int status, int start, int end, OrderByComparator orderByComparator)
14363                    throws SystemException {
14364                    boolean pagination = true;
14365                    FinderPath finderPath = null;
14366                    Object[] finderArgs = null;
14367    
14368                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
14369                    finderArgs = new Object[] {
14370                                    groupId, displayDate, status,
14371                                    
14372                                    start, end, orderByComparator
14373                            };
14374    
14375                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14376                                    finderArgs, this);
14377    
14378                    if ((list != null) && !list.isEmpty()) {
14379                            for (BlogsEntry blogsEntry : list) {
14380                                    if ((groupId != blogsEntry.getGroupId()) ||
14381                                                    !Validator.equals(displayDate,
14382                                                            blogsEntry.getDisplayDate()) ||
14383                                                    (status != blogsEntry.getStatus())) {
14384                                            list = null;
14385    
14386                                            break;
14387                                    }
14388                            }
14389                    }
14390    
14391                    if (list == null) {
14392                            StringBundler query = null;
14393    
14394                            if (orderByComparator != null) {
14395                                    query = new StringBundler(5 +
14396                                                    (orderByComparator.getOrderByFields().length * 3));
14397                            }
14398                            else {
14399                                    query = new StringBundler(5);
14400                            }
14401    
14402                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14403    
14404                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14405    
14406                            if (displayDate == null) {
14407                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14408                            }
14409                            else {
14410                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14411                            }
14412    
14413                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14414    
14415                            if (orderByComparator != null) {
14416                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14417                                            orderByComparator);
14418                            }
14419                            else
14420                             if (pagination) {
14421                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14422                            }
14423    
14424                            String sql = query.toString();
14425    
14426                            Session session = null;
14427    
14428                            try {
14429                                    session = openSession();
14430    
14431                                    Query q = session.createQuery(sql);
14432    
14433                                    QueryPos qPos = QueryPos.getInstance(q);
14434    
14435                                    qPos.add(groupId);
14436    
14437                                    if (displayDate != null) {
14438                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14439                                    }
14440    
14441                                    qPos.add(status);
14442    
14443                                    if (!pagination) {
14444                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14445                                                            start, end, false);
14446    
14447                                            Collections.sort(list);
14448    
14449                                            list = new UnmodifiableList<BlogsEntry>(list);
14450                                    }
14451                                    else {
14452                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14453                                                            start, end);
14454                                    }
14455    
14456                                    cacheResult(list);
14457    
14458                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14459                            }
14460                            catch (Exception e) {
14461                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14462    
14463                                    throw processException(e);
14464                            }
14465                            finally {
14466                                    closeSession(session);
14467                            }
14468                    }
14469    
14470                    return list;
14471            }
14472    
14473            /**
14474             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14475             *
14476             * @param groupId the group ID
14477             * @param displayDate the display date
14478             * @param status the status
14479             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14480             * @return the first matching blogs entry
14481             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14482             * @throws SystemException if a system exception occurred
14483             */
14484            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
14485                    int status, OrderByComparator orderByComparator)
14486                    throws NoSuchEntryException, SystemException {
14487                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
14488                                    status, orderByComparator);
14489    
14490                    if (blogsEntry != null) {
14491                            return blogsEntry;
14492                    }
14493    
14494                    StringBundler msg = new StringBundler(8);
14495    
14496                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14497    
14498                    msg.append("groupId=");
14499                    msg.append(groupId);
14500    
14501                    msg.append(", displayDate=");
14502                    msg.append(displayDate);
14503    
14504                    msg.append(", status=");
14505                    msg.append(status);
14506    
14507                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14508    
14509                    throw new NoSuchEntryException(msg.toString());
14510            }
14511    
14512            /**
14513             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14514             *
14515             * @param groupId the group ID
14516             * @param displayDate the display date
14517             * @param status the status
14518             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14519             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14520             * @throws SystemException if a system exception occurred
14521             */
14522            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
14523                    int status, OrderByComparator orderByComparator)
14524                    throws SystemException {
14525                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
14526                                    1, orderByComparator);
14527    
14528                    if (!list.isEmpty()) {
14529                            return list.get(0);
14530                    }
14531    
14532                    return null;
14533            }
14534    
14535            /**
14536             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14537             *
14538             * @param groupId the group ID
14539             * @param displayDate the display date
14540             * @param status the status
14541             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14542             * @return the last matching blogs entry
14543             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14544             * @throws SystemException if a system exception occurred
14545             */
14546            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
14547                    int status, OrderByComparator orderByComparator)
14548                    throws NoSuchEntryException, SystemException {
14549                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
14550                                    status, orderByComparator);
14551    
14552                    if (blogsEntry != null) {
14553                            return blogsEntry;
14554                    }
14555    
14556                    StringBundler msg = new StringBundler(8);
14557    
14558                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14559    
14560                    msg.append("groupId=");
14561                    msg.append(groupId);
14562    
14563                    msg.append(", displayDate=");
14564                    msg.append(displayDate);
14565    
14566                    msg.append(", status=");
14567                    msg.append(status);
14568    
14569                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14570    
14571                    throw new NoSuchEntryException(msg.toString());
14572            }
14573    
14574            /**
14575             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14576             *
14577             * @param groupId the group ID
14578             * @param displayDate the display date
14579             * @param status the status
14580             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14581             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14582             * @throws SystemException if a system exception occurred
14583             */
14584            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
14585                    int status, OrderByComparator orderByComparator)
14586                    throws SystemException {
14587                    int count = countByG_LtD_S(groupId, displayDate, status);
14588    
14589                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
14590                                    count - 1, count, orderByComparator);
14591    
14592                    if (!list.isEmpty()) {
14593                            return list.get(0);
14594                    }
14595    
14596                    return null;
14597            }
14598    
14599            /**
14600             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14601             *
14602             * @param entryId the primary key of the current blogs entry
14603             * @param groupId the group ID
14604             * @param displayDate the display date
14605             * @param status the status
14606             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14607             * @return the previous, current, and next blogs entry
14608             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14609             * @throws SystemException if a system exception occurred
14610             */
14611            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
14612                    Date displayDate, int status, OrderByComparator orderByComparator)
14613                    throws NoSuchEntryException, SystemException {
14614                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14615    
14616                    Session session = null;
14617    
14618                    try {
14619                            session = openSession();
14620    
14621                            BlogsEntry[] array = new BlogsEntryImpl[3];
14622    
14623                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
14624                                            displayDate, status, orderByComparator, true);
14625    
14626                            array[1] = blogsEntry;
14627    
14628                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
14629                                            displayDate, status, orderByComparator, false);
14630    
14631                            return array;
14632                    }
14633                    catch (Exception e) {
14634                            throw processException(e);
14635                    }
14636                    finally {
14637                            closeSession(session);
14638                    }
14639            }
14640    
14641            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
14642                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14643                    OrderByComparator orderByComparator, boolean previous) {
14644                    StringBundler query = null;
14645    
14646                    if (orderByComparator != null) {
14647                            query = new StringBundler(6 +
14648                                            (orderByComparator.getOrderByFields().length * 6));
14649                    }
14650                    else {
14651                            query = new StringBundler(3);
14652                    }
14653    
14654                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14655    
14656                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14657    
14658                    if (displayDate == null) {
14659                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14660                    }
14661                    else {
14662                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14663                    }
14664    
14665                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14666    
14667                    if (orderByComparator != null) {
14668                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14669    
14670                            if (orderByConditionFields.length > 0) {
14671                                    query.append(WHERE_AND);
14672                            }
14673    
14674                            for (int i = 0; i < orderByConditionFields.length; i++) {
14675                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14676                                    query.append(orderByConditionFields[i]);
14677    
14678                                    if ((i + 1) < orderByConditionFields.length) {
14679                                            if (orderByComparator.isAscending() ^ previous) {
14680                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14681                                            }
14682                                            else {
14683                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14684                                            }
14685                                    }
14686                                    else {
14687                                            if (orderByComparator.isAscending() ^ previous) {
14688                                                    query.append(WHERE_GREATER_THAN);
14689                                            }
14690                                            else {
14691                                                    query.append(WHERE_LESSER_THAN);
14692                                            }
14693                                    }
14694                            }
14695    
14696                            query.append(ORDER_BY_CLAUSE);
14697    
14698                            String[] orderByFields = orderByComparator.getOrderByFields();
14699    
14700                            for (int i = 0; i < orderByFields.length; i++) {
14701                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14702                                    query.append(orderByFields[i]);
14703    
14704                                    if ((i + 1) < orderByFields.length) {
14705                                            if (orderByComparator.isAscending() ^ previous) {
14706                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14707                                            }
14708                                            else {
14709                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14710                                            }
14711                                    }
14712                                    else {
14713                                            if (orderByComparator.isAscending() ^ previous) {
14714                                                    query.append(ORDER_BY_ASC);
14715                                            }
14716                                            else {
14717                                                    query.append(ORDER_BY_DESC);
14718                                            }
14719                                    }
14720                            }
14721                    }
14722                    else {
14723                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14724                    }
14725    
14726                    String sql = query.toString();
14727    
14728                    Query q = session.createQuery(sql);
14729    
14730                    q.setFirstResult(0);
14731                    q.setMaxResults(2);
14732    
14733                    QueryPos qPos = QueryPos.getInstance(q);
14734    
14735                    qPos.add(groupId);
14736    
14737                    if (displayDate != null) {
14738                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14739                    }
14740    
14741                    qPos.add(status);
14742    
14743                    if (orderByComparator != null) {
14744                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14745    
14746                            for (Object value : values) {
14747                                    qPos.add(value);
14748                            }
14749                    }
14750    
14751                    List<BlogsEntry> list = q.list();
14752    
14753                    if (list.size() == 2) {
14754                            return list.get(1);
14755                    }
14756                    else {
14757                            return null;
14758                    }
14759            }
14760    
14761            /**
14762             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14763             *
14764             * @param groupId the group ID
14765             * @param displayDate the display date
14766             * @param status the status
14767             * @return the matching blogs entries that the user has permission to view
14768             * @throws SystemException if a system exception occurred
14769             */
14770            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
14771                    int status) throws SystemException {
14772                    return filterFindByG_LtD_S(groupId, displayDate, status,
14773                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14774            }
14775    
14776            /**
14777             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14778             *
14779             * <p>
14780             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14781             * </p>
14782             *
14783             * @param groupId the group ID
14784             * @param displayDate the display date
14785             * @param status the status
14786             * @param start the lower bound of the range of blogs entries
14787             * @param end the upper bound of the range of blogs entries (not inclusive)
14788             * @return the range of matching blogs entries that the user has permission to view
14789             * @throws SystemException if a system exception occurred
14790             */
14791            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
14792                    int status, int start, int end) throws SystemException {
14793                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
14794                            null);
14795            }
14796    
14797            /**
14798             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14799             *
14800             * <p>
14801             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14802             * </p>
14803             *
14804             * @param groupId the group ID
14805             * @param displayDate the display date
14806             * @param status the status
14807             * @param start the lower bound of the range of blogs entries
14808             * @param end the upper bound of the range of blogs entries (not inclusive)
14809             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14810             * @return the ordered range of matching blogs entries that the user has permission to view
14811             * @throws SystemException if a system exception occurred
14812             */
14813            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
14814                    int status, int start, int end, OrderByComparator orderByComparator)
14815                    throws SystemException {
14816                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14817                            return findByG_LtD_S(groupId, displayDate, status, start, end,
14818                                    orderByComparator);
14819                    }
14820    
14821                    StringBundler query = null;
14822    
14823                    if (orderByComparator != null) {
14824                            query = new StringBundler(5 +
14825                                            (orderByComparator.getOrderByFields().length * 3));
14826                    }
14827                    else {
14828                            query = new StringBundler(5);
14829                    }
14830    
14831                    if (getDB().isSupportsInlineDistinct()) {
14832                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14833                    }
14834                    else {
14835                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14836                    }
14837    
14838                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14839    
14840                    if (displayDate == null) {
14841                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14842                    }
14843                    else {
14844                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14845                    }
14846    
14847                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14848    
14849                    if (!getDB().isSupportsInlineDistinct()) {
14850                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14851                    }
14852    
14853                    if (orderByComparator != null) {
14854                            if (getDB().isSupportsInlineDistinct()) {
14855                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14856                                            orderByComparator);
14857                            }
14858                            else {
14859                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14860                                            orderByComparator);
14861                            }
14862                    }
14863                    else {
14864                            if (getDB().isSupportsInlineDistinct()) {
14865                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14866                            }
14867                            else {
14868                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14869                            }
14870                    }
14871    
14872                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14873                                    BlogsEntry.class.getName(),
14874                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14875    
14876                    Session session = null;
14877    
14878                    try {
14879                            session = openSession();
14880    
14881                            SQLQuery q = session.createSQLQuery(sql);
14882    
14883                            if (getDB().isSupportsInlineDistinct()) {
14884                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14885                            }
14886                            else {
14887                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14888                            }
14889    
14890                            QueryPos qPos = QueryPos.getInstance(q);
14891    
14892                            qPos.add(groupId);
14893    
14894                            if (displayDate != null) {
14895                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14896                            }
14897    
14898                            qPos.add(status);
14899    
14900                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
14901                    }
14902                    catch (Exception e) {
14903                            throw processException(e);
14904                    }
14905                    finally {
14906                            closeSession(session);
14907                    }
14908            }
14909    
14910            /**
14911             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14912             *
14913             * @param entryId the primary key of the current blogs entry
14914             * @param groupId the group ID
14915             * @param displayDate the display date
14916             * @param status the status
14917             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14918             * @return the previous, current, and next blogs entry
14919             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14920             * @throws SystemException if a system exception occurred
14921             */
14922            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
14923                    long groupId, Date displayDate, int status,
14924                    OrderByComparator orderByComparator)
14925                    throws NoSuchEntryException, SystemException {
14926                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14927                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
14928                                    status, orderByComparator);
14929                    }
14930    
14931                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14932    
14933                    Session session = null;
14934    
14935                    try {
14936                            session = openSession();
14937    
14938                            BlogsEntry[] array = new BlogsEntryImpl[3];
14939    
14940                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
14941                                            groupId, displayDate, status, orderByComparator, true);
14942    
14943                            array[1] = blogsEntry;
14944    
14945                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
14946                                            groupId, displayDate, status, orderByComparator, false);
14947    
14948                            return array;
14949                    }
14950                    catch (Exception e) {
14951                            throw processException(e);
14952                    }
14953                    finally {
14954                            closeSession(session);
14955                    }
14956            }
14957    
14958            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
14959                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14960                    OrderByComparator orderByComparator, boolean previous) {
14961                    StringBundler query = null;
14962    
14963                    if (orderByComparator != null) {
14964                            query = new StringBundler(6 +
14965                                            (orderByComparator.getOrderByFields().length * 6));
14966                    }
14967                    else {
14968                            query = new StringBundler(3);
14969                    }
14970    
14971                    if (getDB().isSupportsInlineDistinct()) {
14972                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14973                    }
14974                    else {
14975                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14976                    }
14977    
14978                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14979    
14980                    if (displayDate == null) {
14981                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14982                    }
14983                    else {
14984                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14985                    }
14986    
14987                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14988    
14989                    if (!getDB().isSupportsInlineDistinct()) {
14990                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14991                    }
14992    
14993                    if (orderByComparator != null) {
14994                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14995    
14996                            if (orderByConditionFields.length > 0) {
14997                                    query.append(WHERE_AND);
14998                            }
14999    
15000                            for (int i = 0; i < orderByConditionFields.length; i++) {
15001                                    if (getDB().isSupportsInlineDistinct()) {
15002                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15003                                    }
15004                                    else {
15005                                            query.append(_ORDER_BY_ENTITY_TABLE);
15006                                    }
15007    
15008                                    query.append(orderByConditionFields[i]);
15009    
15010                                    if ((i + 1) < orderByConditionFields.length) {
15011                                            if (orderByComparator.isAscending() ^ previous) {
15012                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15013                                            }
15014                                            else {
15015                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15016                                            }
15017                                    }
15018                                    else {
15019                                            if (orderByComparator.isAscending() ^ previous) {
15020                                                    query.append(WHERE_GREATER_THAN);
15021                                            }
15022                                            else {
15023                                                    query.append(WHERE_LESSER_THAN);
15024                                            }
15025                                    }
15026                            }
15027    
15028                            query.append(ORDER_BY_CLAUSE);
15029    
15030                            String[] orderByFields = orderByComparator.getOrderByFields();
15031    
15032                            for (int i = 0; i < orderByFields.length; i++) {
15033                                    if (getDB().isSupportsInlineDistinct()) {
15034                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15035                                    }
15036                                    else {
15037                                            query.append(_ORDER_BY_ENTITY_TABLE);
15038                                    }
15039    
15040                                    query.append(orderByFields[i]);
15041    
15042                                    if ((i + 1) < orderByFields.length) {
15043                                            if (orderByComparator.isAscending() ^ previous) {
15044                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15045                                            }
15046                                            else {
15047                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15048                                            }
15049                                    }
15050                                    else {
15051                                            if (orderByComparator.isAscending() ^ previous) {
15052                                                    query.append(ORDER_BY_ASC);
15053                                            }
15054                                            else {
15055                                                    query.append(ORDER_BY_DESC);
15056                                            }
15057                                    }
15058                            }
15059                    }
15060                    else {
15061                            if (getDB().isSupportsInlineDistinct()) {
15062                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15063                            }
15064                            else {
15065                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15066                            }
15067                    }
15068    
15069                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15070                                    BlogsEntry.class.getName(),
15071                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15072    
15073                    SQLQuery q = session.createSQLQuery(sql);
15074    
15075                    q.setFirstResult(0);
15076                    q.setMaxResults(2);
15077    
15078                    if (getDB().isSupportsInlineDistinct()) {
15079                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15080                    }
15081                    else {
15082                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15083                    }
15084    
15085                    QueryPos qPos = QueryPos.getInstance(q);
15086    
15087                    qPos.add(groupId);
15088    
15089                    if (displayDate != null) {
15090                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15091                    }
15092    
15093                    qPos.add(status);
15094    
15095                    if (orderByComparator != null) {
15096                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15097    
15098                            for (Object value : values) {
15099                                    qPos.add(value);
15100                            }
15101                    }
15102    
15103                    List<BlogsEntry> list = q.list();
15104    
15105                    if (list.size() == 2) {
15106                            return list.get(1);
15107                    }
15108                    else {
15109                            return null;
15110                    }
15111            }
15112    
15113            /**
15114             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15115             *
15116             * @param groupId the group ID
15117             * @param displayDate the display date
15118             * @param status the status
15119             * @throws SystemException if a system exception occurred
15120             */
15121            public void removeByG_LtD_S(long groupId, Date displayDate, int status)
15122                    throws SystemException {
15123                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
15124                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15125                            remove(blogsEntry);
15126                    }
15127            }
15128    
15129            /**
15130             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15131             *
15132             * @param groupId the group ID
15133             * @param displayDate the display date
15134             * @param status the status
15135             * @return the number of matching blogs entries
15136             * @throws SystemException if a system exception occurred
15137             */
15138            public int countByG_LtD_S(long groupId, Date displayDate, int status)
15139                    throws SystemException {
15140                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
15141    
15142                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
15143    
15144                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15145                                    this);
15146    
15147                    if (count == null) {
15148                            StringBundler query = new StringBundler(4);
15149    
15150                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15151    
15152                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15153    
15154                            if (displayDate == null) {
15155                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15156                            }
15157                            else {
15158                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15159                            }
15160    
15161                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15162    
15163                            String sql = query.toString();
15164    
15165                            Session session = null;
15166    
15167                            try {
15168                                    session = openSession();
15169    
15170                                    Query q = session.createQuery(sql);
15171    
15172                                    QueryPos qPos = QueryPos.getInstance(q);
15173    
15174                                    qPos.add(groupId);
15175    
15176                                    if (displayDate != null) {
15177                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15178                                    }
15179    
15180                                    qPos.add(status);
15181    
15182                                    count = (Long)q.uniqueResult();
15183    
15184                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15185                            }
15186                            catch (Exception e) {
15187                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15188    
15189                                    throw processException(e);
15190                            }
15191                            finally {
15192                                    closeSession(session);
15193                            }
15194                    }
15195    
15196                    return count.intValue();
15197            }
15198    
15199            /**
15200             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15201             *
15202             * @param groupId the group ID
15203             * @param displayDate the display date
15204             * @param status the status
15205             * @return the number of matching blogs entries that the user has permission to view
15206             * @throws SystemException if a system exception occurred
15207             */
15208            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status)
15209                    throws SystemException {
15210                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15211                            return countByG_LtD_S(groupId, displayDate, status);
15212                    }
15213    
15214                    StringBundler query = new StringBundler(4);
15215    
15216                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
15217    
15218                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15219    
15220                    if (displayDate == null) {
15221                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15222                    }
15223                    else {
15224                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15225                    }
15226    
15227                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15228    
15229                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15230                                    BlogsEntry.class.getName(),
15231                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15232    
15233                    Session session = null;
15234    
15235                    try {
15236                            session = openSession();
15237    
15238                            SQLQuery q = session.createSQLQuery(sql);
15239    
15240                            q.addScalar(COUNT_COLUMN_NAME,
15241                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15242    
15243                            QueryPos qPos = QueryPos.getInstance(q);
15244    
15245                            qPos.add(groupId);
15246    
15247                            if (displayDate != null) {
15248                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
15249                            }
15250    
15251                            qPos.add(status);
15252    
15253                            Long count = (Long)q.uniqueResult();
15254    
15255                            return count.intValue();
15256                    }
15257                    catch (Exception e) {
15258                            throw processException(e);
15259                    }
15260                    finally {
15261                            closeSession(session);
15262                    }
15263            }
15264    
15265            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
15266            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
15267            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15268            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15269            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
15270                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15271                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15272                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
15273                            new String[] {
15274                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15275                                    Integer.class.getName(),
15276                                    
15277                            Integer.class.getName(), Integer.class.getName(),
15278                                    OrderByComparator.class.getName()
15279                            });
15280            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
15281                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15282                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15283                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
15284                            new String[] {
15285                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15286                                    Integer.class.getName()
15287                            });
15288    
15289            /**
15290             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15291             *
15292             * @param groupId the group ID
15293             * @param userId the user ID
15294             * @param displayDate the display date
15295             * @param status the status
15296             * @return the matching blogs entries
15297             * @throws SystemException if a system exception occurred
15298             */
15299            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15300                    Date displayDate, int status) throws SystemException {
15301                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
15302                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15303            }
15304    
15305            /**
15306             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15307             *
15308             * <p>
15309             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15310             * </p>
15311             *
15312             * @param groupId the group ID
15313             * @param userId the user ID
15314             * @param displayDate the display date
15315             * @param status the status
15316             * @param start the lower bound of the range of blogs entries
15317             * @param end the upper bound of the range of blogs entries (not inclusive)
15318             * @return the range of matching blogs entries
15319             * @throws SystemException if a system exception occurred
15320             */
15321            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15322                    Date displayDate, int status, int start, int end)
15323                    throws SystemException {
15324                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
15325                            end, null);
15326            }
15327    
15328            /**
15329             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15330             *
15331             * <p>
15332             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15333             * </p>
15334             *
15335             * @param groupId the group ID
15336             * @param userId the user ID
15337             * @param displayDate the display date
15338             * @param status the status
15339             * @param start the lower bound of the range of blogs entries
15340             * @param end the upper bound of the range of blogs entries (not inclusive)
15341             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15342             * @return the ordered range of matching blogs entries
15343             * @throws SystemException if a system exception occurred
15344             */
15345            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15346                    Date displayDate, int status, int start, int end,
15347                    OrderByComparator orderByComparator) throws SystemException {
15348                    boolean pagination = true;
15349                    FinderPath finderPath = null;
15350                    Object[] finderArgs = null;
15351    
15352                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
15353                    finderArgs = new Object[] {
15354                                    groupId, userId, displayDate, status,
15355                                    
15356                                    start, end, orderByComparator
15357                            };
15358    
15359                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
15360                                    finderArgs, this);
15361    
15362                    if ((list != null) && !list.isEmpty()) {
15363                            for (BlogsEntry blogsEntry : list) {
15364                                    if ((groupId != blogsEntry.getGroupId()) ||
15365                                                    (userId != blogsEntry.getUserId()) ||
15366                                                    !Validator.equals(displayDate,
15367                                                            blogsEntry.getDisplayDate()) ||
15368                                                    (status != blogsEntry.getStatus())) {
15369                                            list = null;
15370    
15371                                            break;
15372                                    }
15373                            }
15374                    }
15375    
15376                    if (list == null) {
15377                            StringBundler query = null;
15378    
15379                            if (orderByComparator != null) {
15380                                    query = new StringBundler(6 +
15381                                                    (orderByComparator.getOrderByFields().length * 3));
15382                            }
15383                            else {
15384                                    query = new StringBundler(6);
15385                            }
15386    
15387                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15388    
15389                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15390    
15391                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15392    
15393                            if (displayDate == null) {
15394                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
15395                            }
15396                            else {
15397                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
15398                            }
15399    
15400                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
15401    
15402                            if (orderByComparator != null) {
15403                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15404                                            orderByComparator);
15405                            }
15406                            else
15407                             if (pagination) {
15408                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15409                            }
15410    
15411                            String sql = query.toString();
15412    
15413                            Session session = null;
15414    
15415                            try {
15416                                    session = openSession();
15417    
15418                                    Query q = session.createQuery(sql);
15419    
15420                                    QueryPos qPos = QueryPos.getInstance(q);
15421    
15422                                    qPos.add(groupId);
15423    
15424                                    qPos.add(userId);
15425    
15426                                    if (displayDate != null) {
15427                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15428                                    }
15429    
15430                                    qPos.add(status);
15431    
15432                                    if (!pagination) {
15433                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15434                                                            start, end, false);
15435    
15436                                            Collections.sort(list);
15437    
15438                                            list = new UnmodifiableList<BlogsEntry>(list);
15439                                    }
15440                                    else {
15441                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15442                                                            start, end);
15443                                    }
15444    
15445                                    cacheResult(list);
15446    
15447                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15448                            }
15449                            catch (Exception e) {
15450                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15451    
15452                                    throw processException(e);
15453                            }
15454                            finally {
15455                                    closeSession(session);
15456                            }
15457                    }
15458    
15459                    return list;
15460            }
15461    
15462            /**
15463             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15464             *
15465             * @param groupId the group ID
15466             * @param userId the user ID
15467             * @param displayDate the display date
15468             * @param status the status
15469             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15470             * @return the first matching blogs entry
15471             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15472             * @throws SystemException if a system exception occurred
15473             */
15474            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
15475                    Date displayDate, int status, OrderByComparator orderByComparator)
15476                    throws NoSuchEntryException, SystemException {
15477                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
15478                                    displayDate, status, orderByComparator);
15479    
15480                    if (blogsEntry != null) {
15481                            return blogsEntry;
15482                    }
15483    
15484                    StringBundler msg = new StringBundler(10);
15485    
15486                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15487    
15488                    msg.append("groupId=");
15489                    msg.append(groupId);
15490    
15491                    msg.append(", userId=");
15492                    msg.append(userId);
15493    
15494                    msg.append(", displayDate=");
15495                    msg.append(displayDate);
15496    
15497                    msg.append(", status=");
15498                    msg.append(status);
15499    
15500                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15501    
15502                    throw new NoSuchEntryException(msg.toString());
15503            }
15504    
15505            /**
15506             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15507             *
15508             * @param groupId the group ID
15509             * @param userId the user ID
15510             * @param displayDate the display date
15511             * @param status the status
15512             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15513             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15514             * @throws SystemException if a system exception occurred
15515             */
15516            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
15517                    Date displayDate, int status, OrderByComparator orderByComparator)
15518                    throws SystemException {
15519                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
15520                                    displayDate, status, 0, 1, orderByComparator);
15521    
15522                    if (!list.isEmpty()) {
15523                            return list.get(0);
15524                    }
15525    
15526                    return null;
15527            }
15528    
15529            /**
15530             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15531             *
15532             * @param groupId the group ID
15533             * @param userId the user ID
15534             * @param displayDate the display date
15535             * @param status the status
15536             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15537             * @return the last matching blogs entry
15538             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15539             * @throws SystemException if a system exception occurred
15540             */
15541            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
15542                    Date displayDate, int status, OrderByComparator orderByComparator)
15543                    throws NoSuchEntryException, SystemException {
15544                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
15545                                    displayDate, status, orderByComparator);
15546    
15547                    if (blogsEntry != null) {
15548                            return blogsEntry;
15549                    }
15550    
15551                    StringBundler msg = new StringBundler(10);
15552    
15553                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15554    
15555                    msg.append("groupId=");
15556                    msg.append(groupId);
15557    
15558                    msg.append(", userId=");
15559                    msg.append(userId);
15560    
15561                    msg.append(", displayDate=");
15562                    msg.append(displayDate);
15563    
15564                    msg.append(", status=");
15565                    msg.append(status);
15566    
15567                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15568    
15569                    throw new NoSuchEntryException(msg.toString());
15570            }
15571    
15572            /**
15573             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15574             *
15575             * @param groupId the group ID
15576             * @param userId the user ID
15577             * @param displayDate the display date
15578             * @param status the status
15579             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15580             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15581             * @throws SystemException if a system exception occurred
15582             */
15583            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
15584                    Date displayDate, int status, OrderByComparator orderByComparator)
15585                    throws SystemException {
15586                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
15587    
15588                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
15589                                    displayDate, status, count - 1, count, orderByComparator);
15590    
15591                    if (!list.isEmpty()) {
15592                            return list.get(0);
15593                    }
15594    
15595                    return null;
15596            }
15597    
15598            /**
15599             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15600             *
15601             * @param entryId the primary key of the current blogs entry
15602             * @param groupId the group ID
15603             * @param userId the user ID
15604             * @param displayDate the display date
15605             * @param status the status
15606             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15607             * @return the previous, current, and next blogs entry
15608             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15609             * @throws SystemException if a system exception occurred
15610             */
15611            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
15612                    long groupId, long userId, Date displayDate, int status,
15613                    OrderByComparator orderByComparator)
15614                    throws NoSuchEntryException, SystemException {
15615                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15616    
15617                    Session session = null;
15618    
15619                    try {
15620                            session = openSession();
15621    
15622                            BlogsEntry[] array = new BlogsEntryImpl[3];
15623    
15624                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
15625                                            groupId, userId, displayDate, status, orderByComparator,
15626                                            true);
15627    
15628                            array[1] = blogsEntry;
15629    
15630                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
15631                                            groupId, userId, displayDate, status, orderByComparator,
15632                                            false);
15633    
15634                            return array;
15635                    }
15636                    catch (Exception e) {
15637                            throw processException(e);
15638                    }
15639                    finally {
15640                            closeSession(session);
15641                    }
15642            }
15643    
15644            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
15645                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
15646                    int status, OrderByComparator orderByComparator, boolean previous) {
15647                    StringBundler query = null;
15648    
15649                    if (orderByComparator != null) {
15650                            query = new StringBundler(6 +
15651                                            (orderByComparator.getOrderByFields().length * 6));
15652                    }
15653                    else {
15654                            query = new StringBundler(3);
15655                    }
15656    
15657                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15658    
15659                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15660    
15661                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15662    
15663                    if (displayDate == null) {
15664                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
15665                    }
15666                    else {
15667                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
15668                    }
15669    
15670                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
15671    
15672                    if (orderByComparator != null) {
15673                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15674    
15675                            if (orderByConditionFields.length > 0) {
15676                                    query.append(WHERE_AND);
15677                            }
15678    
15679                            for (int i = 0; i < orderByConditionFields.length; i++) {
15680                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15681                                    query.append(orderByConditionFields[i]);
15682    
15683                                    if ((i + 1) < orderByConditionFields.length) {
15684                                            if (orderByComparator.isAscending() ^ previous) {
15685                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15686                                            }
15687                                            else {
15688                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15689                                            }
15690                                    }
15691                                    else {
15692                                            if (orderByComparator.isAscending() ^ previous) {
15693                                                    query.append(WHERE_GREATER_THAN);
15694                                            }
15695                                            else {
15696                                                    query.append(WHERE_LESSER_THAN);
15697                                            }
15698                                    }
15699                            }
15700    
15701                            query.append(ORDER_BY_CLAUSE);
15702    
15703                            String[] orderByFields = orderByComparator.getOrderByFields();
15704    
15705                            for (int i = 0; i < orderByFields.length; i++) {
15706                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15707                                    query.append(orderByFields[i]);
15708    
15709                                    if ((i + 1) < orderByFields.length) {
15710                                            if (orderByComparator.isAscending() ^ previous) {
15711                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15712                                            }
15713                                            else {
15714                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15715                                            }
15716                                    }
15717                                    else {
15718                                            if (orderByComparator.isAscending() ^ previous) {
15719                                                    query.append(ORDER_BY_ASC);
15720                                            }
15721                                            else {
15722                                                    query.append(ORDER_BY_DESC);
15723                                            }
15724                                    }
15725                            }
15726                    }
15727                    else {
15728                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15729                    }
15730    
15731                    String sql = query.toString();
15732    
15733                    Query q = session.createQuery(sql);
15734    
15735                    q.setFirstResult(0);
15736                    q.setMaxResults(2);
15737    
15738                    QueryPos qPos = QueryPos.getInstance(q);
15739    
15740                    qPos.add(groupId);
15741    
15742                    qPos.add(userId);
15743    
15744                    if (displayDate != null) {
15745                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15746                    }
15747    
15748                    qPos.add(status);
15749    
15750                    if (orderByComparator != null) {
15751                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15752    
15753                            for (Object value : values) {
15754                                    qPos.add(value);
15755                            }
15756                    }
15757    
15758                    List<BlogsEntry> list = q.list();
15759    
15760                    if (list.size() == 2) {
15761                            return list.get(1);
15762                    }
15763                    else {
15764                            return null;
15765                    }
15766            }
15767    
15768            /**
15769             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15770             *
15771             * @param groupId the group ID
15772             * @param userId the user ID
15773             * @param displayDate the display date
15774             * @param status the status
15775             * @return the matching blogs entries that the user has permission to view
15776             * @throws SystemException if a system exception occurred
15777             */
15778            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
15779                    Date displayDate, int status) throws SystemException {
15780                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
15781                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15782            }
15783    
15784            /**
15785             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15786             *
15787             * <p>
15788             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15789             * </p>
15790             *
15791             * @param groupId the group ID
15792             * @param userId the user ID
15793             * @param displayDate the display date
15794             * @param status the status
15795             * @param start the lower bound of the range of blogs entries
15796             * @param end the upper bound of the range of blogs entries (not inclusive)
15797             * @return the range of matching blogs entries that the user has permission to view
15798             * @throws SystemException if a system exception occurred
15799             */
15800            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
15801                    Date displayDate, int status, int start, int end)
15802                    throws SystemException {
15803                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
15804                            start, end, null);
15805            }
15806    
15807            /**
15808             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15809             *
15810             * <p>
15811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15812             * </p>
15813             *
15814             * @param groupId the group ID
15815             * @param userId the user ID
15816             * @param displayDate the display date
15817             * @param status the status
15818             * @param start the lower bound of the range of blogs entries
15819             * @param end the upper bound of the range of blogs entries (not inclusive)
15820             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15821             * @return the ordered range of matching blogs entries that the user has permission to view
15822             * @throws SystemException if a system exception occurred
15823             */
15824            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
15825                    Date displayDate, int status, int start, int end,
15826                    OrderByComparator orderByComparator) throws SystemException {
15827                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15828                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
15829                                    start, end, orderByComparator);
15830                    }
15831    
15832                    StringBundler query = null;
15833    
15834                    if (orderByComparator != null) {
15835                            query = new StringBundler(6 +
15836                                            (orderByComparator.getOrderByFields().length * 3));
15837                    }
15838                    else {
15839                            query = new StringBundler(6);
15840                    }
15841    
15842                    if (getDB().isSupportsInlineDistinct()) {
15843                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
15844                    }
15845                    else {
15846                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
15847                    }
15848    
15849                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15850    
15851                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15852    
15853                    if (displayDate == null) {
15854                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
15855                    }
15856                    else {
15857                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
15858                    }
15859    
15860                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
15861    
15862                    if (!getDB().isSupportsInlineDistinct()) {
15863                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
15864                    }
15865    
15866                    if (orderByComparator != null) {
15867                            if (getDB().isSupportsInlineDistinct()) {
15868                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15869                                            orderByComparator);
15870                            }
15871                            else {
15872                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15873                                            orderByComparator);
15874                            }
15875                    }
15876                    else {
15877                            if (getDB().isSupportsInlineDistinct()) {
15878                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15879                            }
15880                            else {
15881                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15882                            }
15883                    }
15884    
15885                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15886                                    BlogsEntry.class.getName(),
15887                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15888    
15889                    Session session = null;
15890    
15891                    try {
15892                            session = openSession();
15893    
15894                            SQLQuery q = session.createSQLQuery(sql);
15895    
15896                            if (getDB().isSupportsInlineDistinct()) {
15897                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15898                            }
15899                            else {
15900                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15901                            }
15902    
15903                            QueryPos qPos = QueryPos.getInstance(q);
15904    
15905                            qPos.add(groupId);
15906    
15907                            qPos.add(userId);
15908    
15909                            if (displayDate != null) {
15910                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
15911                            }
15912    
15913                            qPos.add(status);
15914    
15915                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
15916                    }
15917                    catch (Exception e) {
15918                            throw processException(e);
15919                    }
15920                    finally {
15921                            closeSession(session);
15922                    }
15923            }
15924    
15925            /**
15926             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15927             *
15928             * @param entryId the primary key of the current blogs entry
15929             * @param groupId the group ID
15930             * @param userId the user ID
15931             * @param displayDate the display date
15932             * @param status the status
15933             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15934             * @return the previous, current, and next blogs entry
15935             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15936             * @throws SystemException if a system exception occurred
15937             */
15938            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
15939                    long groupId, long userId, Date displayDate, int status,
15940                    OrderByComparator orderByComparator)
15941                    throws NoSuchEntryException, SystemException {
15942                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15943                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
15944                                    displayDate, status, orderByComparator);
15945                    }
15946    
15947                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15948    
15949                    Session session = null;
15950    
15951                    try {
15952                            session = openSession();
15953    
15954                            BlogsEntry[] array = new BlogsEntryImpl[3];
15955    
15956                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
15957                                            groupId, userId, displayDate, status, orderByComparator,
15958                                            true);
15959    
15960                            array[1] = blogsEntry;
15961    
15962                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
15963                                            groupId, userId, displayDate, status, orderByComparator,
15964                                            false);
15965    
15966                            return array;
15967                    }
15968                    catch (Exception e) {
15969                            throw processException(e);
15970                    }
15971                    finally {
15972                            closeSession(session);
15973                    }
15974            }
15975    
15976            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
15977                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
15978                    int status, OrderByComparator orderByComparator, boolean previous) {
15979                    StringBundler query = null;
15980    
15981                    if (orderByComparator != null) {
15982                            query = new StringBundler(6 +
15983                                            (orderByComparator.getOrderByFields().length * 6));
15984                    }
15985                    else {
15986                            query = new StringBundler(3);
15987                    }
15988    
15989                    if (getDB().isSupportsInlineDistinct()) {
15990                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
15991                    }
15992                    else {
15993                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
15994                    }
15995    
15996                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15997    
15998                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15999    
16000                    if (displayDate == null) {
16001                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16002                    }
16003                    else {
16004                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16005                    }
16006    
16007                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16008    
16009                    if (!getDB().isSupportsInlineDistinct()) {
16010                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16011                    }
16012    
16013                    if (orderByComparator != null) {
16014                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16015    
16016                            if (orderByConditionFields.length > 0) {
16017                                    query.append(WHERE_AND);
16018                            }
16019    
16020                            for (int i = 0; i < orderByConditionFields.length; i++) {
16021                                    if (getDB().isSupportsInlineDistinct()) {
16022                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16023                                    }
16024                                    else {
16025                                            query.append(_ORDER_BY_ENTITY_TABLE);
16026                                    }
16027    
16028                                    query.append(orderByConditionFields[i]);
16029    
16030                                    if ((i + 1) < orderByConditionFields.length) {
16031                                            if (orderByComparator.isAscending() ^ previous) {
16032                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16033                                            }
16034                                            else {
16035                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16036                                            }
16037                                    }
16038                                    else {
16039                                            if (orderByComparator.isAscending() ^ previous) {
16040                                                    query.append(WHERE_GREATER_THAN);
16041                                            }
16042                                            else {
16043                                                    query.append(WHERE_LESSER_THAN);
16044                                            }
16045                                    }
16046                            }
16047    
16048                            query.append(ORDER_BY_CLAUSE);
16049    
16050                            String[] orderByFields = orderByComparator.getOrderByFields();
16051    
16052                            for (int i = 0; i < orderByFields.length; i++) {
16053                                    if (getDB().isSupportsInlineDistinct()) {
16054                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16055                                    }
16056                                    else {
16057                                            query.append(_ORDER_BY_ENTITY_TABLE);
16058                                    }
16059    
16060                                    query.append(orderByFields[i]);
16061    
16062                                    if ((i + 1) < orderByFields.length) {
16063                                            if (orderByComparator.isAscending() ^ previous) {
16064                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16065                                            }
16066                                            else {
16067                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16068                                            }
16069                                    }
16070                                    else {
16071                                            if (orderByComparator.isAscending() ^ previous) {
16072                                                    query.append(ORDER_BY_ASC);
16073                                            }
16074                                            else {
16075                                                    query.append(ORDER_BY_DESC);
16076                                            }
16077                                    }
16078                            }
16079                    }
16080                    else {
16081                            if (getDB().isSupportsInlineDistinct()) {
16082                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16083                            }
16084                            else {
16085                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16086                            }
16087                    }
16088    
16089                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16090                                    BlogsEntry.class.getName(),
16091                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16092    
16093                    SQLQuery q = session.createSQLQuery(sql);
16094    
16095                    q.setFirstResult(0);
16096                    q.setMaxResults(2);
16097    
16098                    if (getDB().isSupportsInlineDistinct()) {
16099                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16100                    }
16101                    else {
16102                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16103                    }
16104    
16105                    QueryPos qPos = QueryPos.getInstance(q);
16106    
16107                    qPos.add(groupId);
16108    
16109                    qPos.add(userId);
16110    
16111                    if (displayDate != null) {
16112                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16113                    }
16114    
16115                    qPos.add(status);
16116    
16117                    if (orderByComparator != null) {
16118                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16119    
16120                            for (Object value : values) {
16121                                    qPos.add(value);
16122                            }
16123                    }
16124    
16125                    List<BlogsEntry> list = q.list();
16126    
16127                    if (list.size() == 2) {
16128                            return list.get(1);
16129                    }
16130                    else {
16131                            return null;
16132                    }
16133            }
16134    
16135            /**
16136             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
16137             *
16138             * @param groupId the group ID
16139             * @param userId the user ID
16140             * @param displayDate the display date
16141             * @param status the status
16142             * @throws SystemException if a system exception occurred
16143             */
16144            public void removeByG_U_LtD_NotS(long groupId, long userId,
16145                    Date displayDate, int status) throws SystemException {
16146                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
16147                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16148                            remove(blogsEntry);
16149                    }
16150            }
16151    
16152            /**
16153             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16154             *
16155             * @param groupId the group ID
16156             * @param userId the user ID
16157             * @param displayDate the display date
16158             * @param status the status
16159             * @return the number of matching blogs entries
16160             * @throws SystemException if a system exception occurred
16161             */
16162            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
16163                    int status) throws SystemException {
16164                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
16165    
16166                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16167    
16168                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16169                                    this);
16170    
16171                    if (count == null) {
16172                            StringBundler query = new StringBundler(5);
16173    
16174                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16175    
16176                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16177    
16178                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16179    
16180                            if (displayDate == null) {
16181                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16182                            }
16183                            else {
16184                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16185                            }
16186    
16187                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16188    
16189                            String sql = query.toString();
16190    
16191                            Session session = null;
16192    
16193                            try {
16194                                    session = openSession();
16195    
16196                                    Query q = session.createQuery(sql);
16197    
16198                                    QueryPos qPos = QueryPos.getInstance(q);
16199    
16200                                    qPos.add(groupId);
16201    
16202                                    qPos.add(userId);
16203    
16204                                    if (displayDate != null) {
16205                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16206                                    }
16207    
16208                                    qPos.add(status);
16209    
16210                                    count = (Long)q.uniqueResult();
16211    
16212                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16213                            }
16214                            catch (Exception e) {
16215                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16216    
16217                                    throw processException(e);
16218                            }
16219                            finally {
16220                                    closeSession(session);
16221                            }
16222                    }
16223    
16224                    return count.intValue();
16225            }
16226    
16227            /**
16228             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16229             *
16230             * @param groupId the group ID
16231             * @param userId the user ID
16232             * @param displayDate the display date
16233             * @param status the status
16234             * @return the number of matching blogs entries that the user has permission to view
16235             * @throws SystemException if a system exception occurred
16236             */
16237            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
16238                    Date displayDate, int status) throws SystemException {
16239                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16240                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16241                    }
16242    
16243                    StringBundler query = new StringBundler(5);
16244    
16245                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16246    
16247                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16248    
16249                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16250    
16251                    if (displayDate == null) {
16252                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16253                    }
16254                    else {
16255                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16256                    }
16257    
16258                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16259    
16260                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16261                                    BlogsEntry.class.getName(),
16262                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16263    
16264                    Session session = null;
16265    
16266                    try {
16267                            session = openSession();
16268    
16269                            SQLQuery q = session.createSQLQuery(sql);
16270    
16271                            q.addScalar(COUNT_COLUMN_NAME,
16272                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16273    
16274                            QueryPos qPos = QueryPos.getInstance(q);
16275    
16276                            qPos.add(groupId);
16277    
16278                            qPos.add(userId);
16279    
16280                            if (displayDate != null) {
16281                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
16282                            }
16283    
16284                            qPos.add(status);
16285    
16286                            Long count = (Long)q.uniqueResult();
16287    
16288                            return count.intValue();
16289                    }
16290                    catch (Exception e) {
16291                            throw processException(e);
16292                    }
16293                    finally {
16294                            closeSession(session);
16295                    }
16296            }
16297    
16298            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
16299            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
16300            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
16301            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16302            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
16303            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
16304                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16305                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16306                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
16307                            new String[] {
16308                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16309                                    Integer.class.getName(),
16310                                    
16311                            Integer.class.getName(), Integer.class.getName(),
16312                                    OrderByComparator.class.getName()
16313                            });
16314            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16315                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16316                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16317                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16318                            new String[] {
16319                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16320                                    Integer.class.getName()
16321                            });
16322    
16323            /**
16324             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16325             *
16326             * @param groupId the group ID
16327             * @param userId the user ID
16328             * @param displayDate the display date
16329             * @param status the status
16330             * @return the matching blogs entries
16331             * @throws SystemException if a system exception occurred
16332             */
16333            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16334                    Date displayDate, int status) throws SystemException {
16335                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16336                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16337            }
16338    
16339            /**
16340             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16341             *
16342             * <p>
16343             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16344             * </p>
16345             *
16346             * @param groupId the group ID
16347             * @param userId the user ID
16348             * @param displayDate the display date
16349             * @param status the status
16350             * @param start the lower bound of the range of blogs entries
16351             * @param end the upper bound of the range of blogs entries (not inclusive)
16352             * @return the range of matching blogs entries
16353             * @throws SystemException if a system exception occurred
16354             */
16355            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16356                    Date displayDate, int status, int start, int end)
16357                    throws SystemException {
16358                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16359                            end, null);
16360            }
16361    
16362            /**
16363             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16364             *
16365             * <p>
16366             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16367             * </p>
16368             *
16369             * @param groupId the group ID
16370             * @param userId the user ID
16371             * @param displayDate the display date
16372             * @param status the status
16373             * @param start the lower bound of the range of blogs entries
16374             * @param end the upper bound of the range of blogs entries (not inclusive)
16375             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16376             * @return the ordered range of matching blogs entries
16377             * @throws SystemException if a system exception occurred
16378             */
16379            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16380                    Date displayDate, int status, int start, int end,
16381                    OrderByComparator orderByComparator) throws SystemException {
16382                    boolean pagination = true;
16383                    FinderPath finderPath = null;
16384                    Object[] finderArgs = null;
16385    
16386                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16387                    finderArgs = new Object[] {
16388                                    groupId, userId, displayDate, status,
16389                                    
16390                                    start, end, orderByComparator
16391                            };
16392    
16393                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
16394                                    finderArgs, this);
16395    
16396                    if ((list != null) && !list.isEmpty()) {
16397                            for (BlogsEntry blogsEntry : list) {
16398                                    if ((groupId != blogsEntry.getGroupId()) ||
16399                                                    (userId != blogsEntry.getUserId()) ||
16400                                                    !Validator.equals(displayDate,
16401                                                            blogsEntry.getDisplayDate()) ||
16402                                                    (status != blogsEntry.getStatus())) {
16403                                            list = null;
16404    
16405                                            break;
16406                                    }
16407                            }
16408                    }
16409    
16410                    if (list == null) {
16411                            StringBundler query = null;
16412    
16413                            if (orderByComparator != null) {
16414                                    query = new StringBundler(6 +
16415                                                    (orderByComparator.getOrderByFields().length * 3));
16416                            }
16417                            else {
16418                                    query = new StringBundler(6);
16419                            }
16420    
16421                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16422    
16423                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16424    
16425                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16426    
16427                            if (displayDate == null) {
16428                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16429                            }
16430                            else {
16431                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16432                            }
16433    
16434                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16435    
16436                            if (orderByComparator != null) {
16437                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16438                                            orderByComparator);
16439                            }
16440                            else
16441                             if (pagination) {
16442                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16443                            }
16444    
16445                            String sql = query.toString();
16446    
16447                            Session session = null;
16448    
16449                            try {
16450                                    session = openSession();
16451    
16452                                    Query q = session.createQuery(sql);
16453    
16454                                    QueryPos qPos = QueryPos.getInstance(q);
16455    
16456                                    qPos.add(groupId);
16457    
16458                                    qPos.add(userId);
16459    
16460                                    if (displayDate != null) {
16461                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16462                                    }
16463    
16464                                    qPos.add(status);
16465    
16466                                    if (!pagination) {
16467                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16468                                                            start, end, false);
16469    
16470                                            Collections.sort(list);
16471    
16472                                            list = new UnmodifiableList<BlogsEntry>(list);
16473                                    }
16474                                    else {
16475                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16476                                                            start, end);
16477                                    }
16478    
16479                                    cacheResult(list);
16480    
16481                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16482                            }
16483                            catch (Exception e) {
16484                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16485    
16486                                    throw processException(e);
16487                            }
16488                            finally {
16489                                    closeSession(session);
16490                            }
16491                    }
16492    
16493                    return list;
16494            }
16495    
16496            /**
16497             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16498             *
16499             * @param groupId the group ID
16500             * @param userId the user ID
16501             * @param displayDate the display date
16502             * @param status the status
16503             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16504             * @return the first matching blogs entry
16505             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
16506             * @throws SystemException if a system exception occurred
16507             */
16508            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16509                    Date displayDate, int status, OrderByComparator orderByComparator)
16510                    throws NoSuchEntryException, SystemException {
16511                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16512                                    displayDate, status, orderByComparator);
16513    
16514                    if (blogsEntry != null) {
16515                            return blogsEntry;
16516                    }
16517    
16518                    StringBundler msg = new StringBundler(10);
16519    
16520                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16521    
16522                    msg.append("groupId=");
16523                    msg.append(groupId);
16524    
16525                    msg.append(", userId=");
16526                    msg.append(userId);
16527    
16528                    msg.append(", displayDate=");
16529                    msg.append(displayDate);
16530    
16531                    msg.append(", status=");
16532                    msg.append(status);
16533    
16534                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16535    
16536                    throw new NoSuchEntryException(msg.toString());
16537            }
16538    
16539            /**
16540             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16541             *
16542             * @param groupId the group ID
16543             * @param userId the user ID
16544             * @param displayDate the display date
16545             * @param status the status
16546             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16547             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16548             * @throws SystemException if a system exception occurred
16549             */
16550            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16551                    Date displayDate, int status, OrderByComparator orderByComparator)
16552                    throws SystemException {
16553                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16554                                    status, 0, 1, orderByComparator);
16555    
16556                    if (!list.isEmpty()) {
16557                            return list.get(0);
16558                    }
16559    
16560                    return null;
16561            }
16562    
16563            /**
16564             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16565             *
16566             * @param groupId the group ID
16567             * @param userId the user ID
16568             * @param displayDate the display date
16569             * @param status the status
16570             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16571             * @return the last matching blogs entry
16572             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
16573             * @throws SystemException if a system exception occurred
16574             */
16575            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16576                    Date displayDate, int status, OrderByComparator orderByComparator)
16577                    throws NoSuchEntryException, SystemException {
16578                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16579                                    displayDate, status, orderByComparator);
16580    
16581                    if (blogsEntry != null) {
16582                            return blogsEntry;
16583                    }
16584    
16585                    StringBundler msg = new StringBundler(10);
16586    
16587                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16588    
16589                    msg.append("groupId=");
16590                    msg.append(groupId);
16591    
16592                    msg.append(", userId=");
16593                    msg.append(userId);
16594    
16595                    msg.append(", displayDate=");
16596                    msg.append(displayDate);
16597    
16598                    msg.append(", status=");
16599                    msg.append(status);
16600    
16601                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16602    
16603                    throw new NoSuchEntryException(msg.toString());
16604            }
16605    
16606            /**
16607             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16608             *
16609             * @param groupId the group ID
16610             * @param userId the user ID
16611             * @param displayDate the display date
16612             * @param status the status
16613             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16614             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16615             * @throws SystemException if a system exception occurred
16616             */
16617            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16618                    Date displayDate, int status, OrderByComparator orderByComparator)
16619                    throws SystemException {
16620                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16621    
16622                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16623                                    status, count - 1, count, orderByComparator);
16624    
16625                    if (!list.isEmpty()) {
16626                            return list.get(0);
16627                    }
16628    
16629                    return null;
16630            }
16631    
16632            /**
16633             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16634             *
16635             * @param entryId the primary key of the current blogs entry
16636             * @param groupId the group ID
16637             * @param userId the user ID
16638             * @param displayDate the display date
16639             * @param status the status
16640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16641             * @return the previous, current, and next blogs entry
16642             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16643             * @throws SystemException if a system exception occurred
16644             */
16645            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16646                    long userId, Date displayDate, int status,
16647                    OrderByComparator orderByComparator)
16648                    throws NoSuchEntryException, SystemException {
16649                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16650    
16651                    Session session = null;
16652    
16653                    try {
16654                            session = openSession();
16655    
16656                            BlogsEntry[] array = new BlogsEntryImpl[3];
16657    
16658                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16659                                            userId, displayDate, status, orderByComparator, true);
16660    
16661                            array[1] = blogsEntry;
16662    
16663                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16664                                            userId, displayDate, status, orderByComparator, false);
16665    
16666                            return array;
16667                    }
16668                    catch (Exception e) {
16669                            throw processException(e);
16670                    }
16671                    finally {
16672                            closeSession(session);
16673                    }
16674            }
16675    
16676            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16677                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16678                    int status, OrderByComparator orderByComparator, boolean previous) {
16679                    StringBundler query = null;
16680    
16681                    if (orderByComparator != null) {
16682                            query = new StringBundler(6 +
16683                                            (orderByComparator.getOrderByFields().length * 6));
16684                    }
16685                    else {
16686                            query = new StringBundler(3);
16687                    }
16688    
16689                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16690    
16691                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16692    
16693                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16694    
16695                    if (displayDate == null) {
16696                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16697                    }
16698                    else {
16699                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16700                    }
16701    
16702                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16703    
16704                    if (orderByComparator != null) {
16705                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16706    
16707                            if (orderByConditionFields.length > 0) {
16708                                    query.append(WHERE_AND);
16709                            }
16710    
16711                            for (int i = 0; i < orderByConditionFields.length; i++) {
16712                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16713                                    query.append(orderByConditionFields[i]);
16714    
16715                                    if ((i + 1) < orderByConditionFields.length) {
16716                                            if (orderByComparator.isAscending() ^ previous) {
16717                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16718                                            }
16719                                            else {
16720                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16721                                            }
16722                                    }
16723                                    else {
16724                                            if (orderByComparator.isAscending() ^ previous) {
16725                                                    query.append(WHERE_GREATER_THAN);
16726                                            }
16727                                            else {
16728                                                    query.append(WHERE_LESSER_THAN);
16729                                            }
16730                                    }
16731                            }
16732    
16733                            query.append(ORDER_BY_CLAUSE);
16734    
16735                            String[] orderByFields = orderByComparator.getOrderByFields();
16736    
16737                            for (int i = 0; i < orderByFields.length; i++) {
16738                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16739                                    query.append(orderByFields[i]);
16740    
16741                                    if ((i + 1) < orderByFields.length) {
16742                                            if (orderByComparator.isAscending() ^ previous) {
16743                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16744                                            }
16745                                            else {
16746                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16747                                            }
16748                                    }
16749                                    else {
16750                                            if (orderByComparator.isAscending() ^ previous) {
16751                                                    query.append(ORDER_BY_ASC);
16752                                            }
16753                                            else {
16754                                                    query.append(ORDER_BY_DESC);
16755                                            }
16756                                    }
16757                            }
16758                    }
16759                    else {
16760                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16761                    }
16762    
16763                    String sql = query.toString();
16764    
16765                    Query q = session.createQuery(sql);
16766    
16767                    q.setFirstResult(0);
16768                    q.setMaxResults(2);
16769    
16770                    QueryPos qPos = QueryPos.getInstance(q);
16771    
16772                    qPos.add(groupId);
16773    
16774                    qPos.add(userId);
16775    
16776                    if (displayDate != null) {
16777                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16778                    }
16779    
16780                    qPos.add(status);
16781    
16782                    if (orderByComparator != null) {
16783                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16784    
16785                            for (Object value : values) {
16786                                    qPos.add(value);
16787                            }
16788                    }
16789    
16790                    List<BlogsEntry> list = q.list();
16791    
16792                    if (list.size() == 2) {
16793                            return list.get(1);
16794                    }
16795                    else {
16796                            return null;
16797                    }
16798            }
16799    
16800            /**
16801             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16802             *
16803             * @param groupId the group ID
16804             * @param userId the user ID
16805             * @param displayDate the display date
16806             * @param status the status
16807             * @return the matching blogs entries that the user has permission to view
16808             * @throws SystemException if a system exception occurred
16809             */
16810            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16811                    Date displayDate, int status) throws SystemException {
16812                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16813                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16814            }
16815    
16816            /**
16817             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16818             *
16819             * <p>
16820             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16821             * </p>
16822             *
16823             * @param groupId the group ID
16824             * @param userId the user ID
16825             * @param displayDate the display date
16826             * @param status the status
16827             * @param start the lower bound of the range of blogs entries
16828             * @param end the upper bound of the range of blogs entries (not inclusive)
16829             * @return the range of matching blogs entries that the user has permission to view
16830             * @throws SystemException if a system exception occurred
16831             */
16832            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16833                    Date displayDate, int status, int start, int end)
16834                    throws SystemException {
16835                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16836                            start, end, null);
16837            }
16838    
16839            /**
16840             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16841             *
16842             * <p>
16843             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16844             * </p>
16845             *
16846             * @param groupId the group ID
16847             * @param userId the user ID
16848             * @param displayDate the display date
16849             * @param status the status
16850             * @param start the lower bound of the range of blogs entries
16851             * @param end the upper bound of the range of blogs entries (not inclusive)
16852             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16853             * @return the ordered range of matching blogs entries that the user has permission to view
16854             * @throws SystemException if a system exception occurred
16855             */
16856            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16857                    Date displayDate, int status, int start, int end,
16858                    OrderByComparator orderByComparator) throws SystemException {
16859                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16860                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16861                                    end, orderByComparator);
16862                    }
16863    
16864                    StringBundler query = null;
16865    
16866                    if (orderByComparator != null) {
16867                            query = new StringBundler(6 +
16868                                            (orderByComparator.getOrderByFields().length * 3));
16869                    }
16870                    else {
16871                            query = new StringBundler(6);
16872                    }
16873    
16874                    if (getDB().isSupportsInlineDistinct()) {
16875                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16876                    }
16877                    else {
16878                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16879                    }
16880    
16881                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16882    
16883                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16884    
16885                    if (displayDate == null) {
16886                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16887                    }
16888                    else {
16889                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16890                    }
16891    
16892                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16893    
16894                    if (!getDB().isSupportsInlineDistinct()) {
16895                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16896                    }
16897    
16898                    if (orderByComparator != null) {
16899                            if (getDB().isSupportsInlineDistinct()) {
16900                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16901                                            orderByComparator);
16902                            }
16903                            else {
16904                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16905                                            orderByComparator);
16906                            }
16907                    }
16908                    else {
16909                            if (getDB().isSupportsInlineDistinct()) {
16910                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16911                            }
16912                            else {
16913                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16914                            }
16915                    }
16916    
16917                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16918                                    BlogsEntry.class.getName(),
16919                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16920    
16921                    Session session = null;
16922    
16923                    try {
16924                            session = openSession();
16925    
16926                            SQLQuery q = session.createSQLQuery(sql);
16927    
16928                            if (getDB().isSupportsInlineDistinct()) {
16929                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16930                            }
16931                            else {
16932                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16933                            }
16934    
16935                            QueryPos qPos = QueryPos.getInstance(q);
16936    
16937                            qPos.add(groupId);
16938    
16939                            qPos.add(userId);
16940    
16941                            if (displayDate != null) {
16942                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
16943                            }
16944    
16945                            qPos.add(status);
16946    
16947                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16948                    }
16949                    catch (Exception e) {
16950                            throw processException(e);
16951                    }
16952                    finally {
16953                            closeSession(session);
16954                    }
16955            }
16956    
16957            /**
16958             * Returns the blogs entries before and after the current blogs entry in the ordered set of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16959             *
16960             * @param entryId the primary key of the current blogs entry
16961             * @param groupId the group ID
16962             * @param userId the user ID
16963             * @param displayDate the display date
16964             * @param status the status
16965             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16966             * @return the previous, current, and next blogs entry
16967             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16968             * @throws SystemException if a system exception occurred
16969             */
16970            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
16971                    long groupId, long userId, Date displayDate, int status,
16972                    OrderByComparator orderByComparator)
16973                    throws NoSuchEntryException, SystemException {
16974                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16975                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
16976                                    displayDate, status, orderByComparator);
16977                    }
16978    
16979                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16980    
16981                    Session session = null;
16982    
16983                    try {
16984                            session = openSession();
16985    
16986                            BlogsEntry[] array = new BlogsEntryImpl[3];
16987    
16988                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16989                                            groupId, userId, displayDate, status, orderByComparator,
16990                                            true);
16991    
16992                            array[1] = blogsEntry;
16993    
16994                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16995                                            groupId, userId, displayDate, status, orderByComparator,
16996                                            false);
16997    
16998                            return array;
16999                    }
17000                    catch (Exception e) {
17001                            throw processException(e);
17002                    }
17003                    finally {
17004                            closeSession(session);
17005                    }
17006            }
17007    
17008            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
17009                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17010                    int status, OrderByComparator orderByComparator, boolean previous) {
17011                    StringBundler query = null;
17012    
17013                    if (orderByComparator != null) {
17014                            query = new StringBundler(6 +
17015                                            (orderByComparator.getOrderByFields().length * 6));
17016                    }
17017                    else {
17018                            query = new StringBundler(3);
17019                    }
17020    
17021                    if (getDB().isSupportsInlineDistinct()) {
17022                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17023                    }
17024                    else {
17025                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17026                    }
17027    
17028                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17029    
17030                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17031    
17032                    if (displayDate == null) {
17033                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17034                    }
17035                    else {
17036                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17037                    }
17038    
17039                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17040    
17041                    if (!getDB().isSupportsInlineDistinct()) {
17042                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17043                    }
17044    
17045                    if (orderByComparator != null) {
17046                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17047    
17048                            if (orderByConditionFields.length > 0) {
17049                                    query.append(WHERE_AND);
17050                            }
17051    
17052                            for (int i = 0; i < orderByConditionFields.length; i++) {
17053                                    if (getDB().isSupportsInlineDistinct()) {
17054                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17055                                    }
17056                                    else {
17057                                            query.append(_ORDER_BY_ENTITY_TABLE);
17058                                    }
17059    
17060                                    query.append(orderByConditionFields[i]);
17061    
17062                                    if ((i + 1) < orderByConditionFields.length) {
17063                                            if (orderByComparator.isAscending() ^ previous) {
17064                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17065                                            }
17066                                            else {
17067                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17068                                            }
17069                                    }
17070                                    else {
17071                                            if (orderByComparator.isAscending() ^ previous) {
17072                                                    query.append(WHERE_GREATER_THAN);
17073                                            }
17074                                            else {
17075                                                    query.append(WHERE_LESSER_THAN);
17076                                            }
17077                                    }
17078                            }
17079    
17080                            query.append(ORDER_BY_CLAUSE);
17081    
17082                            String[] orderByFields = orderByComparator.getOrderByFields();
17083    
17084                            for (int i = 0; i < orderByFields.length; i++) {
17085                                    if (getDB().isSupportsInlineDistinct()) {
17086                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17087                                    }
17088                                    else {
17089                                            query.append(_ORDER_BY_ENTITY_TABLE);
17090                                    }
17091    
17092                                    query.append(orderByFields[i]);
17093    
17094                                    if ((i + 1) < orderByFields.length) {
17095                                            if (orderByComparator.isAscending() ^ previous) {
17096                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17097                                            }
17098                                            else {
17099                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17100                                            }
17101                                    }
17102                                    else {
17103                                            if (orderByComparator.isAscending() ^ previous) {
17104                                                    query.append(ORDER_BY_ASC);
17105                                            }
17106                                            else {
17107                                                    query.append(ORDER_BY_DESC);
17108                                            }
17109                                    }
17110                            }
17111                    }
17112                    else {
17113                            if (getDB().isSupportsInlineDistinct()) {
17114                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17115                            }
17116                            else {
17117                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17118                            }
17119                    }
17120    
17121                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17122                                    BlogsEntry.class.getName(),
17123                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17124    
17125                    SQLQuery q = session.createSQLQuery(sql);
17126    
17127                    q.setFirstResult(0);
17128                    q.setMaxResults(2);
17129    
17130                    if (getDB().isSupportsInlineDistinct()) {
17131                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17132                    }
17133                    else {
17134                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17135                    }
17136    
17137                    QueryPos qPos = QueryPos.getInstance(q);
17138    
17139                    qPos.add(groupId);
17140    
17141                    qPos.add(userId);
17142    
17143                    if (displayDate != null) {
17144                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17145                    }
17146    
17147                    qPos.add(status);
17148    
17149                    if (orderByComparator != null) {
17150                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17151    
17152                            for (Object value : values) {
17153                                    qPos.add(value);
17154                            }
17155                    }
17156    
17157                    List<BlogsEntry> list = q.list();
17158    
17159                    if (list.size() == 2) {
17160                            return list.get(1);
17161                    }
17162                    else {
17163                            return null;
17164                    }
17165            }
17166    
17167            /**
17168             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
17169             *
17170             * @param groupId the group ID
17171             * @param userId the user ID
17172             * @param displayDate the display date
17173             * @param status the status
17174             * @throws SystemException if a system exception occurred
17175             */
17176            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
17177                    int status) throws SystemException {
17178                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
17179                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17180                            remove(blogsEntry);
17181                    }
17182            }
17183    
17184            /**
17185             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17186             *
17187             * @param groupId the group ID
17188             * @param userId the user ID
17189             * @param displayDate the display date
17190             * @param status the status
17191             * @return the number of matching blogs entries
17192             * @throws SystemException if a system exception occurred
17193             */
17194            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17195                    int status) throws SystemException {
17196                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
17197    
17198                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17199    
17200                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17201                                    this);
17202    
17203                    if (count == null) {
17204                            StringBundler query = new StringBundler(5);
17205    
17206                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17207    
17208                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17209    
17210                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17211    
17212                            if (displayDate == null) {
17213                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17214                            }
17215                            else {
17216                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17217                            }
17218    
17219                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17220    
17221                            String sql = query.toString();
17222    
17223                            Session session = null;
17224    
17225                            try {
17226                                    session = openSession();
17227    
17228                                    Query q = session.createQuery(sql);
17229    
17230                                    QueryPos qPos = QueryPos.getInstance(q);
17231    
17232                                    qPos.add(groupId);
17233    
17234                                    qPos.add(userId);
17235    
17236                                    if (displayDate != null) {
17237                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17238                                    }
17239    
17240                                    qPos.add(status);
17241    
17242                                    count = (Long)q.uniqueResult();
17243    
17244                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17245                            }
17246                            catch (Exception e) {
17247                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17248    
17249                                    throw processException(e);
17250                            }
17251                            finally {
17252                                    closeSession(session);
17253                            }
17254                    }
17255    
17256                    return count.intValue();
17257            }
17258    
17259            /**
17260             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17261             *
17262             * @param groupId the group ID
17263             * @param userId the user ID
17264             * @param displayDate the display date
17265             * @param status the status
17266             * @return the number of matching blogs entries that the user has permission to view
17267             * @throws SystemException if a system exception occurred
17268             */
17269            public int filterCountByG_U_LtD_S(long groupId, long userId,
17270                    Date displayDate, int status) throws SystemException {
17271                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17272                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17273                    }
17274    
17275                    StringBundler query = new StringBundler(5);
17276    
17277                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17278    
17279                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17280    
17281                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17282    
17283                    if (displayDate == null) {
17284                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17285                    }
17286                    else {
17287                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17288                    }
17289    
17290                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17291    
17292                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17293                                    BlogsEntry.class.getName(),
17294                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17295    
17296                    Session session = null;
17297    
17298                    try {
17299                            session = openSession();
17300    
17301                            SQLQuery q = session.createSQLQuery(sql);
17302    
17303                            q.addScalar(COUNT_COLUMN_NAME,
17304                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17305    
17306                            QueryPos qPos = QueryPos.getInstance(q);
17307    
17308                            qPos.add(groupId);
17309    
17310                            qPos.add(userId);
17311    
17312                            if (displayDate != null) {
17313                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17314                            }
17315    
17316                            qPos.add(status);
17317    
17318                            Long count = (Long)q.uniqueResult();
17319    
17320                            return count.intValue();
17321                    }
17322                    catch (Exception e) {
17323                            throw processException(e);
17324                    }
17325                    finally {
17326                            closeSession(session);
17327                    }
17328            }
17329    
17330            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17331            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17332            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
17333            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17334            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17335    
17336            /**
17337             * Caches the blogs entry in the entity cache if it is enabled.
17338             *
17339             * @param blogsEntry the blogs entry
17340             */
17341            public void cacheResult(BlogsEntry blogsEntry) {
17342                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17343                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
17344    
17345                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
17346                            new Object[] {
17347                                    blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
17348                            }, blogsEntry);
17349    
17350                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
17351                            new Object[] {
17352                                    Long.valueOf(blogsEntry.getGroupId()),
17353                                    
17354                            blogsEntry.getUrlTitle()
17355                            }, blogsEntry);
17356    
17357                    blogsEntry.resetOriginalValues();
17358            }
17359    
17360            /**
17361             * Caches the blogs entries in the entity cache if it is enabled.
17362             *
17363             * @param blogsEntries the blogs entries
17364             */
17365            public void cacheResult(List<BlogsEntry> blogsEntries) {
17366                    for (BlogsEntry blogsEntry : blogsEntries) {
17367                            if (EntityCacheUtil.getResult(
17368                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17369                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
17370                                    cacheResult(blogsEntry);
17371                            }
17372                            else {
17373                                    blogsEntry.resetOriginalValues();
17374                            }
17375                    }
17376            }
17377    
17378            /**
17379             * Clears the cache for all blogs entries.
17380             *
17381             * <p>
17382             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17383             * </p>
17384             */
17385            @Override
17386            public void clearCache() {
17387                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
17388                            CacheRegistryUtil.clear(BlogsEntryImpl.class.getName());
17389                    }
17390    
17391                    EntityCacheUtil.clearCache(BlogsEntryImpl.class.getName());
17392    
17393                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
17394                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17395                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17396            }
17397    
17398            /**
17399             * Clears the cache for the blogs entry.
17400             *
17401             * <p>
17402             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17403             * </p>
17404             */
17405            @Override
17406            public void clearCache(BlogsEntry blogsEntry) {
17407                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17408                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17409    
17410                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17411                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17412    
17413                    clearUniqueFindersCache(blogsEntry);
17414            }
17415    
17416            @Override
17417            public void clearCache(List<BlogsEntry> blogsEntries) {
17418                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17419                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17420    
17421                    for (BlogsEntry blogsEntry : blogsEntries) {
17422                            EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17423                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17424    
17425                            clearUniqueFindersCache(blogsEntry);
17426                    }
17427            }
17428    
17429            protected void cacheUniqueFindersCache(BlogsEntry blogsEntry) {
17430                    if (blogsEntry.isNew()) {
17431                            Object[] args = new Object[] {
17432                                            blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
17433                                    };
17434    
17435                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17436                                    Long.valueOf(1));
17437                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17438                                    blogsEntry);
17439    
17440                            args = new Object[] {
17441                                            Long.valueOf(blogsEntry.getGroupId()),
17442                                            
17443                                            blogsEntry.getUrlTitle()
17444                                    };
17445    
17446                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17447                                    Long.valueOf(1));
17448                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17449                                    blogsEntry);
17450                    }
17451                    else {
17452                            BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17453    
17454                            if ((blogsEntryModelImpl.getColumnBitmask() &
17455                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17456                                    Object[] args = new Object[] {
17457                                                    blogsEntry.getUuid(),
17458                                                    Long.valueOf(blogsEntry.getGroupId())
17459                                            };
17460    
17461                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17462                                            Long.valueOf(1));
17463                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17464                                            blogsEntry);
17465                            }
17466    
17467                            if ((blogsEntryModelImpl.getColumnBitmask() &
17468                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17469                                    Object[] args = new Object[] {
17470                                                    Long.valueOf(blogsEntry.getGroupId()),
17471                                                    
17472                                                    blogsEntry.getUrlTitle()
17473                                            };
17474    
17475                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17476                                            Long.valueOf(1));
17477                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17478                                            blogsEntry);
17479                            }
17480                    }
17481            }
17482    
17483            protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
17484                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17485    
17486                    Object[] args = new Object[] {
17487                                    blogsEntry.getUuid(), Long.valueOf(blogsEntry.getGroupId())
17488                            };
17489    
17490                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17491                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17492    
17493                    if ((blogsEntryModelImpl.getColumnBitmask() &
17494                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17495                            args = new Object[] {
17496                                            blogsEntryModelImpl.getOriginalUuid(),
17497                                            Long.valueOf(blogsEntryModelImpl.getOriginalGroupId())
17498                                    };
17499    
17500                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17501                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17502                    }
17503    
17504                    args = new Object[] {
17505                                    Long.valueOf(blogsEntry.getGroupId()),
17506                                    
17507                                    blogsEntry.getUrlTitle()
17508                            };
17509    
17510                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17511                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17512    
17513                    if ((blogsEntryModelImpl.getColumnBitmask() &
17514                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17515                            args = new Object[] {
17516                                            Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
17517                                            
17518                                            blogsEntryModelImpl.getOriginalUrlTitle()
17519                                    };
17520    
17521                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17522                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17523                    }
17524            }
17525    
17526            /**
17527             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
17528             *
17529             * @param entryId the primary key for the new blogs entry
17530             * @return the new blogs entry
17531             */
17532            public BlogsEntry create(long entryId) {
17533                    BlogsEntry blogsEntry = new BlogsEntryImpl();
17534    
17535                    blogsEntry.setNew(true);
17536                    blogsEntry.setPrimaryKey(entryId);
17537    
17538                    String uuid = PortalUUIDUtil.generate();
17539    
17540                    blogsEntry.setUuid(uuid);
17541    
17542                    return blogsEntry;
17543            }
17544    
17545            /**
17546             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
17547             *
17548             * @param entryId the primary key of the blogs entry
17549             * @return the blogs entry that was removed
17550             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17551             * @throws SystemException if a system exception occurred
17552             */
17553            public BlogsEntry remove(long entryId)
17554                    throws NoSuchEntryException, SystemException {
17555                    return remove(Long.valueOf(entryId));
17556            }
17557    
17558            /**
17559             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
17560             *
17561             * @param primaryKey the primary key of the blogs entry
17562             * @return the blogs entry that was removed
17563             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17564             * @throws SystemException if a system exception occurred
17565             */
17566            @Override
17567            public BlogsEntry remove(Serializable primaryKey)
17568                    throws NoSuchEntryException, SystemException {
17569                    Session session = null;
17570    
17571                    try {
17572                            session = openSession();
17573    
17574                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17575                                            primaryKey);
17576    
17577                            if (blogsEntry == null) {
17578                                    if (_log.isWarnEnabled()) {
17579                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
17580                                    }
17581    
17582                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
17583                                            primaryKey);
17584                            }
17585    
17586                            return remove(blogsEntry);
17587                    }
17588                    catch (NoSuchEntryException nsee) {
17589                            throw nsee;
17590                    }
17591                    catch (Exception e) {
17592                            throw processException(e);
17593                    }
17594                    finally {
17595                            closeSession(session);
17596                    }
17597            }
17598    
17599            @Override
17600            protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
17601                    throws SystemException {
17602                    blogsEntry = toUnwrappedModel(blogsEntry);
17603    
17604                    Session session = null;
17605    
17606                    try {
17607                            session = openSession();
17608    
17609                            if (!session.contains(blogsEntry)) {
17610                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17611                                                    blogsEntry.getPrimaryKeyObj());
17612                            }
17613    
17614                            if (blogsEntry != null) {
17615                                    session.delete(blogsEntry);
17616                            }
17617                    }
17618                    catch (Exception e) {
17619                            throw processException(e);
17620                    }
17621                    finally {
17622                            closeSession(session);
17623                    }
17624    
17625                    if (blogsEntry != null) {
17626                            clearCache(blogsEntry);
17627                    }
17628    
17629                    return blogsEntry;
17630            }
17631    
17632            @Override
17633            public BlogsEntry updateImpl(
17634                    com.liferay.portlet.blogs.model.BlogsEntry blogsEntry)
17635                    throws SystemException {
17636                    blogsEntry = toUnwrappedModel(blogsEntry);
17637    
17638                    boolean isNew = blogsEntry.isNew();
17639    
17640                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17641    
17642                    if (Validator.isNull(blogsEntry.getUuid())) {
17643                            String uuid = PortalUUIDUtil.generate();
17644    
17645                            blogsEntry.setUuid(uuid);
17646                    }
17647    
17648                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
17649    
17650                    if (userId > 0) {
17651                            long companyId = blogsEntry.getCompanyId();
17652    
17653                            long groupId = blogsEntry.getGroupId();
17654    
17655                            long entryId = 0;
17656    
17657                            if (!isNew) {
17658                                    entryId = blogsEntry.getPrimaryKey();
17659                            }
17660    
17661                            try {
17662                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
17663                                                    userId,
17664                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
17665                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
17666                                                    blogsEntry.getTitle(), null));
17667    
17668                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
17669                                                    groupId, userId,
17670                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
17671                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
17672                                                    blogsEntry.getContent(), null));
17673                            }
17674                            catch (SanitizerException se) {
17675                                    throw new SystemException(se);
17676                            }
17677                    }
17678    
17679                    Session session = null;
17680    
17681                    try {
17682                            session = openSession();
17683    
17684                            if (blogsEntry.isNew()) {
17685                                    session.save(blogsEntry);
17686    
17687                                    blogsEntry.setNew(false);
17688                            }
17689                            else {
17690                                    session.merge(blogsEntry);
17691                            }
17692                    }
17693                    catch (Exception e) {
17694                            throw processException(e);
17695                    }
17696                    finally {
17697                            closeSession(session);
17698                    }
17699    
17700                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17701    
17702                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
17703                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17704                    }
17705    
17706                    else {
17707                            if ((blogsEntryModelImpl.getColumnBitmask() &
17708                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
17709                                    Object[] args = new Object[] {
17710                                                    blogsEntryModelImpl.getOriginalUuid()
17711                                            };
17712    
17713                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17714                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17715                                            args);
17716    
17717                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
17718    
17719                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17720                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17721                                            args);
17722                            }
17723    
17724                            if ((blogsEntryModelImpl.getColumnBitmask() &
17725                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
17726                                    Object[] args = new Object[] {
17727                                                    blogsEntryModelImpl.getOriginalUuid(),
17728                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId())
17729                                            };
17730    
17731                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17732                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17733                                            args);
17734    
17735                                    args = new Object[] {
17736                                                    blogsEntryModelImpl.getUuid(),
17737                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId())
17738                                            };
17739    
17740                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17741                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17742                                            args);
17743                            }
17744    
17745                            if ((blogsEntryModelImpl.getColumnBitmask() &
17746                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
17747                                    Object[] args = new Object[] {
17748                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId())
17749                                            };
17750    
17751                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17752                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17753                                            args);
17754    
17755                                    args = new Object[] {
17756                                                    Long.valueOf(blogsEntryModelImpl.getGroupId())
17757                                            };
17758    
17759                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17760                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17761                                            args);
17762                            }
17763    
17764                            if ((blogsEntryModelImpl.getColumnBitmask() &
17765                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
17766                                    Object[] args = new Object[] {
17767                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId())
17768                                            };
17769    
17770                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
17771                                            args);
17772                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
17773                                            args);
17774    
17775                                    args = new Object[] {
17776                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId())
17777                                            };
17778    
17779                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
17780                                            args);
17781                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
17782                                            args);
17783                            }
17784    
17785                            if ((blogsEntryModelImpl.getColumnBitmask() &
17786                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
17787                                    Object[] args = new Object[] {
17788                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
17789                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId())
17790                                            };
17791    
17792                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
17793                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
17794                                            args);
17795    
17796                                    args = new Object[] {
17797                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
17798                                                    Long.valueOf(blogsEntryModelImpl.getUserId())
17799                                            };
17800    
17801                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
17802                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
17803                                            args);
17804                            }
17805    
17806                            if ((blogsEntryModelImpl.getColumnBitmask() &
17807                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
17808                                    Object[] args = new Object[] {
17809                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
17810                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
17811                                            };
17812    
17813                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
17814                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
17815                                            args);
17816    
17817                                    args = new Object[] {
17818                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
17819                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
17820                                            };
17821    
17822                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
17823                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
17824                                            args);
17825                            }
17826    
17827                            if ((blogsEntryModelImpl.getColumnBitmask() &
17828                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
17829                                    Object[] args = new Object[] {
17830                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
17831                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
17832                                            };
17833    
17834                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
17835                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
17836                                            args);
17837    
17838                                    args = new Object[] {
17839                                                    Long.valueOf(blogsEntryModelImpl.getGroupId()),
17840                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
17841                                            };
17842    
17843                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
17844                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
17845                                            args);
17846                            }
17847    
17848                            if ((blogsEntryModelImpl.getColumnBitmask() &
17849                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
17850                                    Object[] args = new Object[] {
17851                                                    Long.valueOf(blogsEntryModelImpl.getOriginalCompanyId()),
17852                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId()),
17853                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
17854                                            };
17855    
17856                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
17857                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
17858                                            args);
17859    
17860                                    args = new Object[] {
17861                                                    Long.valueOf(blogsEntryModelImpl.getCompanyId()),
17862                                                    Long.valueOf(blogsEntryModelImpl.getUserId()),
17863                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
17864                                            };
17865    
17866                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
17867                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
17868                                            args);
17869                            }
17870    
17871                            if ((blogsEntryModelImpl.getColumnBitmask() &
17872                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
17873                                    Object[] args = new Object[] {
17874                                                    Long.valueOf(blogsEntryModelImpl.getOriginalGroupId()),
17875                                                    Long.valueOf(blogsEntryModelImpl.getOriginalUserId()),
17876                                                    Integer.valueOf(blogsEntryModelImpl.getOriginalStatus())
17877                                            };
17878    
17879                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
17880                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
17881                                            args);
17882    
17883                                    args = new Object[] {
17884                                                    Long.valueOf(blogsEntryModelImpl.getGroupId()),
17885                                                    Long.valueOf(blogsEntryModelImpl.getUserId()),
17886                                                    Integer.valueOf(blogsEntryModelImpl.getStatus())
17887                                            };
17888    
17889                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
17890                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
17891                                            args);
17892                            }
17893                    }
17894    
17895                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17896                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
17897    
17898                    clearUniqueFindersCache(blogsEntry);
17899                    cacheUniqueFindersCache(blogsEntry);
17900    
17901                    return blogsEntry;
17902            }
17903    
17904            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
17905                    if (blogsEntry instanceof BlogsEntryImpl) {
17906                            return blogsEntry;
17907                    }
17908    
17909                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
17910    
17911                    blogsEntryImpl.setNew(blogsEntry.isNew());
17912                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
17913    
17914                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
17915                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
17916                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
17917                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
17918                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
17919                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
17920                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
17921                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
17922                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
17923                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
17924                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
17925                    blogsEntryImpl.setContent(blogsEntry.getContent());
17926                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
17927                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
17928                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
17929                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
17930                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
17931                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
17932                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
17933                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
17934                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
17935                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
17936                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
17937    
17938                    return blogsEntryImpl;
17939            }
17940    
17941            /**
17942             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
17943             *
17944             * @param primaryKey the primary key of the blogs entry
17945             * @return the blogs entry
17946             * @throws com.liferay.portal.NoSuchModelException if a blogs entry with the primary key could not be found
17947             * @throws SystemException if a system exception occurred
17948             */
17949            @Override
17950            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
17951                    throws NoSuchModelException, SystemException {
17952                    return findByPrimaryKey(((Long)primaryKey).longValue());
17953            }
17954    
17955            /**
17956             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
17957             *
17958             * @param entryId the primary key of the blogs entry
17959             * @return the blogs entry
17960             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17961             * @throws SystemException if a system exception occurred
17962             */
17963            public BlogsEntry findByPrimaryKey(long entryId)
17964                    throws NoSuchEntryException, SystemException {
17965                    BlogsEntry blogsEntry = fetchByPrimaryKey(entryId);
17966    
17967                    if (blogsEntry == null) {
17968                            if (_log.isWarnEnabled()) {
17969                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
17970                            }
17971    
17972                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
17973                                    entryId);
17974                    }
17975    
17976                    return blogsEntry;
17977            }
17978    
17979            /**
17980             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
17981             *
17982             * @param primaryKey the primary key of the blogs entry
17983             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
17984             * @throws SystemException if a system exception occurred
17985             */
17986            @Override
17987            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey)
17988                    throws SystemException {
17989                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
17990            }
17991    
17992            /**
17993             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
17994             *
17995             * @param entryId the primary key of the blogs entry
17996             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
17997             * @throws SystemException if a system exception occurred
17998             */
17999            public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
18000                    BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18001                                    BlogsEntryImpl.class, entryId);
18002    
18003                    if (blogsEntry == _nullBlogsEntry) {
18004                            return null;
18005                    }
18006    
18007                    if (blogsEntry == null) {
18008                            Session session = null;
18009    
18010                            try {
18011                                    session = openSession();
18012    
18013                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18014                                                    Long.valueOf(entryId));
18015    
18016                                    if (blogsEntry != null) {
18017                                            cacheResult(blogsEntry);
18018                                    }
18019                                    else {
18020                                            EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18021                                                    BlogsEntryImpl.class, entryId, _nullBlogsEntry);
18022                                    }
18023                            }
18024                            catch (Exception e) {
18025                                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18026                                            BlogsEntryImpl.class, entryId);
18027    
18028                                    throw processException(e);
18029                            }
18030                            finally {
18031                                    closeSession(session);
18032                            }
18033                    }
18034    
18035                    return blogsEntry;
18036            }
18037    
18038            /**
18039             * Returns all the blogs entries.
18040             *
18041             * @return the blogs entries
18042             * @throws SystemException if a system exception occurred
18043             */
18044            public List<BlogsEntry> findAll() throws SystemException {
18045                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18046            }
18047    
18048            /**
18049             * Returns a range of all the blogs entries.
18050             *
18051             * <p>
18052             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18053             * </p>
18054             *
18055             * @param start the lower bound of the range of blogs entries
18056             * @param end the upper bound of the range of blogs entries (not inclusive)
18057             * @return the range of blogs entries
18058             * @throws SystemException if a system exception occurred
18059             */
18060            public List<BlogsEntry> findAll(int start, int end)
18061                    throws SystemException {
18062                    return findAll(start, end, null);
18063            }
18064    
18065            /**
18066             * Returns an ordered range of all the blogs entries.
18067             *
18068             * <p>
18069             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18070             * </p>
18071             *
18072             * @param start the lower bound of the range of blogs entries
18073             * @param end the upper bound of the range of blogs entries (not inclusive)
18074             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18075             * @return the ordered range of blogs entries
18076             * @throws SystemException if a system exception occurred
18077             */
18078            public List<BlogsEntry> findAll(int start, int end,
18079                    OrderByComparator orderByComparator) throws SystemException {
18080                    boolean pagination = true;
18081                    FinderPath finderPath = null;
18082                    Object[] finderArgs = null;
18083    
18084                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18085                                    (orderByComparator == null)) {
18086                            pagination = false;
18087                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
18088                            finderArgs = FINDER_ARGS_EMPTY;
18089                    }
18090                    else {
18091                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
18092                            finderArgs = new Object[] { start, end, orderByComparator };
18093                    }
18094    
18095                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
18096                                    finderArgs, this);
18097    
18098                    if (list == null) {
18099                            StringBundler query = null;
18100                            String sql = null;
18101    
18102                            if (orderByComparator != null) {
18103                                    query = new StringBundler(2 +
18104                                                    (orderByComparator.getOrderByFields().length * 3));
18105    
18106                                    query.append(_SQL_SELECT_BLOGSENTRY);
18107    
18108                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18109                                            orderByComparator);
18110    
18111                                    sql = query.toString();
18112                            }
18113                            else {
18114                                    sql = _SQL_SELECT_BLOGSENTRY;
18115    
18116                                    if (pagination) {
18117                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
18118                                    }
18119                            }
18120    
18121                            Session session = null;
18122    
18123                            try {
18124                                    session = openSession();
18125    
18126                                    Query q = session.createQuery(sql);
18127    
18128                                    if (!pagination) {
18129                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18130                                                            start, end, false);
18131    
18132                                            Collections.sort(list);
18133    
18134                                            list = new UnmodifiableList<BlogsEntry>(list);
18135                                    }
18136                                    else {
18137                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18138                                                            start, end);
18139                                    }
18140    
18141                                    cacheResult(list);
18142    
18143                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18144                            }
18145                            catch (Exception e) {
18146                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18147    
18148                                    throw processException(e);
18149                            }
18150                            finally {
18151                                    closeSession(session);
18152                            }
18153                    }
18154    
18155                    return list;
18156            }
18157    
18158            /**
18159             * Removes all the blogs entries from the database.
18160             *
18161             * @throws SystemException if a system exception occurred
18162             */
18163            public void removeAll() throws SystemException {
18164                    for (BlogsEntry blogsEntry : findAll()) {
18165                            remove(blogsEntry);
18166                    }
18167            }
18168    
18169            /**
18170             * Returns the number of blogs entries.
18171             *
18172             * @return the number of blogs entries
18173             * @throws SystemException if a system exception occurred
18174             */
18175            public int countAll() throws SystemException {
18176                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18177                                    FINDER_ARGS_EMPTY, this);
18178    
18179                    if (count == null) {
18180                            Session session = null;
18181    
18182                            try {
18183                                    session = openSession();
18184    
18185                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
18186    
18187                                    count = (Long)q.uniqueResult();
18188    
18189                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18190                                            FINDER_ARGS_EMPTY, count);
18191                            }
18192                            catch (Exception e) {
18193                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
18194                                            FINDER_ARGS_EMPTY);
18195    
18196                                    throw processException(e);
18197                            }
18198                            finally {
18199                                    closeSession(session);
18200                            }
18201                    }
18202    
18203                    return count.intValue();
18204            }
18205    
18206            /**
18207             * Initializes the blogs entry persistence.
18208             */
18209            public void afterPropertiesSet() {
18210                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
18211                                            com.liferay.portal.util.PropsUtil.get(
18212                                                    "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
18213    
18214                    if (listenerClassNames.length > 0) {
18215                            try {
18216                                    List<ModelListener<BlogsEntry>> listenersList = new ArrayList<ModelListener<BlogsEntry>>();
18217    
18218                                    for (String listenerClassName : listenerClassNames) {
18219                                            listenersList.add((ModelListener<BlogsEntry>)InstanceFactory.newInstance(
18220                                                            listenerClassName));
18221                                    }
18222    
18223                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
18224                            }
18225                            catch (Exception e) {
18226                                    _log.error(e);
18227                            }
18228                    }
18229            }
18230    
18231            public void destroy() {
18232                    EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
18233                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18234                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18235                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18236            }
18237    
18238            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
18239            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
18240            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
18241            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
18242            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
18243            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
18244            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
18245                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
18246            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
18247                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
18248            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
18249            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
18250            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
18251            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
18252            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
18253            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
18254            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
18255            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18256            private static Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
18257            private static BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
18258                            @Override
18259                            public Object clone() {
18260                                    return this;
18261                            }
18262    
18263                            @Override
18264                            public CacheModel<BlogsEntry> toCacheModel() {
18265                                    return _nullBlogsEntryCacheModel;
18266                            }
18267                    };
18268    
18269            private static CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
18270                            public BlogsEntry toEntityModel() {
18271                                    return _nullBlogsEntry;
18272                            }
18273                    };
18274    }