001    /**
002     * Copyright (c) 2000-2013 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.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.SQLQuery;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.sanitizer.Sanitizer;
030    import com.liferay.portal.kernel.sanitizer.SanitizerException;
031    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
032    import com.liferay.portal.kernel.util.CalendarUtil;
033    import com.liferay.portal.kernel.util.ContentTypes;
034    import com.liferay.portal.kernel.util.GetterUtil;
035    import com.liferay.portal.kernel.util.InstanceFactory;
036    import com.liferay.portal.kernel.util.OrderByComparator;
037    import com.liferay.portal.kernel.util.SetUtil;
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    import java.util.Set;
062    
063    /**
064     * The persistence implementation for the blogs entry service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see BlogsEntryPersistence
072     * @see BlogsEntryUtil
073     * @generated
074     */
075    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
076            implements BlogsEntryPersistence {
077            /*
078             * NOTE FOR DEVELOPERS:
079             *
080             * Never modify or reference this class directly. Always use {@link BlogsEntryUtil} to access the blogs entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
081             */
082            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
083            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List1";
085            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List2";
087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
088                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
091                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
093            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
094                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
097                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
098                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
099                            new String[] {
100                                    String.class.getName(),
101                                    
102                            Integer.class.getName(), Integer.class.getName(),
103                                    OrderByComparator.class.getName()
104                            });
105            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
106                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108                            new String[] { String.class.getName() },
109                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
110                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
111                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
113                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
115                            new String[] { String.class.getName() });
116    
117            /**
118             * Returns all the blogs entries where uuid = &#63;.
119             *
120             * @param uuid the uuid
121             * @return the matching blogs entries
122             * @throws SystemException if a system exception occurred
123             */
124            @Override
125            public List<BlogsEntry> findByUuid(String uuid) throws SystemException {
126                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
127            }
128    
129            /**
130             * Returns a range of all the blogs entries where uuid = &#63;.
131             *
132             * <p>
133             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
134             * </p>
135             *
136             * @param uuid the uuid
137             * @param start the lower bound of the range of blogs entries
138             * @param end the upper bound of the range of blogs entries (not inclusive)
139             * @return the range of matching blogs entries
140             * @throws SystemException if a system exception occurred
141             */
142            @Override
143            public List<BlogsEntry> findByUuid(String uuid, int start, int end)
144                    throws SystemException {
145                    return findByUuid(uuid, start, end, null);
146            }
147    
148            /**
149             * Returns an ordered range of all the blogs entries where uuid = &#63;.
150             *
151             * <p>
152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
153             * </p>
154             *
155             * @param uuid the uuid
156             * @param start the lower bound of the range of blogs entries
157             * @param end the upper bound of the range of blogs entries (not inclusive)
158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
159             * @return the ordered range of matching blogs entries
160             * @throws SystemException if a system exception occurred
161             */
162            @Override
163            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
164                    OrderByComparator orderByComparator) throws SystemException {
165                    boolean pagination = true;
166                    FinderPath finderPath = null;
167                    Object[] finderArgs = null;
168    
169                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
170                                    (orderByComparator == null)) {
171                            pagination = false;
172                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
173                            finderArgs = new Object[] { uuid };
174                    }
175                    else {
176                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
177                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
178                    }
179    
180                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
181                                    finderArgs, this);
182    
183                    if ((list != null) && !list.isEmpty()) {
184                            for (BlogsEntry blogsEntry : list) {
185                                    if (!Validator.equals(uuid, blogsEntry.getUuid())) {
186                                            list = null;
187    
188                                            break;
189                                    }
190                            }
191                    }
192    
193                    if (list == null) {
194                            StringBundler query = null;
195    
196                            if (orderByComparator != null) {
197                                    query = new StringBundler(3 +
198                                                    (orderByComparator.getOrderByFields().length * 3));
199                            }
200                            else {
201                                    query = new StringBundler(3);
202                            }
203    
204                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
205    
206                            boolean bindUuid = false;
207    
208                            if (uuid == null) {
209                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
210                            }
211                            else if (uuid.equals(StringPool.BLANK)) {
212                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
213                            }
214                            else {
215                                    bindUuid = true;
216    
217                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
218                            }
219    
220                            if (orderByComparator != null) {
221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
222                                            orderByComparator);
223                            }
224                            else
225                             if (pagination) {
226                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
227                            }
228    
229                            String sql = query.toString();
230    
231                            Session session = null;
232    
233                            try {
234                                    session = openSession();
235    
236                                    Query q = session.createQuery(sql);
237    
238                                    QueryPos qPos = QueryPos.getInstance(q);
239    
240                                    if (bindUuid) {
241                                            qPos.add(uuid);
242                                    }
243    
244                                    if (!pagination) {
245                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
246                                                            start, end, false);
247    
248                                            Collections.sort(list);
249    
250                                            list = new UnmodifiableList<BlogsEntry>(list);
251                                    }
252                                    else {
253                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
254                                                            start, end);
255                                    }
256    
257                                    cacheResult(list);
258    
259                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
260                            }
261                            catch (Exception e) {
262                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
263    
264                                    throw processException(e);
265                            }
266                            finally {
267                                    closeSession(session);
268                            }
269                    }
270    
271                    return list;
272            }
273    
274            /**
275             * Returns the first blogs entry in the ordered set where uuid = &#63;.
276             *
277             * @param uuid the uuid
278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
279             * @return the first matching blogs entry
280             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
281             * @throws SystemException if a system exception occurred
282             */
283            @Override
284            public BlogsEntry findByUuid_First(String uuid,
285                    OrderByComparator orderByComparator)
286                    throws NoSuchEntryException, SystemException {
287                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
288    
289                    if (blogsEntry != null) {
290                            return blogsEntry;
291                    }
292    
293                    StringBundler msg = new StringBundler(4);
294    
295                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
296    
297                    msg.append("uuid=");
298                    msg.append(uuid);
299    
300                    msg.append(StringPool.CLOSE_CURLY_BRACE);
301    
302                    throw new NoSuchEntryException(msg.toString());
303            }
304    
305            /**
306             * Returns the first blogs entry in the ordered set where uuid = &#63;.
307             *
308             * @param uuid the uuid
309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
310             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
311             * @throws SystemException if a system exception occurred
312             */
313            @Override
314            public BlogsEntry fetchByUuid_First(String uuid,
315                    OrderByComparator orderByComparator) throws SystemException {
316                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
317    
318                    if (!list.isEmpty()) {
319                            return list.get(0);
320                    }
321    
322                    return null;
323            }
324    
325            /**
326             * Returns the last blogs entry in the ordered set where uuid = &#63;.
327             *
328             * @param uuid the uuid
329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
330             * @return the last matching blogs entry
331             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
332             * @throws SystemException if a system exception occurred
333             */
334            @Override
335            public BlogsEntry findByUuid_Last(String uuid,
336                    OrderByComparator orderByComparator)
337                    throws NoSuchEntryException, SystemException {
338                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
339    
340                    if (blogsEntry != null) {
341                            return blogsEntry;
342                    }
343    
344                    StringBundler msg = new StringBundler(4);
345    
346                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
347    
348                    msg.append("uuid=");
349                    msg.append(uuid);
350    
351                    msg.append(StringPool.CLOSE_CURLY_BRACE);
352    
353                    throw new NoSuchEntryException(msg.toString());
354            }
355    
356            /**
357             * Returns the last blogs entry in the ordered set where uuid = &#63;.
358             *
359             * @param uuid the uuid
360             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
361             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
362             * @throws SystemException if a system exception occurred
363             */
364            @Override
365            public BlogsEntry fetchByUuid_Last(String uuid,
366                    OrderByComparator orderByComparator) throws SystemException {
367                    int count = countByUuid(uuid);
368    
369                    if (count == 0) {
370                            return null;
371                    }
372    
373                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
374                                    orderByComparator);
375    
376                    if (!list.isEmpty()) {
377                            return list.get(0);
378                    }
379    
380                    return null;
381            }
382    
383            /**
384             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
385             *
386             * @param entryId the primary key of the current blogs entry
387             * @param uuid the uuid
388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
389             * @return the previous, current, and next blogs entry
390             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
391             * @throws SystemException if a system exception occurred
392             */
393            @Override
394            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
395                    OrderByComparator orderByComparator)
396                    throws NoSuchEntryException, SystemException {
397                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
398    
399                    Session session = null;
400    
401                    try {
402                            session = openSession();
403    
404                            BlogsEntry[] array = new BlogsEntryImpl[3];
405    
406                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
407                                            orderByComparator, true);
408    
409                            array[1] = blogsEntry;
410    
411                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
412                                            orderByComparator, false);
413    
414                            return array;
415                    }
416                    catch (Exception e) {
417                            throw processException(e);
418                    }
419                    finally {
420                            closeSession(session);
421                    }
422            }
423    
424            protected BlogsEntry getByUuid_PrevAndNext(Session session,
425                    BlogsEntry blogsEntry, String uuid,
426                    OrderByComparator orderByComparator, boolean previous) {
427                    StringBundler query = null;
428    
429                    if (orderByComparator != null) {
430                            query = new StringBundler(6 +
431                                            (orderByComparator.getOrderByFields().length * 6));
432                    }
433                    else {
434                            query = new StringBundler(3);
435                    }
436    
437                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
438    
439                    boolean bindUuid = false;
440    
441                    if (uuid == null) {
442                            query.append(_FINDER_COLUMN_UUID_UUID_1);
443                    }
444                    else if (uuid.equals(StringPool.BLANK)) {
445                            query.append(_FINDER_COLUMN_UUID_UUID_3);
446                    }
447                    else {
448                            bindUuid = true;
449    
450                            query.append(_FINDER_COLUMN_UUID_UUID_2);
451                    }
452    
453                    if (orderByComparator != null) {
454                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
455    
456                            if (orderByConditionFields.length > 0) {
457                                    query.append(WHERE_AND);
458                            }
459    
460                            for (int i = 0; i < orderByConditionFields.length; i++) {
461                                    query.append(_ORDER_BY_ENTITY_ALIAS);
462                                    query.append(orderByConditionFields[i]);
463    
464                                    if ((i + 1) < orderByConditionFields.length) {
465                                            if (orderByComparator.isAscending() ^ previous) {
466                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
467                                            }
468                                            else {
469                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
470                                            }
471                                    }
472                                    else {
473                                            if (orderByComparator.isAscending() ^ previous) {
474                                                    query.append(WHERE_GREATER_THAN);
475                                            }
476                                            else {
477                                                    query.append(WHERE_LESSER_THAN);
478                                            }
479                                    }
480                            }
481    
482                            query.append(ORDER_BY_CLAUSE);
483    
484                            String[] orderByFields = orderByComparator.getOrderByFields();
485    
486                            for (int i = 0; i < orderByFields.length; i++) {
487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
488                                    query.append(orderByFields[i]);
489    
490                                    if ((i + 1) < orderByFields.length) {
491                                            if (orderByComparator.isAscending() ^ previous) {
492                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
493                                            }
494                                            else {
495                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
496                                            }
497                                    }
498                                    else {
499                                            if (orderByComparator.isAscending() ^ previous) {
500                                                    query.append(ORDER_BY_ASC);
501                                            }
502                                            else {
503                                                    query.append(ORDER_BY_DESC);
504                                            }
505                                    }
506                            }
507                    }
508                    else {
509                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
510                    }
511    
512                    String sql = query.toString();
513    
514                    Query q = session.createQuery(sql);
515    
516                    q.setFirstResult(0);
517                    q.setMaxResults(2);
518    
519                    QueryPos qPos = QueryPos.getInstance(q);
520    
521                    if (bindUuid) {
522                            qPos.add(uuid);
523                    }
524    
525                    if (orderByComparator != null) {
526                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
527    
528                            for (Object value : values) {
529                                    qPos.add(value);
530                            }
531                    }
532    
533                    List<BlogsEntry> list = q.list();
534    
535                    if (list.size() == 2) {
536                            return list.get(1);
537                    }
538                    else {
539                            return null;
540                    }
541            }
542    
543            /**
544             * Removes all the blogs entries where uuid = &#63; from the database.
545             *
546             * @param uuid the uuid
547             * @throws SystemException if a system exception occurred
548             */
549            @Override
550            public void removeByUuid(String uuid) throws SystemException {
551                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
552                                    QueryUtil.ALL_POS, null)) {
553                            remove(blogsEntry);
554                    }
555            }
556    
557            /**
558             * Returns the number of blogs entries where uuid = &#63;.
559             *
560             * @param uuid the uuid
561             * @return the number of matching blogs entries
562             * @throws SystemException if a system exception occurred
563             */
564            @Override
565            public int countByUuid(String uuid) throws SystemException {
566                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
567    
568                    Object[] finderArgs = new Object[] { uuid };
569    
570                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
571                                    this);
572    
573                    if (count == null) {
574                            StringBundler query = new StringBundler(2);
575    
576                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
577    
578                            boolean bindUuid = false;
579    
580                            if (uuid == null) {
581                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
582                            }
583                            else if (uuid.equals(StringPool.BLANK)) {
584                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
585                            }
586                            else {
587                                    bindUuid = true;
588    
589                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
590                            }
591    
592                            String sql = query.toString();
593    
594                            Session session = null;
595    
596                            try {
597                                    session = openSession();
598    
599                                    Query q = session.createQuery(sql);
600    
601                                    QueryPos qPos = QueryPos.getInstance(q);
602    
603                                    if (bindUuid) {
604                                            qPos.add(uuid);
605                                    }
606    
607                                    count = (Long)q.uniqueResult();
608    
609                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
610                            }
611                            catch (Exception e) {
612                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
613    
614                                    throw processException(e);
615                            }
616                            finally {
617                                    closeSession(session);
618                            }
619                    }
620    
621                    return count.intValue();
622            }
623    
624            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
625            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
626            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
627            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
628                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
629                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
630                            new String[] { String.class.getName(), Long.class.getName() },
631                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
632                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
633            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
634                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
635                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
636                            new String[] { String.class.getName(), Long.class.getName() });
637    
638            /**
639             * 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.
640             *
641             * @param uuid the uuid
642             * @param groupId the group ID
643             * @return the matching blogs entry
644             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
645             * @throws SystemException if a system exception occurred
646             */
647            @Override
648            public BlogsEntry findByUUID_G(String uuid, long groupId)
649                    throws NoSuchEntryException, SystemException {
650                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
651    
652                    if (blogsEntry == null) {
653                            StringBundler msg = new StringBundler(6);
654    
655                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
656    
657                            msg.append("uuid=");
658                            msg.append(uuid);
659    
660                            msg.append(", groupId=");
661                            msg.append(groupId);
662    
663                            msg.append(StringPool.CLOSE_CURLY_BRACE);
664    
665                            if (_log.isWarnEnabled()) {
666                                    _log.warn(msg.toString());
667                            }
668    
669                            throw new NoSuchEntryException(msg.toString());
670                    }
671    
672                    return blogsEntry;
673            }
674    
675            /**
676             * 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.
677             *
678             * @param uuid the uuid
679             * @param groupId the group ID
680             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
681             * @throws SystemException if a system exception occurred
682             */
683            @Override
684            public BlogsEntry fetchByUUID_G(String uuid, long groupId)
685                    throws SystemException {
686                    return fetchByUUID_G(uuid, groupId, true);
687            }
688    
689            /**
690             * 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.
691             *
692             * @param uuid the uuid
693             * @param groupId the group ID
694             * @param retrieveFromCache whether to use the finder cache
695             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
696             * @throws SystemException if a system exception occurred
697             */
698            @Override
699            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
700                    boolean retrieveFromCache) throws SystemException {
701                    Object[] finderArgs = new Object[] { uuid, groupId };
702    
703                    Object result = null;
704    
705                    if (retrieveFromCache) {
706                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
707                                            finderArgs, this);
708                    }
709    
710                    if (result instanceof BlogsEntry) {
711                            BlogsEntry blogsEntry = (BlogsEntry)result;
712    
713                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
714                                            (groupId != blogsEntry.getGroupId())) {
715                                    result = null;
716                            }
717                    }
718    
719                    if (result == null) {
720                            StringBundler query = new StringBundler(4);
721    
722                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
723    
724                            boolean bindUuid = false;
725    
726                            if (uuid == null) {
727                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
728                            }
729                            else if (uuid.equals(StringPool.BLANK)) {
730                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
731                            }
732                            else {
733                                    bindUuid = true;
734    
735                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
736                            }
737    
738                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
739    
740                            String sql = query.toString();
741    
742                            Session session = null;
743    
744                            try {
745                                    session = openSession();
746    
747                                    Query q = session.createQuery(sql);
748    
749                                    QueryPos qPos = QueryPos.getInstance(q);
750    
751                                    if (bindUuid) {
752                                            qPos.add(uuid);
753                                    }
754    
755                                    qPos.add(groupId);
756    
757                                    List<BlogsEntry> list = q.list();
758    
759                                    if (list.isEmpty()) {
760                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
761                                                    finderArgs, list);
762                                    }
763                                    else {
764                                            BlogsEntry blogsEntry = list.get(0);
765    
766                                            result = blogsEntry;
767    
768                                            cacheResult(blogsEntry);
769    
770                                            if ((blogsEntry.getUuid() == null) ||
771                                                            !blogsEntry.getUuid().equals(uuid) ||
772                                                            (blogsEntry.getGroupId() != groupId)) {
773                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
774                                                            finderArgs, blogsEntry);
775                                            }
776                                    }
777                            }
778                            catch (Exception e) {
779                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
780                                            finderArgs);
781    
782                                    throw processException(e);
783                            }
784                            finally {
785                                    closeSession(session);
786                            }
787                    }
788    
789                    if (result instanceof List<?>) {
790                            return null;
791                    }
792                    else {
793                            return (BlogsEntry)result;
794                    }
795            }
796    
797            /**
798             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
799             *
800             * @param uuid the uuid
801             * @param groupId the group ID
802             * @return the blogs entry that was removed
803             * @throws SystemException if a system exception occurred
804             */
805            @Override
806            public BlogsEntry removeByUUID_G(String uuid, long groupId)
807                    throws NoSuchEntryException, SystemException {
808                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
809    
810                    return remove(blogsEntry);
811            }
812    
813            /**
814             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
815             *
816             * @param uuid the uuid
817             * @param groupId the group ID
818             * @return the number of matching blogs entries
819             * @throws SystemException if a system exception occurred
820             */
821            @Override
822            public int countByUUID_G(String uuid, long groupId)
823                    throws SystemException {
824                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
825    
826                    Object[] finderArgs = new Object[] { uuid, groupId };
827    
828                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
829                                    this);
830    
831                    if (count == null) {
832                            StringBundler query = new StringBundler(3);
833    
834                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
835    
836                            boolean bindUuid = false;
837    
838                            if (uuid == null) {
839                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
840                            }
841                            else if (uuid.equals(StringPool.BLANK)) {
842                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
843                            }
844                            else {
845                                    bindUuid = true;
846    
847                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
848                            }
849    
850                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
851    
852                            String sql = query.toString();
853    
854                            Session session = null;
855    
856                            try {
857                                    session = openSession();
858    
859                                    Query q = session.createQuery(sql);
860    
861                                    QueryPos qPos = QueryPos.getInstance(q);
862    
863                                    if (bindUuid) {
864                                            qPos.add(uuid);
865                                    }
866    
867                                    qPos.add(groupId);
868    
869                                    count = (Long)q.uniqueResult();
870    
871                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
872                            }
873                            catch (Exception e) {
874                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
875    
876                                    throw processException(e);
877                            }
878                            finally {
879                                    closeSession(session);
880                            }
881                    }
882    
883                    return count.intValue();
884            }
885    
886            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
887            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
888            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
889            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
890            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
891                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
892                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
893                            new String[] {
894                                    String.class.getName(), Long.class.getName(),
895                                    
896                            Integer.class.getName(), Integer.class.getName(),
897                                    OrderByComparator.class.getName()
898                            });
899            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
900                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
901                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
902                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
903                            new String[] { String.class.getName(), Long.class.getName() },
904                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
905                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
906                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
907                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
908            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
909                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
910                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
911                            new String[] { String.class.getName(), Long.class.getName() });
912    
913            /**
914             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
915             *
916             * @param uuid the uuid
917             * @param companyId the company ID
918             * @return the matching blogs entries
919             * @throws SystemException if a system exception occurred
920             */
921            @Override
922            public List<BlogsEntry> findByUuid_C(String uuid, long companyId)
923                    throws SystemException {
924                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
925                            QueryUtil.ALL_POS, null);
926            }
927    
928            /**
929             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
930             *
931             * <p>
932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
933             * </p>
934             *
935             * @param uuid the uuid
936             * @param companyId the company ID
937             * @param start the lower bound of the range of blogs entries
938             * @param end the upper bound of the range of blogs entries (not inclusive)
939             * @return the range of matching blogs entries
940             * @throws SystemException if a system exception occurred
941             */
942            @Override
943            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
944                    int start, int end) throws SystemException {
945                    return findByUuid_C(uuid, companyId, start, end, null);
946            }
947    
948            /**
949             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
950             *
951             * <p>
952             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
953             * </p>
954             *
955             * @param uuid the uuid
956             * @param companyId the company ID
957             * @param start the lower bound of the range of blogs entries
958             * @param end the upper bound of the range of blogs entries (not inclusive)
959             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
960             * @return the ordered range of matching blogs entries
961             * @throws SystemException if a system exception occurred
962             */
963            @Override
964            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
965                    int start, int end, OrderByComparator orderByComparator)
966                    throws SystemException {
967                    boolean pagination = true;
968                    FinderPath finderPath = null;
969                    Object[] finderArgs = null;
970    
971                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
972                                    (orderByComparator == null)) {
973                            pagination = false;
974                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
975                            finderArgs = new Object[] { uuid, companyId };
976                    }
977                    else {
978                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
979                            finderArgs = new Object[] {
980                                            uuid, companyId,
981                                            
982                                            start, end, orderByComparator
983                                    };
984                    }
985    
986                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
987                                    finderArgs, this);
988    
989                    if ((list != null) && !list.isEmpty()) {
990                            for (BlogsEntry blogsEntry : list) {
991                                    if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
992                                                    (companyId != blogsEntry.getCompanyId())) {
993                                            list = null;
994    
995                                            break;
996                                    }
997                            }
998                    }
999    
1000                    if (list == null) {
1001                            StringBundler query = null;
1002    
1003                            if (orderByComparator != null) {
1004                                    query = new StringBundler(4 +
1005                                                    (orderByComparator.getOrderByFields().length * 3));
1006                            }
1007                            else {
1008                                    query = new StringBundler(4);
1009                            }
1010    
1011                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1012    
1013                            boolean bindUuid = false;
1014    
1015                            if (uuid == null) {
1016                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1017                            }
1018                            else if (uuid.equals(StringPool.BLANK)) {
1019                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1020                            }
1021                            else {
1022                                    bindUuid = true;
1023    
1024                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1025                            }
1026    
1027                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1028    
1029                            if (orderByComparator != null) {
1030                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1031                                            orderByComparator);
1032                            }
1033                            else
1034                             if (pagination) {
1035                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1036                            }
1037    
1038                            String sql = query.toString();
1039    
1040                            Session session = null;
1041    
1042                            try {
1043                                    session = openSession();
1044    
1045                                    Query q = session.createQuery(sql);
1046    
1047                                    QueryPos qPos = QueryPos.getInstance(q);
1048    
1049                                    if (bindUuid) {
1050                                            qPos.add(uuid);
1051                                    }
1052    
1053                                    qPos.add(companyId);
1054    
1055                                    if (!pagination) {
1056                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1057                                                            start, end, false);
1058    
1059                                            Collections.sort(list);
1060    
1061                                            list = new UnmodifiableList<BlogsEntry>(list);
1062                                    }
1063                                    else {
1064                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1065                                                            start, end);
1066                                    }
1067    
1068                                    cacheResult(list);
1069    
1070                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1071                            }
1072                            catch (Exception e) {
1073                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1074    
1075                                    throw processException(e);
1076                            }
1077                            finally {
1078                                    closeSession(session);
1079                            }
1080                    }
1081    
1082                    return list;
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
1092             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1093             * @throws SystemException if a system exception occurred
1094             */
1095            @Override
1096            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1097                    OrderByComparator orderByComparator)
1098                    throws NoSuchEntryException, SystemException {
1099                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1100                                    orderByComparator);
1101    
1102                    if (blogsEntry != null) {
1103                            return blogsEntry;
1104                    }
1105    
1106                    StringBundler msg = new StringBundler(6);
1107    
1108                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1109    
1110                    msg.append("uuid=");
1111                    msg.append(uuid);
1112    
1113                    msg.append(", companyId=");
1114                    msg.append(companyId);
1115    
1116                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1117    
1118                    throw new NoSuchEntryException(msg.toString());
1119            }
1120    
1121            /**
1122             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1123             *
1124             * @param uuid the uuid
1125             * @param companyId the company ID
1126             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1127             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1128             * @throws SystemException if a system exception occurred
1129             */
1130            @Override
1131            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1132                    OrderByComparator orderByComparator) throws SystemException {
1133                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1134                                    orderByComparator);
1135    
1136                    if (!list.isEmpty()) {
1137                            return list.get(0);
1138                    }
1139    
1140                    return null;
1141            }
1142    
1143            /**
1144             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1145             *
1146             * @param uuid the uuid
1147             * @param companyId the company ID
1148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1149             * @return the last matching blogs entry
1150             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1151             * @throws SystemException if a system exception occurred
1152             */
1153            @Override
1154            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1155                    OrderByComparator orderByComparator)
1156                    throws NoSuchEntryException, SystemException {
1157                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1158                                    orderByComparator);
1159    
1160                    if (blogsEntry != null) {
1161                            return blogsEntry;
1162                    }
1163    
1164                    StringBundler msg = new StringBundler(6);
1165    
1166                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1167    
1168                    msg.append("uuid=");
1169                    msg.append(uuid);
1170    
1171                    msg.append(", companyId=");
1172                    msg.append(companyId);
1173    
1174                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1175    
1176                    throw new NoSuchEntryException(msg.toString());
1177            }
1178    
1179            /**
1180             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1181             *
1182             * @param uuid the uuid
1183             * @param companyId the company ID
1184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1185             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1186             * @throws SystemException if a system exception occurred
1187             */
1188            @Override
1189            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1190                    OrderByComparator orderByComparator) throws SystemException {
1191                    int count = countByUuid_C(uuid, companyId);
1192    
1193                    if (count == 0) {
1194                            return null;
1195                    }
1196    
1197                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1198                                    orderByComparator);
1199    
1200                    if (!list.isEmpty()) {
1201                            return list.get(0);
1202                    }
1203    
1204                    return null;
1205            }
1206    
1207            /**
1208             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1209             *
1210             * @param entryId the primary key of the current blogs entry
1211             * @param uuid the uuid
1212             * @param companyId the company ID
1213             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1214             * @return the previous, current, and next blogs entry
1215             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1216             * @throws SystemException if a system exception occurred
1217             */
1218            @Override
1219            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1220                    long companyId, OrderByComparator orderByComparator)
1221                    throws NoSuchEntryException, SystemException {
1222                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1223    
1224                    Session session = null;
1225    
1226                    try {
1227                            session = openSession();
1228    
1229                            BlogsEntry[] array = new BlogsEntryImpl[3];
1230    
1231                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1232                                            companyId, orderByComparator, true);
1233    
1234                            array[1] = blogsEntry;
1235    
1236                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1237                                            companyId, orderByComparator, false);
1238    
1239                            return array;
1240                    }
1241                    catch (Exception e) {
1242                            throw processException(e);
1243                    }
1244                    finally {
1245                            closeSession(session);
1246                    }
1247            }
1248    
1249            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1250                    BlogsEntry blogsEntry, String uuid, long companyId,
1251                    OrderByComparator orderByComparator, boolean previous) {
1252                    StringBundler query = null;
1253    
1254                    if (orderByComparator != null) {
1255                            query = new StringBundler(6 +
1256                                            (orderByComparator.getOrderByFields().length * 6));
1257                    }
1258                    else {
1259                            query = new StringBundler(3);
1260                    }
1261    
1262                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1263    
1264                    boolean bindUuid = false;
1265    
1266                    if (uuid == null) {
1267                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1268                    }
1269                    else if (uuid.equals(StringPool.BLANK)) {
1270                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1271                    }
1272                    else {
1273                            bindUuid = true;
1274    
1275                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1276                    }
1277    
1278                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1279    
1280                    if (orderByComparator != null) {
1281                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1282    
1283                            if (orderByConditionFields.length > 0) {
1284                                    query.append(WHERE_AND);
1285                            }
1286    
1287                            for (int i = 0; i < orderByConditionFields.length; i++) {
1288                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1289                                    query.append(orderByConditionFields[i]);
1290    
1291                                    if ((i + 1) < orderByConditionFields.length) {
1292                                            if (orderByComparator.isAscending() ^ previous) {
1293                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1294                                            }
1295                                            else {
1296                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1297                                            }
1298                                    }
1299                                    else {
1300                                            if (orderByComparator.isAscending() ^ previous) {
1301                                                    query.append(WHERE_GREATER_THAN);
1302                                            }
1303                                            else {
1304                                                    query.append(WHERE_LESSER_THAN);
1305                                            }
1306                                    }
1307                            }
1308    
1309                            query.append(ORDER_BY_CLAUSE);
1310    
1311                            String[] orderByFields = orderByComparator.getOrderByFields();
1312    
1313                            for (int i = 0; i < orderByFields.length; i++) {
1314                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1315                                    query.append(orderByFields[i]);
1316    
1317                                    if ((i + 1) < orderByFields.length) {
1318                                            if (orderByComparator.isAscending() ^ previous) {
1319                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1320                                            }
1321                                            else {
1322                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1323                                            }
1324                                    }
1325                                    else {
1326                                            if (orderByComparator.isAscending() ^ previous) {
1327                                                    query.append(ORDER_BY_ASC);
1328                                            }
1329                                            else {
1330                                                    query.append(ORDER_BY_DESC);
1331                                            }
1332                                    }
1333                            }
1334                    }
1335                    else {
1336                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1337                    }
1338    
1339                    String sql = query.toString();
1340    
1341                    Query q = session.createQuery(sql);
1342    
1343                    q.setFirstResult(0);
1344                    q.setMaxResults(2);
1345    
1346                    QueryPos qPos = QueryPos.getInstance(q);
1347    
1348                    if (bindUuid) {
1349                            qPos.add(uuid);
1350                    }
1351    
1352                    qPos.add(companyId);
1353    
1354                    if (orderByComparator != null) {
1355                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1356    
1357                            for (Object value : values) {
1358                                    qPos.add(value);
1359                            }
1360                    }
1361    
1362                    List<BlogsEntry> list = q.list();
1363    
1364                    if (list.size() == 2) {
1365                            return list.get(1);
1366                    }
1367                    else {
1368                            return null;
1369                    }
1370            }
1371    
1372            /**
1373             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1374             *
1375             * @param uuid the uuid
1376             * @param companyId the company ID
1377             * @throws SystemException if a system exception occurred
1378             */
1379            @Override
1380            public void removeByUuid_C(String uuid, long companyId)
1381                    throws SystemException {
1382                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1383                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1384                            remove(blogsEntry);
1385                    }
1386            }
1387    
1388            /**
1389             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1390             *
1391             * @param uuid the uuid
1392             * @param companyId the company ID
1393             * @return the number of matching blogs entries
1394             * @throws SystemException if a system exception occurred
1395             */
1396            @Override
1397            public int countByUuid_C(String uuid, long companyId)
1398                    throws SystemException {
1399                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1400    
1401                    Object[] finderArgs = new Object[] { uuid, companyId };
1402    
1403                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1404                                    this);
1405    
1406                    if (count == null) {
1407                            StringBundler query = new StringBundler(3);
1408    
1409                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1410    
1411                            boolean bindUuid = false;
1412    
1413                            if (uuid == null) {
1414                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1415                            }
1416                            else if (uuid.equals(StringPool.BLANK)) {
1417                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1418                            }
1419                            else {
1420                                    bindUuid = true;
1421    
1422                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1423                            }
1424    
1425                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1426    
1427                            String sql = query.toString();
1428    
1429                            Session session = null;
1430    
1431                            try {
1432                                    session = openSession();
1433    
1434                                    Query q = session.createQuery(sql);
1435    
1436                                    QueryPos qPos = QueryPos.getInstance(q);
1437    
1438                                    if (bindUuid) {
1439                                            qPos.add(uuid);
1440                                    }
1441    
1442                                    qPos.add(companyId);
1443    
1444                                    count = (Long)q.uniqueResult();
1445    
1446                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1447                            }
1448                            catch (Exception e) {
1449                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1450    
1451                                    throw processException(e);
1452                            }
1453                            finally {
1454                                    closeSession(session);
1455                            }
1456                    }
1457    
1458                    return count.intValue();
1459            }
1460    
1461            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1462            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1463            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1464            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1465            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1466                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1467                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1468                            new String[] {
1469                                    Long.class.getName(),
1470                                    
1471                            Integer.class.getName(), Integer.class.getName(),
1472                                    OrderByComparator.class.getName()
1473                            });
1474            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1475                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1476                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1477                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1478                            new String[] { Long.class.getName() },
1479                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1480                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1481                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1482            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1483                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1484                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1485                            new String[] { Long.class.getName() });
1486    
1487            /**
1488             * Returns all the blogs entries where groupId = &#63;.
1489             *
1490             * @param groupId the group ID
1491             * @return the matching blogs entries
1492             * @throws SystemException if a system exception occurred
1493             */
1494            @Override
1495            public List<BlogsEntry> findByGroupId(long groupId)
1496                    throws SystemException {
1497                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1498            }
1499    
1500            /**
1501             * Returns a range of all the blogs entries where groupId = &#63;.
1502             *
1503             * <p>
1504             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1505             * </p>
1506             *
1507             * @param groupId the group ID
1508             * @param start the lower bound of the range of blogs entries
1509             * @param end the upper bound of the range of blogs entries (not inclusive)
1510             * @return the range of matching blogs entries
1511             * @throws SystemException if a system exception occurred
1512             */
1513            @Override
1514            public List<BlogsEntry> findByGroupId(long groupId, int start, int end)
1515                    throws SystemException {
1516                    return findByGroupId(groupId, start, end, null);
1517            }
1518    
1519            /**
1520             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1521             *
1522             * <p>
1523             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1524             * </p>
1525             *
1526             * @param groupId the group ID
1527             * @param start the lower bound of the range of blogs entries
1528             * @param end the upper bound of the range of blogs entries (not inclusive)
1529             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1530             * @return the ordered range of matching blogs entries
1531             * @throws SystemException if a system exception occurred
1532             */
1533            @Override
1534            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1535                    OrderByComparator orderByComparator) throws SystemException {
1536                    boolean pagination = true;
1537                    FinderPath finderPath = null;
1538                    Object[] finderArgs = null;
1539    
1540                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1541                                    (orderByComparator == null)) {
1542                            pagination = false;
1543                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1544                            finderArgs = new Object[] { groupId };
1545                    }
1546                    else {
1547                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1548                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1549                    }
1550    
1551                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1552                                    finderArgs, this);
1553    
1554                    if ((list != null) && !list.isEmpty()) {
1555                            for (BlogsEntry blogsEntry : list) {
1556                                    if ((groupId != blogsEntry.getGroupId())) {
1557                                            list = null;
1558    
1559                                            break;
1560                                    }
1561                            }
1562                    }
1563    
1564                    if (list == null) {
1565                            StringBundler query = null;
1566    
1567                            if (orderByComparator != null) {
1568                                    query = new StringBundler(3 +
1569                                                    (orderByComparator.getOrderByFields().length * 3));
1570                            }
1571                            else {
1572                                    query = new StringBundler(3);
1573                            }
1574    
1575                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1576    
1577                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1578    
1579                            if (orderByComparator != null) {
1580                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1581                                            orderByComparator);
1582                            }
1583                            else
1584                             if (pagination) {
1585                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1586                            }
1587    
1588                            String sql = query.toString();
1589    
1590                            Session session = null;
1591    
1592                            try {
1593                                    session = openSession();
1594    
1595                                    Query q = session.createQuery(sql);
1596    
1597                                    QueryPos qPos = QueryPos.getInstance(q);
1598    
1599                                    qPos.add(groupId);
1600    
1601                                    if (!pagination) {
1602                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1603                                                            start, end, false);
1604    
1605                                            Collections.sort(list);
1606    
1607                                            list = new UnmodifiableList<BlogsEntry>(list);
1608                                    }
1609                                    else {
1610                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1611                                                            start, end);
1612                                    }
1613    
1614                                    cacheResult(list);
1615    
1616                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1617                            }
1618                            catch (Exception e) {
1619                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1620    
1621                                    throw processException(e);
1622                            }
1623                            finally {
1624                                    closeSession(session);
1625                            }
1626                    }
1627    
1628                    return list;
1629            }
1630    
1631            /**
1632             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1633             *
1634             * @param groupId the group ID
1635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1636             * @return the first matching blogs entry
1637             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1638             * @throws SystemException if a system exception occurred
1639             */
1640            @Override
1641            public BlogsEntry findByGroupId_First(long groupId,
1642                    OrderByComparator orderByComparator)
1643                    throws NoSuchEntryException, SystemException {
1644                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1645    
1646                    if (blogsEntry != null) {
1647                            return blogsEntry;
1648                    }
1649    
1650                    StringBundler msg = new StringBundler(4);
1651    
1652                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1653    
1654                    msg.append("groupId=");
1655                    msg.append(groupId);
1656    
1657                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1658    
1659                    throw new NoSuchEntryException(msg.toString());
1660            }
1661    
1662            /**
1663             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1664             *
1665             * @param groupId the group ID
1666             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1667             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1668             * @throws SystemException if a system exception occurred
1669             */
1670            @Override
1671            public BlogsEntry fetchByGroupId_First(long groupId,
1672                    OrderByComparator orderByComparator) throws SystemException {
1673                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1674    
1675                    if (!list.isEmpty()) {
1676                            return list.get(0);
1677                    }
1678    
1679                    return null;
1680            }
1681    
1682            /**
1683             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1684             *
1685             * @param groupId the group ID
1686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1687             * @return the last matching blogs entry
1688             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1689             * @throws SystemException if a system exception occurred
1690             */
1691            @Override
1692            public BlogsEntry findByGroupId_Last(long groupId,
1693                    OrderByComparator orderByComparator)
1694                    throws NoSuchEntryException, SystemException {
1695                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1696    
1697                    if (blogsEntry != null) {
1698                            return blogsEntry;
1699                    }
1700    
1701                    StringBundler msg = new StringBundler(4);
1702    
1703                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1704    
1705                    msg.append("groupId=");
1706                    msg.append(groupId);
1707    
1708                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1709    
1710                    throw new NoSuchEntryException(msg.toString());
1711            }
1712    
1713            /**
1714             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1715             *
1716             * @param groupId the group ID
1717             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1718             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1719             * @throws SystemException if a system exception occurred
1720             */
1721            @Override
1722            public BlogsEntry fetchByGroupId_Last(long groupId,
1723                    OrderByComparator orderByComparator) throws SystemException {
1724                    int count = countByGroupId(groupId);
1725    
1726                    if (count == 0) {
1727                            return null;
1728                    }
1729    
1730                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1731                                    orderByComparator);
1732    
1733                    if (!list.isEmpty()) {
1734                            return list.get(0);
1735                    }
1736    
1737                    return null;
1738            }
1739    
1740            /**
1741             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1742             *
1743             * @param entryId the primary key of the current blogs entry
1744             * @param groupId the group ID
1745             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1746             * @return the previous, current, and next blogs entry
1747             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1748             * @throws SystemException if a system exception occurred
1749             */
1750            @Override
1751            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1752                    OrderByComparator orderByComparator)
1753                    throws NoSuchEntryException, SystemException {
1754                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1755    
1756                    Session session = null;
1757    
1758                    try {
1759                            session = openSession();
1760    
1761                            BlogsEntry[] array = new BlogsEntryImpl[3];
1762    
1763                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1764                                            orderByComparator, true);
1765    
1766                            array[1] = blogsEntry;
1767    
1768                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1769                                            orderByComparator, false);
1770    
1771                            return array;
1772                    }
1773                    catch (Exception e) {
1774                            throw processException(e);
1775                    }
1776                    finally {
1777                            closeSession(session);
1778                    }
1779            }
1780    
1781            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1782                    BlogsEntry blogsEntry, long groupId,
1783                    OrderByComparator orderByComparator, boolean previous) {
1784                    StringBundler query = null;
1785    
1786                    if (orderByComparator != null) {
1787                            query = new StringBundler(6 +
1788                                            (orderByComparator.getOrderByFields().length * 6));
1789                    }
1790                    else {
1791                            query = new StringBundler(3);
1792                    }
1793    
1794                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1795    
1796                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1797    
1798                    if (orderByComparator != null) {
1799                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1800    
1801                            if (orderByConditionFields.length > 0) {
1802                                    query.append(WHERE_AND);
1803                            }
1804    
1805                            for (int i = 0; i < orderByConditionFields.length; i++) {
1806                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1807                                    query.append(orderByConditionFields[i]);
1808    
1809                                    if ((i + 1) < orderByConditionFields.length) {
1810                                            if (orderByComparator.isAscending() ^ previous) {
1811                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1812                                            }
1813                                            else {
1814                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1815                                            }
1816                                    }
1817                                    else {
1818                                            if (orderByComparator.isAscending() ^ previous) {
1819                                                    query.append(WHERE_GREATER_THAN);
1820                                            }
1821                                            else {
1822                                                    query.append(WHERE_LESSER_THAN);
1823                                            }
1824                                    }
1825                            }
1826    
1827                            query.append(ORDER_BY_CLAUSE);
1828    
1829                            String[] orderByFields = orderByComparator.getOrderByFields();
1830    
1831                            for (int i = 0; i < orderByFields.length; i++) {
1832                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1833                                    query.append(orderByFields[i]);
1834    
1835                                    if ((i + 1) < orderByFields.length) {
1836                                            if (orderByComparator.isAscending() ^ previous) {
1837                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1838                                            }
1839                                            else {
1840                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1841                                            }
1842                                    }
1843                                    else {
1844                                            if (orderByComparator.isAscending() ^ previous) {
1845                                                    query.append(ORDER_BY_ASC);
1846                                            }
1847                                            else {
1848                                                    query.append(ORDER_BY_DESC);
1849                                            }
1850                                    }
1851                            }
1852                    }
1853                    else {
1854                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1855                    }
1856    
1857                    String sql = query.toString();
1858    
1859                    Query q = session.createQuery(sql);
1860    
1861                    q.setFirstResult(0);
1862                    q.setMaxResults(2);
1863    
1864                    QueryPos qPos = QueryPos.getInstance(q);
1865    
1866                    qPos.add(groupId);
1867    
1868                    if (orderByComparator != null) {
1869                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1870    
1871                            for (Object value : values) {
1872                                    qPos.add(value);
1873                            }
1874                    }
1875    
1876                    List<BlogsEntry> list = q.list();
1877    
1878                    if (list.size() == 2) {
1879                            return list.get(1);
1880                    }
1881                    else {
1882                            return null;
1883                    }
1884            }
1885    
1886            /**
1887             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1888             *
1889             * @param groupId the group ID
1890             * @return the matching blogs entries that the user has permission to view
1891             * @throws SystemException if a system exception occurred
1892             */
1893            @Override
1894            public List<BlogsEntry> filterFindByGroupId(long groupId)
1895                    throws SystemException {
1896                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1897                            QueryUtil.ALL_POS, null);
1898            }
1899    
1900            /**
1901             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1902             *
1903             * <p>
1904             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1905             * </p>
1906             *
1907             * @param groupId the group ID
1908             * @param start the lower bound of the range of blogs entries
1909             * @param end the upper bound of the range of blogs entries (not inclusive)
1910             * @return the range of matching blogs entries that the user has permission to view
1911             * @throws SystemException if a system exception occurred
1912             */
1913            @Override
1914            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end)
1915                    throws SystemException {
1916                    return filterFindByGroupId(groupId, start, end, null);
1917            }
1918    
1919            /**
1920             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1921             *
1922             * <p>
1923             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1924             * </p>
1925             *
1926             * @param groupId the group ID
1927             * @param start the lower bound of the range of blogs entries
1928             * @param end the upper bound of the range of blogs entries (not inclusive)
1929             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1930             * @return the ordered range of matching blogs entries that the user has permission to view
1931             * @throws SystemException if a system exception occurred
1932             */
1933            @Override
1934            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1935                    int end, OrderByComparator orderByComparator) throws SystemException {
1936                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1937                            return findByGroupId(groupId, start, end, orderByComparator);
1938                    }
1939    
1940                    StringBundler query = null;
1941    
1942                    if (orderByComparator != null) {
1943                            query = new StringBundler(3 +
1944                                            (orderByComparator.getOrderByFields().length * 3));
1945                    }
1946                    else {
1947                            query = new StringBundler(3);
1948                    }
1949    
1950                    if (getDB().isSupportsInlineDistinct()) {
1951                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1952                    }
1953                    else {
1954                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1955                    }
1956    
1957                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1958    
1959                    if (!getDB().isSupportsInlineDistinct()) {
1960                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1961                    }
1962    
1963                    if (orderByComparator != null) {
1964                            if (getDB().isSupportsInlineDistinct()) {
1965                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1966                                            orderByComparator, true);
1967                            }
1968                            else {
1969                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1970                                            orderByComparator, true);
1971                            }
1972                    }
1973                    else {
1974                            if (getDB().isSupportsInlineDistinct()) {
1975                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1976                            }
1977                            else {
1978                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
1979                            }
1980                    }
1981    
1982                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1983                                    BlogsEntry.class.getName(),
1984                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1985    
1986                    Session session = null;
1987    
1988                    try {
1989                            session = openSession();
1990    
1991                            SQLQuery q = session.createSQLQuery(sql);
1992    
1993                            if (getDB().isSupportsInlineDistinct()) {
1994                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
1995                            }
1996                            else {
1997                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
1998                            }
1999    
2000                            QueryPos qPos = QueryPos.getInstance(q);
2001    
2002                            qPos.add(groupId);
2003    
2004                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2005                    }
2006                    catch (Exception e) {
2007                            throw processException(e);
2008                    }
2009                    finally {
2010                            closeSession(session);
2011                    }
2012            }
2013    
2014            /**
2015             * 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;.
2016             *
2017             * @param entryId the primary key of the current blogs entry
2018             * @param groupId the group ID
2019             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2020             * @return the previous, current, and next blogs entry
2021             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2022             * @throws SystemException if a system exception occurred
2023             */
2024            @Override
2025            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2026                    long groupId, OrderByComparator orderByComparator)
2027                    throws NoSuchEntryException, SystemException {
2028                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2029                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2030                    }
2031    
2032                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2033    
2034                    Session session = null;
2035    
2036                    try {
2037                            session = openSession();
2038    
2039                            BlogsEntry[] array = new BlogsEntryImpl[3];
2040    
2041                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2042                                            groupId, orderByComparator, true);
2043    
2044                            array[1] = blogsEntry;
2045    
2046                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2047                                            groupId, orderByComparator, false);
2048    
2049                            return array;
2050                    }
2051                    catch (Exception e) {
2052                            throw processException(e);
2053                    }
2054                    finally {
2055                            closeSession(session);
2056                    }
2057            }
2058    
2059            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2060                    BlogsEntry blogsEntry, long groupId,
2061                    OrderByComparator orderByComparator, boolean previous) {
2062                    StringBundler query = null;
2063    
2064                    if (orderByComparator != null) {
2065                            query = new StringBundler(6 +
2066                                            (orderByComparator.getOrderByFields().length * 6));
2067                    }
2068                    else {
2069                            query = new StringBundler(3);
2070                    }
2071    
2072                    if (getDB().isSupportsInlineDistinct()) {
2073                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2074                    }
2075                    else {
2076                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2077                    }
2078    
2079                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2080    
2081                    if (!getDB().isSupportsInlineDistinct()) {
2082                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2083                    }
2084    
2085                    if (orderByComparator != null) {
2086                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2087    
2088                            if (orderByConditionFields.length > 0) {
2089                                    query.append(WHERE_AND);
2090                            }
2091    
2092                            for (int i = 0; i < orderByConditionFields.length; i++) {
2093                                    if (getDB().isSupportsInlineDistinct()) {
2094                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2095                                    }
2096                                    else {
2097                                            query.append(_ORDER_BY_ENTITY_TABLE);
2098                                    }
2099    
2100                                    query.append(orderByConditionFields[i]);
2101    
2102                                    if ((i + 1) < orderByConditionFields.length) {
2103                                            if (orderByComparator.isAscending() ^ previous) {
2104                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2105                                            }
2106                                            else {
2107                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2108                                            }
2109                                    }
2110                                    else {
2111                                            if (orderByComparator.isAscending() ^ previous) {
2112                                                    query.append(WHERE_GREATER_THAN);
2113                                            }
2114                                            else {
2115                                                    query.append(WHERE_LESSER_THAN);
2116                                            }
2117                                    }
2118                            }
2119    
2120                            query.append(ORDER_BY_CLAUSE);
2121    
2122                            String[] orderByFields = orderByComparator.getOrderByFields();
2123    
2124                            for (int i = 0; i < orderByFields.length; i++) {
2125                                    if (getDB().isSupportsInlineDistinct()) {
2126                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2127                                    }
2128                                    else {
2129                                            query.append(_ORDER_BY_ENTITY_TABLE);
2130                                    }
2131    
2132                                    query.append(orderByFields[i]);
2133    
2134                                    if ((i + 1) < orderByFields.length) {
2135                                            if (orderByComparator.isAscending() ^ previous) {
2136                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2137                                            }
2138                                            else {
2139                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2140                                            }
2141                                    }
2142                                    else {
2143                                            if (orderByComparator.isAscending() ^ previous) {
2144                                                    query.append(ORDER_BY_ASC);
2145                                            }
2146                                            else {
2147                                                    query.append(ORDER_BY_DESC);
2148                                            }
2149                                    }
2150                            }
2151                    }
2152                    else {
2153                            if (getDB().isSupportsInlineDistinct()) {
2154                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2155                            }
2156                            else {
2157                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2158                            }
2159                    }
2160    
2161                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2162                                    BlogsEntry.class.getName(),
2163                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2164    
2165                    SQLQuery q = session.createSQLQuery(sql);
2166    
2167                    q.setFirstResult(0);
2168                    q.setMaxResults(2);
2169    
2170                    if (getDB().isSupportsInlineDistinct()) {
2171                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2172                    }
2173                    else {
2174                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2175                    }
2176    
2177                    QueryPos qPos = QueryPos.getInstance(q);
2178    
2179                    qPos.add(groupId);
2180    
2181                    if (orderByComparator != null) {
2182                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2183    
2184                            for (Object value : values) {
2185                                    qPos.add(value);
2186                            }
2187                    }
2188    
2189                    List<BlogsEntry> list = q.list();
2190    
2191                    if (list.size() == 2) {
2192                            return list.get(1);
2193                    }
2194                    else {
2195                            return null;
2196                    }
2197            }
2198    
2199            /**
2200             * Removes all the blogs entries where groupId = &#63; from the database.
2201             *
2202             * @param groupId the group ID
2203             * @throws SystemException if a system exception occurred
2204             */
2205            @Override
2206            public void removeByGroupId(long groupId) throws SystemException {
2207                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2208                                    QueryUtil.ALL_POS, null)) {
2209                            remove(blogsEntry);
2210                    }
2211            }
2212    
2213            /**
2214             * Returns the number of blogs entries where groupId = &#63;.
2215             *
2216             * @param groupId the group ID
2217             * @return the number of matching blogs entries
2218             * @throws SystemException if a system exception occurred
2219             */
2220            @Override
2221            public int countByGroupId(long groupId) throws SystemException {
2222                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2223    
2224                    Object[] finderArgs = new Object[] { groupId };
2225    
2226                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2227                                    this);
2228    
2229                    if (count == null) {
2230                            StringBundler query = new StringBundler(2);
2231    
2232                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2233    
2234                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2235    
2236                            String sql = query.toString();
2237    
2238                            Session session = null;
2239    
2240                            try {
2241                                    session = openSession();
2242    
2243                                    Query q = session.createQuery(sql);
2244    
2245                                    QueryPos qPos = QueryPos.getInstance(q);
2246    
2247                                    qPos.add(groupId);
2248    
2249                                    count = (Long)q.uniqueResult();
2250    
2251                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2252                            }
2253                            catch (Exception e) {
2254                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2255    
2256                                    throw processException(e);
2257                            }
2258                            finally {
2259                                    closeSession(session);
2260                            }
2261                    }
2262    
2263                    return count.intValue();
2264            }
2265    
2266            /**
2267             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2268             *
2269             * @param groupId the group ID
2270             * @return the number of matching blogs entries that the user has permission to view
2271             * @throws SystemException if a system exception occurred
2272             */
2273            @Override
2274            public int filterCountByGroupId(long groupId) throws SystemException {
2275                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2276                            return countByGroupId(groupId);
2277                    }
2278    
2279                    StringBundler query = new StringBundler(2);
2280    
2281                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2282    
2283                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2284    
2285                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2286                                    BlogsEntry.class.getName(),
2287                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2288    
2289                    Session session = null;
2290    
2291                    try {
2292                            session = openSession();
2293    
2294                            SQLQuery q = session.createSQLQuery(sql);
2295    
2296                            q.addScalar(COUNT_COLUMN_NAME,
2297                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2298    
2299                            QueryPos qPos = QueryPos.getInstance(q);
2300    
2301                            qPos.add(groupId);
2302    
2303                            Long count = (Long)q.uniqueResult();
2304    
2305                            return count.intValue();
2306                    }
2307                    catch (Exception e) {
2308                            throw processException(e);
2309                    }
2310                    finally {
2311                            closeSession(session);
2312                    }
2313            }
2314    
2315            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2316            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2317                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2318                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2319                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2320                            new String[] {
2321                                    Long.class.getName(),
2322                                    
2323                            Integer.class.getName(), Integer.class.getName(),
2324                                    OrderByComparator.class.getName()
2325                            });
2326            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2327                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2328                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2329                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2330                            new String[] { Long.class.getName() },
2331                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2332                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2333                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2334            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2335                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2336                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2337                            new String[] { Long.class.getName() });
2338    
2339            /**
2340             * Returns all the blogs entries where companyId = &#63;.
2341             *
2342             * @param companyId the company ID
2343             * @return the matching blogs entries
2344             * @throws SystemException if a system exception occurred
2345             */
2346            @Override
2347            public List<BlogsEntry> findByCompanyId(long companyId)
2348                    throws SystemException {
2349                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2350                            null);
2351            }
2352    
2353            /**
2354             * Returns a range of all the blogs entries where companyId = &#63;.
2355             *
2356             * <p>
2357             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
2358             * </p>
2359             *
2360             * @param companyId the company ID
2361             * @param start the lower bound of the range of blogs entries
2362             * @param end the upper bound of the range of blogs entries (not inclusive)
2363             * @return the range of matching blogs entries
2364             * @throws SystemException if a system exception occurred
2365             */
2366            @Override
2367            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end)
2368                    throws SystemException {
2369                    return findByCompanyId(companyId, start, end, null);
2370            }
2371    
2372            /**
2373             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2374             *
2375             * <p>
2376             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
2377             * </p>
2378             *
2379             * @param companyId the company ID
2380             * @param start the lower bound of the range of blogs entries
2381             * @param end the upper bound of the range of blogs entries (not inclusive)
2382             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2383             * @return the ordered range of matching blogs entries
2384             * @throws SystemException if a system exception occurred
2385             */
2386            @Override
2387            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2388                    OrderByComparator orderByComparator) throws SystemException {
2389                    boolean pagination = true;
2390                    FinderPath finderPath = null;
2391                    Object[] finderArgs = null;
2392    
2393                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2394                                    (orderByComparator == null)) {
2395                            pagination = false;
2396                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2397                            finderArgs = new Object[] { companyId };
2398                    }
2399                    else {
2400                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2401                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2402                    }
2403    
2404                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2405                                    finderArgs, this);
2406    
2407                    if ((list != null) && !list.isEmpty()) {
2408                            for (BlogsEntry blogsEntry : list) {
2409                                    if ((companyId != blogsEntry.getCompanyId())) {
2410                                            list = null;
2411    
2412                                            break;
2413                                    }
2414                            }
2415                    }
2416    
2417                    if (list == null) {
2418                            StringBundler query = null;
2419    
2420                            if (orderByComparator != null) {
2421                                    query = new StringBundler(3 +
2422                                                    (orderByComparator.getOrderByFields().length * 3));
2423                            }
2424                            else {
2425                                    query = new StringBundler(3);
2426                            }
2427    
2428                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2429    
2430                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2431    
2432                            if (orderByComparator != null) {
2433                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2434                                            orderByComparator);
2435                            }
2436                            else
2437                             if (pagination) {
2438                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2439                            }
2440    
2441                            String sql = query.toString();
2442    
2443                            Session session = null;
2444    
2445                            try {
2446                                    session = openSession();
2447    
2448                                    Query q = session.createQuery(sql);
2449    
2450                                    QueryPos qPos = QueryPos.getInstance(q);
2451    
2452                                    qPos.add(companyId);
2453    
2454                                    if (!pagination) {
2455                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2456                                                            start, end, false);
2457    
2458                                            Collections.sort(list);
2459    
2460                                            list = new UnmodifiableList<BlogsEntry>(list);
2461                                    }
2462                                    else {
2463                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2464                                                            start, end);
2465                                    }
2466    
2467                                    cacheResult(list);
2468    
2469                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2470                            }
2471                            catch (Exception e) {
2472                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2473    
2474                                    throw processException(e);
2475                            }
2476                            finally {
2477                                    closeSession(session);
2478                            }
2479                    }
2480    
2481                    return list;
2482            }
2483    
2484            /**
2485             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2486             *
2487             * @param companyId the company ID
2488             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2489             * @return the first matching blogs entry
2490             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2491             * @throws SystemException if a system exception occurred
2492             */
2493            @Override
2494            public BlogsEntry findByCompanyId_First(long companyId,
2495                    OrderByComparator orderByComparator)
2496                    throws NoSuchEntryException, SystemException {
2497                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2498                                    orderByComparator);
2499    
2500                    if (blogsEntry != null) {
2501                            return blogsEntry;
2502                    }
2503    
2504                    StringBundler msg = new StringBundler(4);
2505    
2506                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2507    
2508                    msg.append("companyId=");
2509                    msg.append(companyId);
2510    
2511                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2512    
2513                    throw new NoSuchEntryException(msg.toString());
2514            }
2515    
2516            /**
2517             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2518             *
2519             * @param companyId the company ID
2520             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2521             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2522             * @throws SystemException if a system exception occurred
2523             */
2524            @Override
2525            public BlogsEntry fetchByCompanyId_First(long companyId,
2526                    OrderByComparator orderByComparator) throws SystemException {
2527                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2528                                    orderByComparator);
2529    
2530                    if (!list.isEmpty()) {
2531                            return list.get(0);
2532                    }
2533    
2534                    return null;
2535            }
2536    
2537            /**
2538             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2539             *
2540             * @param companyId the company ID
2541             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2542             * @return the last matching blogs entry
2543             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2544             * @throws SystemException if a system exception occurred
2545             */
2546            @Override
2547            public BlogsEntry findByCompanyId_Last(long companyId,
2548                    OrderByComparator orderByComparator)
2549                    throws NoSuchEntryException, SystemException {
2550                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2551                                    orderByComparator);
2552    
2553                    if (blogsEntry != null) {
2554                            return blogsEntry;
2555                    }
2556    
2557                    StringBundler msg = new StringBundler(4);
2558    
2559                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2560    
2561                    msg.append("companyId=");
2562                    msg.append(companyId);
2563    
2564                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2565    
2566                    throw new NoSuchEntryException(msg.toString());
2567            }
2568    
2569            /**
2570             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2571             *
2572             * @param companyId the company ID
2573             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2574             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2575             * @throws SystemException if a system exception occurred
2576             */
2577            @Override
2578            public BlogsEntry fetchByCompanyId_Last(long companyId,
2579                    OrderByComparator orderByComparator) throws SystemException {
2580                    int count = countByCompanyId(companyId);
2581    
2582                    if (count == 0) {
2583                            return null;
2584                    }
2585    
2586                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2587                                    orderByComparator);
2588    
2589                    if (!list.isEmpty()) {
2590                            return list.get(0);
2591                    }
2592    
2593                    return null;
2594            }
2595    
2596            /**
2597             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2598             *
2599             * @param entryId the primary key of the current blogs entry
2600             * @param companyId the company ID
2601             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2602             * @return the previous, current, and next blogs entry
2603             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2604             * @throws SystemException if a system exception occurred
2605             */
2606            @Override
2607            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2608                    long companyId, OrderByComparator orderByComparator)
2609                    throws NoSuchEntryException, SystemException {
2610                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2611    
2612                    Session session = null;
2613    
2614                    try {
2615                            session = openSession();
2616    
2617                            BlogsEntry[] array = new BlogsEntryImpl[3];
2618    
2619                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2620                                            companyId, orderByComparator, true);
2621    
2622                            array[1] = blogsEntry;
2623    
2624                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2625                                            companyId, orderByComparator, false);
2626    
2627                            return array;
2628                    }
2629                    catch (Exception e) {
2630                            throw processException(e);
2631                    }
2632                    finally {
2633                            closeSession(session);
2634                    }
2635            }
2636    
2637            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2638                    BlogsEntry blogsEntry, long companyId,
2639                    OrderByComparator orderByComparator, boolean previous) {
2640                    StringBundler query = null;
2641    
2642                    if (orderByComparator != null) {
2643                            query = new StringBundler(6 +
2644                                            (orderByComparator.getOrderByFields().length * 6));
2645                    }
2646                    else {
2647                            query = new StringBundler(3);
2648                    }
2649    
2650                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2651    
2652                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2653    
2654                    if (orderByComparator != null) {
2655                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2656    
2657                            if (orderByConditionFields.length > 0) {
2658                                    query.append(WHERE_AND);
2659                            }
2660    
2661                            for (int i = 0; i < orderByConditionFields.length; i++) {
2662                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2663                                    query.append(orderByConditionFields[i]);
2664    
2665                                    if ((i + 1) < orderByConditionFields.length) {
2666                                            if (orderByComparator.isAscending() ^ previous) {
2667                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2668                                            }
2669                                            else {
2670                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2671                                            }
2672                                    }
2673                                    else {
2674                                            if (orderByComparator.isAscending() ^ previous) {
2675                                                    query.append(WHERE_GREATER_THAN);
2676                                            }
2677                                            else {
2678                                                    query.append(WHERE_LESSER_THAN);
2679                                            }
2680                                    }
2681                            }
2682    
2683                            query.append(ORDER_BY_CLAUSE);
2684    
2685                            String[] orderByFields = orderByComparator.getOrderByFields();
2686    
2687                            for (int i = 0; i < orderByFields.length; i++) {
2688                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2689                                    query.append(orderByFields[i]);
2690    
2691                                    if ((i + 1) < orderByFields.length) {
2692                                            if (orderByComparator.isAscending() ^ previous) {
2693                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2694                                            }
2695                                            else {
2696                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2697                                            }
2698                                    }
2699                                    else {
2700                                            if (orderByComparator.isAscending() ^ previous) {
2701                                                    query.append(ORDER_BY_ASC);
2702                                            }
2703                                            else {
2704                                                    query.append(ORDER_BY_DESC);
2705                                            }
2706                                    }
2707                            }
2708                    }
2709                    else {
2710                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2711                    }
2712    
2713                    String sql = query.toString();
2714    
2715                    Query q = session.createQuery(sql);
2716    
2717                    q.setFirstResult(0);
2718                    q.setMaxResults(2);
2719    
2720                    QueryPos qPos = QueryPos.getInstance(q);
2721    
2722                    qPos.add(companyId);
2723    
2724                    if (orderByComparator != null) {
2725                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2726    
2727                            for (Object value : values) {
2728                                    qPos.add(value);
2729                            }
2730                    }
2731    
2732                    List<BlogsEntry> list = q.list();
2733    
2734                    if (list.size() == 2) {
2735                            return list.get(1);
2736                    }
2737                    else {
2738                            return null;
2739                    }
2740            }
2741    
2742            /**
2743             * Removes all the blogs entries where companyId = &#63; from the database.
2744             *
2745             * @param companyId the company ID
2746             * @throws SystemException if a system exception occurred
2747             */
2748            @Override
2749            public void removeByCompanyId(long companyId) throws SystemException {
2750                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2751                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2752                            remove(blogsEntry);
2753                    }
2754            }
2755    
2756            /**
2757             * Returns the number of blogs entries where companyId = &#63;.
2758             *
2759             * @param companyId the company ID
2760             * @return the number of matching blogs entries
2761             * @throws SystemException if a system exception occurred
2762             */
2763            @Override
2764            public int countByCompanyId(long companyId) throws SystemException {
2765                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2766    
2767                    Object[] finderArgs = new Object[] { companyId };
2768    
2769                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2770                                    this);
2771    
2772                    if (count == null) {
2773                            StringBundler query = new StringBundler(2);
2774    
2775                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2776    
2777                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2778    
2779                            String sql = query.toString();
2780    
2781                            Session session = null;
2782    
2783                            try {
2784                                    session = openSession();
2785    
2786                                    Query q = session.createQuery(sql);
2787    
2788                                    QueryPos qPos = QueryPos.getInstance(q);
2789    
2790                                    qPos.add(companyId);
2791    
2792                                    count = (Long)q.uniqueResult();
2793    
2794                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2795                            }
2796                            catch (Exception e) {
2797                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2798    
2799                                    throw processException(e);
2800                            }
2801                            finally {
2802                                    closeSession(session);
2803                            }
2804                    }
2805    
2806                    return count.intValue();
2807            }
2808    
2809            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2810            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2811                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2812                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
2813                            new String[] {
2814                                    Long.class.getName(), Long.class.getName(),
2815                                    
2816                            Integer.class.getName(), Integer.class.getName(),
2817                                    OrderByComparator.class.getName()
2818                            });
2819            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2820                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2821                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
2822                            new String[] { Long.class.getName(), Long.class.getName() },
2823                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2824                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
2825                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2826                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2827            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2828                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2829                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
2830                            new String[] { Long.class.getName(), Long.class.getName() });
2831    
2832            /**
2833             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
2834             *
2835             * @param companyId the company ID
2836             * @param userId the user ID
2837             * @return the matching blogs entries
2838             * @throws SystemException if a system exception occurred
2839             */
2840            @Override
2841            public List<BlogsEntry> findByC_U(long companyId, long userId)
2842                    throws SystemException {
2843                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
2844                            QueryUtil.ALL_POS, null);
2845            }
2846    
2847            /**
2848             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
2849             *
2850             * <p>
2851             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
2852             * </p>
2853             *
2854             * @param companyId the company ID
2855             * @param userId the user ID
2856             * @param start the lower bound of the range of blogs entries
2857             * @param end the upper bound of the range of blogs entries (not inclusive)
2858             * @return the range of matching blogs entries
2859             * @throws SystemException if a system exception occurred
2860             */
2861            @Override
2862            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2863                    int end) throws SystemException {
2864                    return findByC_U(companyId, userId, start, end, null);
2865            }
2866    
2867            /**
2868             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
2869             *
2870             * <p>
2871             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
2872             * </p>
2873             *
2874             * @param companyId the company ID
2875             * @param userId the user ID
2876             * @param start the lower bound of the range of blogs entries
2877             * @param end the upper bound of the range of blogs entries (not inclusive)
2878             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2879             * @return the ordered range of matching blogs entries
2880             * @throws SystemException if a system exception occurred
2881             */
2882            @Override
2883            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
2884                    int end, OrderByComparator orderByComparator) throws SystemException {
2885                    boolean pagination = true;
2886                    FinderPath finderPath = null;
2887                    Object[] finderArgs = null;
2888    
2889                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2890                                    (orderByComparator == null)) {
2891                            pagination = false;
2892                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
2893                            finderArgs = new Object[] { companyId, userId };
2894                    }
2895                    else {
2896                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
2897                            finderArgs = new Object[] {
2898                                            companyId, userId,
2899                                            
2900                                            start, end, orderByComparator
2901                                    };
2902                    }
2903    
2904                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2905                                    finderArgs, this);
2906    
2907                    if ((list != null) && !list.isEmpty()) {
2908                            for (BlogsEntry blogsEntry : list) {
2909                                    if ((companyId != blogsEntry.getCompanyId()) ||
2910                                                    (userId != blogsEntry.getUserId())) {
2911                                            list = null;
2912    
2913                                            break;
2914                                    }
2915                            }
2916                    }
2917    
2918                    if (list == null) {
2919                            StringBundler query = null;
2920    
2921                            if (orderByComparator != null) {
2922                                    query = new StringBundler(4 +
2923                                                    (orderByComparator.getOrderByFields().length * 3));
2924                            }
2925                            else {
2926                                    query = new StringBundler(4);
2927                            }
2928    
2929                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2930    
2931                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2932    
2933                            query.append(_FINDER_COLUMN_C_U_USERID_2);
2934    
2935                            if (orderByComparator != null) {
2936                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2937                                            orderByComparator);
2938                            }
2939                            else
2940                             if (pagination) {
2941                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2942                            }
2943    
2944                            String sql = query.toString();
2945    
2946                            Session session = null;
2947    
2948                            try {
2949                                    session = openSession();
2950    
2951                                    Query q = session.createQuery(sql);
2952    
2953                                    QueryPos qPos = QueryPos.getInstance(q);
2954    
2955                                    qPos.add(companyId);
2956    
2957                                    qPos.add(userId);
2958    
2959                                    if (!pagination) {
2960                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2961                                                            start, end, false);
2962    
2963                                            Collections.sort(list);
2964    
2965                                            list = new UnmodifiableList<BlogsEntry>(list);
2966                                    }
2967                                    else {
2968                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2969                                                            start, end);
2970                                    }
2971    
2972                                    cacheResult(list);
2973    
2974                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2975                            }
2976                            catch (Exception e) {
2977                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2978    
2979                                    throw processException(e);
2980                            }
2981                            finally {
2982                                    closeSession(session);
2983                            }
2984                    }
2985    
2986                    return list;
2987            }
2988    
2989            /**
2990             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
2991             *
2992             * @param companyId the company ID
2993             * @param userId the user ID
2994             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2995             * @return the first matching blogs entry
2996             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2997             * @throws SystemException if a system exception occurred
2998             */
2999            @Override
3000            public BlogsEntry findByC_U_First(long companyId, long userId,
3001                    OrderByComparator orderByComparator)
3002                    throws NoSuchEntryException, SystemException {
3003                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
3004                                    orderByComparator);
3005    
3006                    if (blogsEntry != null) {
3007                            return blogsEntry;
3008                    }
3009    
3010                    StringBundler msg = new StringBundler(6);
3011    
3012                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3013    
3014                    msg.append("companyId=");
3015                    msg.append(companyId);
3016    
3017                    msg.append(", userId=");
3018                    msg.append(userId);
3019    
3020                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3021    
3022                    throw new NoSuchEntryException(msg.toString());
3023            }
3024    
3025            /**
3026             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3027             *
3028             * @param companyId the company ID
3029             * @param userId the user ID
3030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3031             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3032             * @throws SystemException if a system exception occurred
3033             */
3034            @Override
3035            public BlogsEntry fetchByC_U_First(long companyId, long userId,
3036                    OrderByComparator orderByComparator) throws SystemException {
3037                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
3038                                    orderByComparator);
3039    
3040                    if (!list.isEmpty()) {
3041                            return list.get(0);
3042                    }
3043    
3044                    return null;
3045            }
3046    
3047            /**
3048             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3049             *
3050             * @param companyId the company ID
3051             * @param userId the user ID
3052             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3053             * @return the last matching blogs entry
3054             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3055             * @throws SystemException if a system exception occurred
3056             */
3057            @Override
3058            public BlogsEntry findByC_U_Last(long companyId, long userId,
3059                    OrderByComparator orderByComparator)
3060                    throws NoSuchEntryException, SystemException {
3061                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
3062                                    orderByComparator);
3063    
3064                    if (blogsEntry != null) {
3065                            return blogsEntry;
3066                    }
3067    
3068                    StringBundler msg = new StringBundler(6);
3069    
3070                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3071    
3072                    msg.append("companyId=");
3073                    msg.append(companyId);
3074    
3075                    msg.append(", userId=");
3076                    msg.append(userId);
3077    
3078                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3079    
3080                    throw new NoSuchEntryException(msg.toString());
3081            }
3082    
3083            /**
3084             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3085             *
3086             * @param companyId the company ID
3087             * @param userId the user ID
3088             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3089             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3090             * @throws SystemException if a system exception occurred
3091             */
3092            @Override
3093            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
3094                    OrderByComparator orderByComparator) throws SystemException {
3095                    int count = countByC_U(companyId, userId);
3096    
3097                    if (count == 0) {
3098                            return null;
3099                    }
3100    
3101                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
3102                                    orderByComparator);
3103    
3104                    if (!list.isEmpty()) {
3105                            return list.get(0);
3106                    }
3107    
3108                    return null;
3109            }
3110    
3111            /**
3112             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
3113             *
3114             * @param entryId the primary key of the current blogs entry
3115             * @param companyId the company ID
3116             * @param userId the user ID
3117             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3118             * @return the previous, current, and next blogs entry
3119             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3120             * @throws SystemException if a system exception occurred
3121             */
3122            @Override
3123            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
3124                    long userId, OrderByComparator orderByComparator)
3125                    throws NoSuchEntryException, SystemException {
3126                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3127    
3128                    Session session = null;
3129    
3130                    try {
3131                            session = openSession();
3132    
3133                            BlogsEntry[] array = new BlogsEntryImpl[3];
3134    
3135                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3136                                            userId, orderByComparator, true);
3137    
3138                            array[1] = blogsEntry;
3139    
3140                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
3141                                            userId, orderByComparator, false);
3142    
3143                            return array;
3144                    }
3145                    catch (Exception e) {
3146                            throw processException(e);
3147                    }
3148                    finally {
3149                            closeSession(session);
3150                    }
3151            }
3152    
3153            protected BlogsEntry getByC_U_PrevAndNext(Session session,
3154                    BlogsEntry blogsEntry, long companyId, long userId,
3155                    OrderByComparator orderByComparator, boolean previous) {
3156                    StringBundler query = null;
3157    
3158                    if (orderByComparator != null) {
3159                            query = new StringBundler(6 +
3160                                            (orderByComparator.getOrderByFields().length * 6));
3161                    }
3162                    else {
3163                            query = new StringBundler(3);
3164                    }
3165    
3166                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3167    
3168                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3169    
3170                    query.append(_FINDER_COLUMN_C_U_USERID_2);
3171    
3172                    if (orderByComparator != null) {
3173                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3174    
3175                            if (orderByConditionFields.length > 0) {
3176                                    query.append(WHERE_AND);
3177                            }
3178    
3179                            for (int i = 0; i < orderByConditionFields.length; i++) {
3180                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3181                                    query.append(orderByConditionFields[i]);
3182    
3183                                    if ((i + 1) < orderByConditionFields.length) {
3184                                            if (orderByComparator.isAscending() ^ previous) {
3185                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3186                                            }
3187                                            else {
3188                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3189                                            }
3190                                    }
3191                                    else {
3192                                            if (orderByComparator.isAscending() ^ previous) {
3193                                                    query.append(WHERE_GREATER_THAN);
3194                                            }
3195                                            else {
3196                                                    query.append(WHERE_LESSER_THAN);
3197                                            }
3198                                    }
3199                            }
3200    
3201                            query.append(ORDER_BY_CLAUSE);
3202    
3203                            String[] orderByFields = orderByComparator.getOrderByFields();
3204    
3205                            for (int i = 0; i < orderByFields.length; i++) {
3206                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3207                                    query.append(orderByFields[i]);
3208    
3209                                    if ((i + 1) < orderByFields.length) {
3210                                            if (orderByComparator.isAscending() ^ previous) {
3211                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3212                                            }
3213                                            else {
3214                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3215                                            }
3216                                    }
3217                                    else {
3218                                            if (orderByComparator.isAscending() ^ previous) {
3219                                                    query.append(ORDER_BY_ASC);
3220                                            }
3221                                            else {
3222                                                    query.append(ORDER_BY_DESC);
3223                                            }
3224                                    }
3225                            }
3226                    }
3227                    else {
3228                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3229                    }
3230    
3231                    String sql = query.toString();
3232    
3233                    Query q = session.createQuery(sql);
3234    
3235                    q.setFirstResult(0);
3236                    q.setMaxResults(2);
3237    
3238                    QueryPos qPos = QueryPos.getInstance(q);
3239    
3240                    qPos.add(companyId);
3241    
3242                    qPos.add(userId);
3243    
3244                    if (orderByComparator != null) {
3245                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3246    
3247                            for (Object value : values) {
3248                                    qPos.add(value);
3249                            }
3250                    }
3251    
3252                    List<BlogsEntry> list = q.list();
3253    
3254                    if (list.size() == 2) {
3255                            return list.get(1);
3256                    }
3257                    else {
3258                            return null;
3259                    }
3260            }
3261    
3262            /**
3263             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
3264             *
3265             * @param companyId the company ID
3266             * @param userId the user ID
3267             * @throws SystemException if a system exception occurred
3268             */
3269            @Override
3270            public void removeByC_U(long companyId, long userId)
3271                    throws SystemException {
3272                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
3273                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3274                            remove(blogsEntry);
3275                    }
3276            }
3277    
3278            /**
3279             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
3280             *
3281             * @param companyId the company ID
3282             * @param userId the user ID
3283             * @return the number of matching blogs entries
3284             * @throws SystemException if a system exception occurred
3285             */
3286            @Override
3287            public int countByC_U(long companyId, long userId)
3288                    throws SystemException {
3289                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
3290    
3291                    Object[] finderArgs = new Object[] { companyId, userId };
3292    
3293                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3294                                    this);
3295    
3296                    if (count == null) {
3297                            StringBundler query = new StringBundler(3);
3298    
3299                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3300    
3301                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3302    
3303                            query.append(_FINDER_COLUMN_C_U_USERID_2);
3304    
3305                            String sql = query.toString();
3306    
3307                            Session session = null;
3308    
3309                            try {
3310                                    session = openSession();
3311    
3312                                    Query q = session.createQuery(sql);
3313    
3314                                    QueryPos qPos = QueryPos.getInstance(q);
3315    
3316                                    qPos.add(companyId);
3317    
3318                                    qPos.add(userId);
3319    
3320                                    count = (Long)q.uniqueResult();
3321    
3322                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3323                            }
3324                            catch (Exception e) {
3325                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3326    
3327                                    throw processException(e);
3328                            }
3329                            finally {
3330                                    closeSession(session);
3331                            }
3332                    }
3333    
3334                    return count.intValue();
3335            }
3336    
3337            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
3338            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
3339            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3340                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3341                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
3342                            new String[] {
3343                                    Long.class.getName(), Date.class.getName(),
3344                                    
3345                            Integer.class.getName(), Integer.class.getName(),
3346                                    OrderByComparator.class.getName()
3347                            });
3348            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3349                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3350                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
3351                            new String[] { Long.class.getName(), Date.class.getName() });
3352    
3353            /**
3354             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3355             *
3356             * @param companyId the company ID
3357             * @param displayDate the display date
3358             * @return the matching blogs entries
3359             * @throws SystemException if a system exception occurred
3360             */
3361            @Override
3362            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate)
3363                    throws SystemException {
3364                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
3365                            QueryUtil.ALL_POS, null);
3366            }
3367    
3368            /**
3369             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3370             *
3371             * <p>
3372             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3373             * </p>
3374             *
3375             * @param companyId the company ID
3376             * @param displayDate the display date
3377             * @param start the lower bound of the range of blogs entries
3378             * @param end the upper bound of the range of blogs entries (not inclusive)
3379             * @return the range of matching blogs entries
3380             * @throws SystemException if a system exception occurred
3381             */
3382            @Override
3383            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3384                    int start, int end) throws SystemException {
3385                    return findByC_LtD(companyId, displayDate, start, end, null);
3386            }
3387    
3388            /**
3389             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3390             *
3391             * <p>
3392             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3393             * </p>
3394             *
3395             * @param companyId the company ID
3396             * @param displayDate the display date
3397             * @param start the lower bound of the range of blogs entries
3398             * @param end the upper bound of the range of blogs entries (not inclusive)
3399             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3400             * @return the ordered range of matching blogs entries
3401             * @throws SystemException if a system exception occurred
3402             */
3403            @Override
3404            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
3405                    int start, int end, OrderByComparator orderByComparator)
3406                    throws SystemException {
3407                    boolean pagination = true;
3408                    FinderPath finderPath = null;
3409                    Object[] finderArgs = null;
3410    
3411                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
3412                    finderArgs = new Object[] {
3413                                    companyId, displayDate,
3414                                    
3415                                    start, end, orderByComparator
3416                            };
3417    
3418                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3419                                    finderArgs, this);
3420    
3421                    if ((list != null) && !list.isEmpty()) {
3422                            for (BlogsEntry blogsEntry : list) {
3423                                    if ((companyId != blogsEntry.getCompanyId()) ||
3424                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
3425                                                                                                                                    .getTime())) {
3426                                            list = null;
3427    
3428                                            break;
3429                                    }
3430                            }
3431                    }
3432    
3433                    if (list == null) {
3434                            StringBundler query = null;
3435    
3436                            if (orderByComparator != null) {
3437                                    query = new StringBundler(4 +
3438                                                    (orderByComparator.getOrderByFields().length * 3));
3439                            }
3440                            else {
3441                                    query = new StringBundler(4);
3442                            }
3443    
3444                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3445    
3446                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3447    
3448                            boolean bindDisplayDate = false;
3449    
3450                            if (displayDate == null) {
3451                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3452                            }
3453                            else {
3454                                    bindDisplayDate = true;
3455    
3456                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3457                            }
3458    
3459                            if (orderByComparator != null) {
3460                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3461                                            orderByComparator);
3462                            }
3463                            else
3464                             if (pagination) {
3465                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3466                            }
3467    
3468                            String sql = query.toString();
3469    
3470                            Session session = null;
3471    
3472                            try {
3473                                    session = openSession();
3474    
3475                                    Query q = session.createQuery(sql);
3476    
3477                                    QueryPos qPos = QueryPos.getInstance(q);
3478    
3479                                    qPos.add(companyId);
3480    
3481                                    if (bindDisplayDate) {
3482                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3483                                    }
3484    
3485                                    if (!pagination) {
3486                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3487                                                            start, end, false);
3488    
3489                                            Collections.sort(list);
3490    
3491                                            list = new UnmodifiableList<BlogsEntry>(list);
3492                                    }
3493                                    else {
3494                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3495                                                            start, end);
3496                                    }
3497    
3498                                    cacheResult(list);
3499    
3500                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3501                            }
3502                            catch (Exception e) {
3503                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3504    
3505                                    throw processException(e);
3506                            }
3507                            finally {
3508                                    closeSession(session);
3509                            }
3510                    }
3511    
3512                    return list;
3513            }
3514    
3515            /**
3516             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3517             *
3518             * @param companyId the company ID
3519             * @param displayDate the display date
3520             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3521             * @return the first matching blogs entry
3522             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3523             * @throws SystemException if a system exception occurred
3524             */
3525            @Override
3526            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
3527                    OrderByComparator orderByComparator)
3528                    throws NoSuchEntryException, SystemException {
3529                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
3530                                    orderByComparator);
3531    
3532                    if (blogsEntry != null) {
3533                            return blogsEntry;
3534                    }
3535    
3536                    StringBundler msg = new StringBundler(6);
3537    
3538                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3539    
3540                    msg.append("companyId=");
3541                    msg.append(companyId);
3542    
3543                    msg.append(", displayDate=");
3544                    msg.append(displayDate);
3545    
3546                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3547    
3548                    throw new NoSuchEntryException(msg.toString());
3549            }
3550    
3551            /**
3552             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3553             *
3554             * @param companyId the company ID
3555             * @param displayDate the display date
3556             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3557             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3558             * @throws SystemException if a system exception occurred
3559             */
3560            @Override
3561            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
3562                    OrderByComparator orderByComparator) throws SystemException {
3563                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
3564                                    orderByComparator);
3565    
3566                    if (!list.isEmpty()) {
3567                            return list.get(0);
3568                    }
3569    
3570                    return null;
3571            }
3572    
3573            /**
3574             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3575             *
3576             * @param companyId the company ID
3577             * @param displayDate the display date
3578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3579             * @return the last matching blogs entry
3580             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3581             * @throws SystemException if a system exception occurred
3582             */
3583            @Override
3584            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
3585                    OrderByComparator orderByComparator)
3586                    throws NoSuchEntryException, SystemException {
3587                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
3588                                    orderByComparator);
3589    
3590                    if (blogsEntry != null) {
3591                            return blogsEntry;
3592                    }
3593    
3594                    StringBundler msg = new StringBundler(6);
3595    
3596                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3597    
3598                    msg.append("companyId=");
3599                    msg.append(companyId);
3600    
3601                    msg.append(", displayDate=");
3602                    msg.append(displayDate);
3603    
3604                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3605    
3606                    throw new NoSuchEntryException(msg.toString());
3607            }
3608    
3609            /**
3610             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3611             *
3612             * @param companyId the company ID
3613             * @param displayDate the display date
3614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3615             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3616             * @throws SystemException if a system exception occurred
3617             */
3618            @Override
3619            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
3620                    OrderByComparator orderByComparator) throws SystemException {
3621                    int count = countByC_LtD(companyId, displayDate);
3622    
3623                    if (count == 0) {
3624                            return null;
3625                    }
3626    
3627                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
3628                                    count, orderByComparator);
3629    
3630                    if (!list.isEmpty()) {
3631                            return list.get(0);
3632                    }
3633    
3634                    return null;
3635            }
3636    
3637            /**
3638             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
3639             *
3640             * @param entryId the primary key of the current blogs entry
3641             * @param companyId the company ID
3642             * @param displayDate the display date
3643             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3644             * @return the previous, current, and next blogs entry
3645             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3646             * @throws SystemException if a system exception occurred
3647             */
3648            @Override
3649            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
3650                    Date displayDate, OrderByComparator orderByComparator)
3651                    throws NoSuchEntryException, SystemException {
3652                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3653    
3654                    Session session = null;
3655    
3656                    try {
3657                            session = openSession();
3658    
3659                            BlogsEntry[] array = new BlogsEntryImpl[3];
3660    
3661                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3662                                            displayDate, orderByComparator, true);
3663    
3664                            array[1] = blogsEntry;
3665    
3666                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
3667                                            displayDate, orderByComparator, false);
3668    
3669                            return array;
3670                    }
3671                    catch (Exception e) {
3672                            throw processException(e);
3673                    }
3674                    finally {
3675                            closeSession(session);
3676                    }
3677            }
3678    
3679            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
3680                    BlogsEntry blogsEntry, long companyId, Date displayDate,
3681                    OrderByComparator orderByComparator, boolean previous) {
3682                    StringBundler query = null;
3683    
3684                    if (orderByComparator != null) {
3685                            query = new StringBundler(6 +
3686                                            (orderByComparator.getOrderByFields().length * 6));
3687                    }
3688                    else {
3689                            query = new StringBundler(3);
3690                    }
3691    
3692                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3693    
3694                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3695    
3696                    boolean bindDisplayDate = false;
3697    
3698                    if (displayDate == null) {
3699                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3700                    }
3701                    else {
3702                            bindDisplayDate = true;
3703    
3704                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3705                    }
3706    
3707                    if (orderByComparator != null) {
3708                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3709    
3710                            if (orderByConditionFields.length > 0) {
3711                                    query.append(WHERE_AND);
3712                            }
3713    
3714                            for (int i = 0; i < orderByConditionFields.length; i++) {
3715                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3716                                    query.append(orderByConditionFields[i]);
3717    
3718                                    if ((i + 1) < orderByConditionFields.length) {
3719                                            if (orderByComparator.isAscending() ^ previous) {
3720                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3721                                            }
3722                                            else {
3723                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3724                                            }
3725                                    }
3726                                    else {
3727                                            if (orderByComparator.isAscending() ^ previous) {
3728                                                    query.append(WHERE_GREATER_THAN);
3729                                            }
3730                                            else {
3731                                                    query.append(WHERE_LESSER_THAN);
3732                                            }
3733                                    }
3734                            }
3735    
3736                            query.append(ORDER_BY_CLAUSE);
3737    
3738                            String[] orderByFields = orderByComparator.getOrderByFields();
3739    
3740                            for (int i = 0; i < orderByFields.length; i++) {
3741                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3742                                    query.append(orderByFields[i]);
3743    
3744                                    if ((i + 1) < orderByFields.length) {
3745                                            if (orderByComparator.isAscending() ^ previous) {
3746                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3747                                            }
3748                                            else {
3749                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3750                                            }
3751                                    }
3752                                    else {
3753                                            if (orderByComparator.isAscending() ^ previous) {
3754                                                    query.append(ORDER_BY_ASC);
3755                                            }
3756                                            else {
3757                                                    query.append(ORDER_BY_DESC);
3758                                            }
3759                                    }
3760                            }
3761                    }
3762                    else {
3763                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3764                    }
3765    
3766                    String sql = query.toString();
3767    
3768                    Query q = session.createQuery(sql);
3769    
3770                    q.setFirstResult(0);
3771                    q.setMaxResults(2);
3772    
3773                    QueryPos qPos = QueryPos.getInstance(q);
3774    
3775                    qPos.add(companyId);
3776    
3777                    if (bindDisplayDate) {
3778                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3779                    }
3780    
3781                    if (orderByComparator != null) {
3782                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3783    
3784                            for (Object value : values) {
3785                                    qPos.add(value);
3786                            }
3787                    }
3788    
3789                    List<BlogsEntry> list = q.list();
3790    
3791                    if (list.size() == 2) {
3792                            return list.get(1);
3793                    }
3794                    else {
3795                            return null;
3796                    }
3797            }
3798    
3799            /**
3800             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
3801             *
3802             * @param companyId the company ID
3803             * @param displayDate the display date
3804             * @throws SystemException if a system exception occurred
3805             */
3806            @Override
3807            public void removeByC_LtD(long companyId, Date displayDate)
3808                    throws SystemException {
3809                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
3810                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3811                            remove(blogsEntry);
3812                    }
3813            }
3814    
3815            /**
3816             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
3817             *
3818             * @param companyId the company ID
3819             * @param displayDate the display date
3820             * @return the number of matching blogs entries
3821             * @throws SystemException if a system exception occurred
3822             */
3823            @Override
3824            public int countByC_LtD(long companyId, Date displayDate)
3825                    throws SystemException {
3826                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
3827    
3828                    Object[] finderArgs = new Object[] { companyId, displayDate };
3829    
3830                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3831                                    this);
3832    
3833                    if (count == null) {
3834                            StringBundler query = new StringBundler(3);
3835    
3836                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3837    
3838                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
3839    
3840                            boolean bindDisplayDate = false;
3841    
3842                            if (displayDate == null) {
3843                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
3844                            }
3845                            else {
3846                                    bindDisplayDate = true;
3847    
3848                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
3849                            }
3850    
3851                            String sql = query.toString();
3852    
3853                            Session session = null;
3854    
3855                            try {
3856                                    session = openSession();
3857    
3858                                    Query q = session.createQuery(sql);
3859    
3860                                    QueryPos qPos = QueryPos.getInstance(q);
3861    
3862                                    qPos.add(companyId);
3863    
3864                                    if (bindDisplayDate) {
3865                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
3866                                    }
3867    
3868                                    count = (Long)q.uniqueResult();
3869    
3870                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3871                            }
3872                            catch (Exception e) {
3873                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3874    
3875                                    throw processException(e);
3876                            }
3877                            finally {
3878                                    closeSession(session);
3879                            }
3880                    }
3881    
3882                    return count.intValue();
3883            }
3884    
3885            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
3886            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
3887            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
3888            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3889                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3890                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
3891                            new String[] {
3892                                    Long.class.getName(), Integer.class.getName(),
3893                                    
3894                            Integer.class.getName(), Integer.class.getName(),
3895                                    OrderByComparator.class.getName()
3896                            });
3897            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3898                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3899                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
3900                            new String[] { Long.class.getName(), Integer.class.getName() });
3901    
3902            /**
3903             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
3904             *
3905             * @param companyId the company ID
3906             * @param status the status
3907             * @return the matching blogs entries
3908             * @throws SystemException if a system exception occurred
3909             */
3910            @Override
3911            public List<BlogsEntry> findByC_NotS(long companyId, int status)
3912                    throws SystemException {
3913                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
3914                            QueryUtil.ALL_POS, null);
3915            }
3916    
3917            /**
3918             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
3919             *
3920             * <p>
3921             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3922             * </p>
3923             *
3924             * @param companyId the company ID
3925             * @param status the status
3926             * @param start the lower bound of the range of blogs entries
3927             * @param end the upper bound of the range of blogs entries (not inclusive)
3928             * @return the range of matching blogs entries
3929             * @throws SystemException if a system exception occurred
3930             */
3931            @Override
3932            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
3933                    int end) throws SystemException {
3934                    return findByC_NotS(companyId, status, start, end, null);
3935            }
3936    
3937            /**
3938             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
3939             *
3940             * <p>
3941             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3942             * </p>
3943             *
3944             * @param companyId the company ID
3945             * @param status the status
3946             * @param start the lower bound of the range of blogs entries
3947             * @param end the upper bound of the range of blogs entries (not inclusive)
3948             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3949             * @return the ordered range of matching blogs entries
3950             * @throws SystemException if a system exception occurred
3951             */
3952            @Override
3953            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
3954                    int end, OrderByComparator orderByComparator) throws SystemException {
3955                    boolean pagination = true;
3956                    FinderPath finderPath = null;
3957                    Object[] finderArgs = null;
3958    
3959                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
3960                    finderArgs = new Object[] {
3961                                    companyId, status,
3962                                    
3963                                    start, end, orderByComparator
3964                            };
3965    
3966                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3967                                    finderArgs, this);
3968    
3969                    if ((list != null) && !list.isEmpty()) {
3970                            for (BlogsEntry blogsEntry : list) {
3971                                    if ((companyId != blogsEntry.getCompanyId()) ||
3972                                                    (status == blogsEntry.getStatus())) {
3973                                            list = null;
3974    
3975                                            break;
3976                                    }
3977                            }
3978                    }
3979    
3980                    if (list == null) {
3981                            StringBundler query = null;
3982    
3983                            if (orderByComparator != null) {
3984                                    query = new StringBundler(4 +
3985                                                    (orderByComparator.getOrderByFields().length * 3));
3986                            }
3987                            else {
3988                                    query = new StringBundler(4);
3989                            }
3990    
3991                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3992    
3993                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
3994    
3995                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
3996    
3997                            if (orderByComparator != null) {
3998                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3999                                            orderByComparator);
4000                            }
4001                            else
4002                             if (pagination) {
4003                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4004                            }
4005    
4006                            String sql = query.toString();
4007    
4008                            Session session = null;
4009    
4010                            try {
4011                                    session = openSession();
4012    
4013                                    Query q = session.createQuery(sql);
4014    
4015                                    QueryPos qPos = QueryPos.getInstance(q);
4016    
4017                                    qPos.add(companyId);
4018    
4019                                    qPos.add(status);
4020    
4021                                    if (!pagination) {
4022                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4023                                                            start, end, false);
4024    
4025                                            Collections.sort(list);
4026    
4027                                            list = new UnmodifiableList<BlogsEntry>(list);
4028                                    }
4029                                    else {
4030                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4031                                                            start, end);
4032                                    }
4033    
4034                                    cacheResult(list);
4035    
4036                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4037                            }
4038                            catch (Exception e) {
4039                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4040    
4041                                    throw processException(e);
4042                            }
4043                            finally {
4044                                    closeSession(session);
4045                            }
4046                    }
4047    
4048                    return list;
4049            }
4050    
4051            /**
4052             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4053             *
4054             * @param companyId the company ID
4055             * @param status the status
4056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4057             * @return the first matching blogs entry
4058             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4059             * @throws SystemException if a system exception occurred
4060             */
4061            @Override
4062            public BlogsEntry findByC_NotS_First(long companyId, int status,
4063                    OrderByComparator orderByComparator)
4064                    throws NoSuchEntryException, SystemException {
4065                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
4066                                    orderByComparator);
4067    
4068                    if (blogsEntry != null) {
4069                            return blogsEntry;
4070                    }
4071    
4072                    StringBundler msg = new StringBundler(6);
4073    
4074                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4075    
4076                    msg.append("companyId=");
4077                    msg.append(companyId);
4078    
4079                    msg.append(", status=");
4080                    msg.append(status);
4081    
4082                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4083    
4084                    throw new NoSuchEntryException(msg.toString());
4085            }
4086    
4087            /**
4088             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4089             *
4090             * @param companyId the company ID
4091             * @param status the status
4092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4093             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4094             * @throws SystemException if a system exception occurred
4095             */
4096            @Override
4097            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
4098                    OrderByComparator orderByComparator) throws SystemException {
4099                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
4100                                    orderByComparator);
4101    
4102                    if (!list.isEmpty()) {
4103                            return list.get(0);
4104                    }
4105    
4106                    return null;
4107            }
4108    
4109            /**
4110             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4111             *
4112             * @param companyId the company ID
4113             * @param status the status
4114             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4115             * @return the last matching blogs entry
4116             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4117             * @throws SystemException if a system exception occurred
4118             */
4119            @Override
4120            public BlogsEntry findByC_NotS_Last(long companyId, int status,
4121                    OrderByComparator orderByComparator)
4122                    throws NoSuchEntryException, SystemException {
4123                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
4124                                    orderByComparator);
4125    
4126                    if (blogsEntry != null) {
4127                            return blogsEntry;
4128                    }
4129    
4130                    StringBundler msg = new StringBundler(6);
4131    
4132                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4133    
4134                    msg.append("companyId=");
4135                    msg.append(companyId);
4136    
4137                    msg.append(", status=");
4138                    msg.append(status);
4139    
4140                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4141    
4142                    throw new NoSuchEntryException(msg.toString());
4143            }
4144    
4145            /**
4146             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4147             *
4148             * @param companyId the company ID
4149             * @param status the status
4150             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4151             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4152             * @throws SystemException if a system exception occurred
4153             */
4154            @Override
4155            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
4156                    OrderByComparator orderByComparator) throws SystemException {
4157                    int count = countByC_NotS(companyId, status);
4158    
4159                    if (count == 0) {
4160                            return null;
4161                    }
4162    
4163                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
4164                                    count, orderByComparator);
4165    
4166                    if (!list.isEmpty()) {
4167                            return list.get(0);
4168                    }
4169    
4170                    return null;
4171            }
4172    
4173            /**
4174             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
4175             *
4176             * @param entryId the primary key of the current blogs entry
4177             * @param companyId the company ID
4178             * @param status the status
4179             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4180             * @return the previous, current, and next blogs entry
4181             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4182             * @throws SystemException if a system exception occurred
4183             */
4184            @Override
4185            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
4186                    int status, OrderByComparator orderByComparator)
4187                    throws NoSuchEntryException, SystemException {
4188                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4189    
4190                    Session session = null;
4191    
4192                    try {
4193                            session = openSession();
4194    
4195                            BlogsEntry[] array = new BlogsEntryImpl[3];
4196    
4197                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
4198                                            status, orderByComparator, true);
4199    
4200                            array[1] = blogsEntry;
4201    
4202                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
4203                                            status, orderByComparator, false);
4204    
4205                            return array;
4206                    }
4207                    catch (Exception e) {
4208                            throw processException(e);
4209                    }
4210                    finally {
4211                            closeSession(session);
4212                    }
4213            }
4214    
4215            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
4216                    BlogsEntry blogsEntry, long companyId, int status,
4217                    OrderByComparator orderByComparator, boolean previous) {
4218                    StringBundler query = null;
4219    
4220                    if (orderByComparator != null) {
4221                            query = new StringBundler(6 +
4222                                            (orderByComparator.getOrderByFields().length * 6));
4223                    }
4224                    else {
4225                            query = new StringBundler(3);
4226                    }
4227    
4228                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4229    
4230                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4231    
4232                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4233    
4234                    if (orderByComparator != null) {
4235                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4236    
4237                            if (orderByConditionFields.length > 0) {
4238                                    query.append(WHERE_AND);
4239                            }
4240    
4241                            for (int i = 0; i < orderByConditionFields.length; i++) {
4242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4243                                    query.append(orderByConditionFields[i]);
4244    
4245                                    if ((i + 1) < orderByConditionFields.length) {
4246                                            if (orderByComparator.isAscending() ^ previous) {
4247                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4248                                            }
4249                                            else {
4250                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4251                                            }
4252                                    }
4253                                    else {
4254                                            if (orderByComparator.isAscending() ^ previous) {
4255                                                    query.append(WHERE_GREATER_THAN);
4256                                            }
4257                                            else {
4258                                                    query.append(WHERE_LESSER_THAN);
4259                                            }
4260                                    }
4261                            }
4262    
4263                            query.append(ORDER_BY_CLAUSE);
4264    
4265                            String[] orderByFields = orderByComparator.getOrderByFields();
4266    
4267                            for (int i = 0; i < orderByFields.length; i++) {
4268                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4269                                    query.append(orderByFields[i]);
4270    
4271                                    if ((i + 1) < orderByFields.length) {
4272                                            if (orderByComparator.isAscending() ^ previous) {
4273                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4274                                            }
4275                                            else {
4276                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4277                                            }
4278                                    }
4279                                    else {
4280                                            if (orderByComparator.isAscending() ^ previous) {
4281                                                    query.append(ORDER_BY_ASC);
4282                                            }
4283                                            else {
4284                                                    query.append(ORDER_BY_DESC);
4285                                            }
4286                                    }
4287                            }
4288                    }
4289                    else {
4290                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4291                    }
4292    
4293                    String sql = query.toString();
4294    
4295                    Query q = session.createQuery(sql);
4296    
4297                    q.setFirstResult(0);
4298                    q.setMaxResults(2);
4299    
4300                    QueryPos qPos = QueryPos.getInstance(q);
4301    
4302                    qPos.add(companyId);
4303    
4304                    qPos.add(status);
4305    
4306                    if (orderByComparator != null) {
4307                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4308    
4309                            for (Object value : values) {
4310                                    qPos.add(value);
4311                            }
4312                    }
4313    
4314                    List<BlogsEntry> list = q.list();
4315    
4316                    if (list.size() == 2) {
4317                            return list.get(1);
4318                    }
4319                    else {
4320                            return null;
4321                    }
4322            }
4323    
4324            /**
4325             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
4326             *
4327             * @param companyId the company ID
4328             * @param status the status
4329             * @throws SystemException if a system exception occurred
4330             */
4331            @Override
4332            public void removeByC_NotS(long companyId, int status)
4333                    throws SystemException {
4334                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
4335                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4336                            remove(blogsEntry);
4337                    }
4338            }
4339    
4340            /**
4341             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
4342             *
4343             * @param companyId the company ID
4344             * @param status the status
4345             * @return the number of matching blogs entries
4346             * @throws SystemException if a system exception occurred
4347             */
4348            @Override
4349            public int countByC_NotS(long companyId, int status)
4350                    throws SystemException {
4351                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
4352    
4353                    Object[] finderArgs = new Object[] { companyId, status };
4354    
4355                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4356                                    this);
4357    
4358                    if (count == null) {
4359                            StringBundler query = new StringBundler(3);
4360    
4361                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4362    
4363                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
4364    
4365                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
4366    
4367                            String sql = query.toString();
4368    
4369                            Session session = null;
4370    
4371                            try {
4372                                    session = openSession();
4373    
4374                                    Query q = session.createQuery(sql);
4375    
4376                                    QueryPos qPos = QueryPos.getInstance(q);
4377    
4378                                    qPos.add(companyId);
4379    
4380                                    qPos.add(status);
4381    
4382                                    count = (Long)q.uniqueResult();
4383    
4384                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4385                            }
4386                            catch (Exception e) {
4387                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4388    
4389                                    throw processException(e);
4390                            }
4391                            finally {
4392                                    closeSession(session);
4393                            }
4394                    }
4395    
4396                    return count.intValue();
4397            }
4398    
4399            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
4400            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
4401            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4402                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4403                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
4404                            new String[] {
4405                                    Long.class.getName(), Integer.class.getName(),
4406                                    
4407                            Integer.class.getName(), Integer.class.getName(),
4408                                    OrderByComparator.class.getName()
4409                            });
4410            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4411                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4412                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
4413                            new String[] { Long.class.getName(), Integer.class.getName() },
4414                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
4415                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4416                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4417                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4418            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4419                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4420                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
4421                            new String[] { Long.class.getName(), Integer.class.getName() });
4422    
4423            /**
4424             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
4425             *
4426             * @param companyId the company ID
4427             * @param status the status
4428             * @return the matching blogs entries
4429             * @throws SystemException if a system exception occurred
4430             */
4431            @Override
4432            public List<BlogsEntry> findByC_S(long companyId, int status)
4433                    throws SystemException {
4434                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
4435                            QueryUtil.ALL_POS, null);
4436            }
4437    
4438            /**
4439             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
4440             *
4441             * <p>
4442             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
4443             * </p>
4444             *
4445             * @param companyId the company ID
4446             * @param status the status
4447             * @param start the lower bound of the range of blogs entries
4448             * @param end the upper bound of the range of blogs entries (not inclusive)
4449             * @return the range of matching blogs entries
4450             * @throws SystemException if a system exception occurred
4451             */
4452            @Override
4453            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4454                    int end) throws SystemException {
4455                    return findByC_S(companyId, status, start, end, null);
4456            }
4457    
4458            /**
4459             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
4460             *
4461             * <p>
4462             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.
4463             * </p>
4464             *
4465             * @param companyId the company ID
4466             * @param status the status
4467             * @param start the lower bound of the range of blogs entries
4468             * @param end the upper bound of the range of blogs entries (not inclusive)
4469             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4470             * @return the ordered range of matching blogs entries
4471             * @throws SystemException if a system exception occurred
4472             */
4473            @Override
4474            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
4475                    int end, OrderByComparator orderByComparator) throws SystemException {
4476                    boolean pagination = true;
4477                    FinderPath finderPath = null;
4478                    Object[] finderArgs = null;
4479    
4480                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4481                                    (orderByComparator == null)) {
4482                            pagination = false;
4483                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
4484                            finderArgs = new Object[] { companyId, status };
4485                    }
4486                    else {
4487                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
4488                            finderArgs = new Object[] {
4489                                            companyId, status,
4490                                            
4491                                            start, end, orderByComparator
4492                                    };
4493                    }
4494    
4495                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4496                                    finderArgs, this);
4497    
4498                    if ((list != null) && !list.isEmpty()) {
4499                            for (BlogsEntry blogsEntry : list) {
4500                                    if ((companyId != blogsEntry.getCompanyId()) ||
4501                                                    (status != blogsEntry.getStatus())) {
4502                                            list = null;
4503    
4504                                            break;
4505                                    }
4506                            }
4507                    }
4508    
4509                    if (list == null) {
4510                            StringBundler query = null;
4511    
4512                            if (orderByComparator != null) {
4513                                    query = new StringBundler(4 +
4514                                                    (orderByComparator.getOrderByFields().length * 3));
4515                            }
4516                            else {
4517                                    query = new StringBundler(4);
4518                            }
4519    
4520                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4521    
4522                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4523    
4524                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
4525    
4526                            if (orderByComparator != null) {
4527                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4528                                            orderByComparator);
4529                            }
4530                            else
4531                             if (pagination) {
4532                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4533                            }
4534    
4535                            String sql = query.toString();
4536    
4537                            Session session = null;
4538    
4539                            try {
4540                                    session = openSession();
4541    
4542                                    Query q = session.createQuery(sql);
4543    
4544                                    QueryPos qPos = QueryPos.getInstance(q);
4545    
4546                                    qPos.add(companyId);
4547    
4548                                    qPos.add(status);
4549    
4550                                    if (!pagination) {
4551                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4552                                                            start, end, false);
4553    
4554                                            Collections.sort(list);
4555    
4556                                            list = new UnmodifiableList<BlogsEntry>(list);
4557                                    }
4558                                    else {
4559                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4560                                                            start, end);
4561                                    }
4562    
4563                                    cacheResult(list);
4564    
4565                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4566                            }
4567                            catch (Exception e) {
4568                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4569    
4570                                    throw processException(e);
4571                            }
4572                            finally {
4573                                    closeSession(session);
4574                            }
4575                    }
4576    
4577                    return list;
4578            }
4579    
4580            /**
4581             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4582             *
4583             * @param companyId the company ID
4584             * @param status the status
4585             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4586             * @return the first matching blogs entry
4587             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4588             * @throws SystemException if a system exception occurred
4589             */
4590            @Override
4591            public BlogsEntry findByC_S_First(long companyId, int status,
4592                    OrderByComparator orderByComparator)
4593                    throws NoSuchEntryException, SystemException {
4594                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
4595                                    orderByComparator);
4596    
4597                    if (blogsEntry != null) {
4598                            return blogsEntry;
4599                    }
4600    
4601                    StringBundler msg = new StringBundler(6);
4602    
4603                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4604    
4605                    msg.append("companyId=");
4606                    msg.append(companyId);
4607    
4608                    msg.append(", status=");
4609                    msg.append(status);
4610    
4611                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4612    
4613                    throw new NoSuchEntryException(msg.toString());
4614            }
4615    
4616            /**
4617             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4618             *
4619             * @param companyId the company ID
4620             * @param status the status
4621             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4622             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4623             * @throws SystemException if a system exception occurred
4624             */
4625            @Override
4626            public BlogsEntry fetchByC_S_First(long companyId, int status,
4627                    OrderByComparator orderByComparator) throws SystemException {
4628                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
4629                                    orderByComparator);
4630    
4631                    if (!list.isEmpty()) {
4632                            return list.get(0);
4633                    }
4634    
4635                    return null;
4636            }
4637    
4638            /**
4639             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4640             *
4641             * @param companyId the company ID
4642             * @param status the status
4643             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4644             * @return the last matching blogs entry
4645             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4646             * @throws SystemException if a system exception occurred
4647             */
4648            @Override
4649            public BlogsEntry findByC_S_Last(long companyId, int status,
4650                    OrderByComparator orderByComparator)
4651                    throws NoSuchEntryException, SystemException {
4652                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
4653                                    orderByComparator);
4654    
4655                    if (blogsEntry != null) {
4656                            return blogsEntry;
4657                    }
4658    
4659                    StringBundler msg = new StringBundler(6);
4660    
4661                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4662    
4663                    msg.append("companyId=");
4664                    msg.append(companyId);
4665    
4666                    msg.append(", status=");
4667                    msg.append(status);
4668    
4669                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4670    
4671                    throw new NoSuchEntryException(msg.toString());
4672            }
4673    
4674            /**
4675             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4676             *
4677             * @param companyId the company ID
4678             * @param status the status
4679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4680             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4681             * @throws SystemException if a system exception occurred
4682             */
4683            @Override
4684            public BlogsEntry fetchByC_S_Last(long companyId, int status,
4685                    OrderByComparator orderByComparator) throws SystemException {
4686                    int count = countByC_S(companyId, status);
4687    
4688                    if (count == 0) {
4689                            return null;
4690                    }
4691    
4692                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
4693                                    orderByComparator);
4694    
4695                    if (!list.isEmpty()) {
4696                            return list.get(0);
4697                    }
4698    
4699                    return null;
4700            }
4701    
4702            /**
4703             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
4704             *
4705             * @param entryId the primary key of the current blogs entry
4706             * @param companyId the company ID
4707             * @param status the status
4708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4709             * @return the previous, current, and next blogs entry
4710             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4711             * @throws SystemException if a system exception occurred
4712             */
4713            @Override
4714            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
4715                    int status, OrderByComparator orderByComparator)
4716                    throws NoSuchEntryException, SystemException {
4717                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4718    
4719                    Session session = null;
4720    
4721                    try {
4722                            session = openSession();
4723    
4724                            BlogsEntry[] array = new BlogsEntryImpl[3];
4725    
4726                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4727                                            status, orderByComparator, true);
4728    
4729                            array[1] = blogsEntry;
4730    
4731                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
4732                                            status, orderByComparator, false);
4733    
4734                            return array;
4735                    }
4736                    catch (Exception e) {
4737                            throw processException(e);
4738                    }
4739                    finally {
4740                            closeSession(session);
4741                    }
4742            }
4743    
4744            protected BlogsEntry getByC_S_PrevAndNext(Session session,
4745                    BlogsEntry blogsEntry, long companyId, int status,
4746                    OrderByComparator orderByComparator, boolean previous) {
4747                    StringBundler query = null;
4748    
4749                    if (orderByComparator != null) {
4750                            query = new StringBundler(6 +
4751                                            (orderByComparator.getOrderByFields().length * 6));
4752                    }
4753                    else {
4754                            query = new StringBundler(3);
4755                    }
4756    
4757                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4758    
4759                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4760    
4761                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
4762    
4763                    if (orderByComparator != null) {
4764                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4765    
4766                            if (orderByConditionFields.length > 0) {
4767                                    query.append(WHERE_AND);
4768                            }
4769    
4770                            for (int i = 0; i < orderByConditionFields.length; i++) {
4771                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4772                                    query.append(orderByConditionFields[i]);
4773    
4774                                    if ((i + 1) < orderByConditionFields.length) {
4775                                            if (orderByComparator.isAscending() ^ previous) {
4776                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4777                                            }
4778                                            else {
4779                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4780                                            }
4781                                    }
4782                                    else {
4783                                            if (orderByComparator.isAscending() ^ previous) {
4784                                                    query.append(WHERE_GREATER_THAN);
4785                                            }
4786                                            else {
4787                                                    query.append(WHERE_LESSER_THAN);
4788                                            }
4789                                    }
4790                            }
4791    
4792                            query.append(ORDER_BY_CLAUSE);
4793    
4794                            String[] orderByFields = orderByComparator.getOrderByFields();
4795    
4796                            for (int i = 0; i < orderByFields.length; i++) {
4797                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4798                                    query.append(orderByFields[i]);
4799    
4800                                    if ((i + 1) < orderByFields.length) {
4801                                            if (orderByComparator.isAscending() ^ previous) {
4802                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4803                                            }
4804                                            else {
4805                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4806                                            }
4807                                    }
4808                                    else {
4809                                            if (orderByComparator.isAscending() ^ previous) {
4810                                                    query.append(ORDER_BY_ASC);
4811                                            }
4812                                            else {
4813                                                    query.append(ORDER_BY_DESC);
4814                                            }
4815                                    }
4816                            }
4817                    }
4818                    else {
4819                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4820                    }
4821    
4822                    String sql = query.toString();
4823    
4824                    Query q = session.createQuery(sql);
4825    
4826                    q.setFirstResult(0);
4827                    q.setMaxResults(2);
4828    
4829                    QueryPos qPos = QueryPos.getInstance(q);
4830    
4831                    qPos.add(companyId);
4832    
4833                    qPos.add(status);
4834    
4835                    if (orderByComparator != null) {
4836                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4837    
4838                            for (Object value : values) {
4839                                    qPos.add(value);
4840                            }
4841                    }
4842    
4843                    List<BlogsEntry> list = q.list();
4844    
4845                    if (list.size() == 2) {
4846                            return list.get(1);
4847                    }
4848                    else {
4849                            return null;
4850                    }
4851            }
4852    
4853            /**
4854             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
4855             *
4856             * @param companyId the company ID
4857             * @param status the status
4858             * @throws SystemException if a system exception occurred
4859             */
4860            @Override
4861            public void removeByC_S(long companyId, int status)
4862                    throws SystemException {
4863                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
4864                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4865                            remove(blogsEntry);
4866                    }
4867            }
4868    
4869            /**
4870             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
4871             *
4872             * @param companyId the company ID
4873             * @param status the status
4874             * @return the number of matching blogs entries
4875             * @throws SystemException if a system exception occurred
4876             */
4877            @Override
4878            public int countByC_S(long companyId, int status) throws SystemException {
4879                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
4880    
4881                    Object[] finderArgs = new Object[] { companyId, status };
4882    
4883                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4884                                    this);
4885    
4886                    if (count == null) {
4887                            StringBundler query = new StringBundler(3);
4888    
4889                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4890    
4891                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4892    
4893                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
4894    
4895                            String sql = query.toString();
4896    
4897                            Session session = null;
4898    
4899                            try {
4900                                    session = openSession();
4901    
4902                                    Query q = session.createQuery(sql);
4903    
4904                                    QueryPos qPos = QueryPos.getInstance(q);
4905    
4906                                    qPos.add(companyId);
4907    
4908                                    qPos.add(status);
4909    
4910                                    count = (Long)q.uniqueResult();
4911    
4912                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4913                            }
4914                            catch (Exception e) {
4915                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4916    
4917                                    throw processException(e);
4918                            }
4919                            finally {
4920                                    closeSession(session);
4921                            }
4922                    }
4923    
4924                    return count.intValue();
4925            }
4926    
4927            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
4928            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
4929            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4930                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4931                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
4932                            new String[] { Long.class.getName(), String.class.getName() },
4933                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4934                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
4935            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4936                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4937                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
4938                            new String[] { Long.class.getName(), String.class.getName() });
4939    
4940            /**
4941             * 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.
4942             *
4943             * @param groupId the group ID
4944             * @param urlTitle the url title
4945             * @return the matching blogs entry
4946             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4947             * @throws SystemException if a system exception occurred
4948             */
4949            @Override
4950            public BlogsEntry findByG_UT(long groupId, String urlTitle)
4951                    throws NoSuchEntryException, SystemException {
4952                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
4953    
4954                    if (blogsEntry == null) {
4955                            StringBundler msg = new StringBundler(6);
4956    
4957                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4958    
4959                            msg.append("groupId=");
4960                            msg.append(groupId);
4961    
4962                            msg.append(", urlTitle=");
4963                            msg.append(urlTitle);
4964    
4965                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4966    
4967                            if (_log.isWarnEnabled()) {
4968                                    _log.warn(msg.toString());
4969                            }
4970    
4971                            throw new NoSuchEntryException(msg.toString());
4972                    }
4973    
4974                    return blogsEntry;
4975            }
4976    
4977            /**
4978             * 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.
4979             *
4980             * @param groupId the group ID
4981             * @param urlTitle the url title
4982             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4983             * @throws SystemException if a system exception occurred
4984             */
4985            @Override
4986            public BlogsEntry fetchByG_UT(long groupId, String urlTitle)
4987                    throws SystemException {
4988                    return fetchByG_UT(groupId, urlTitle, true);
4989            }
4990    
4991            /**
4992             * 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.
4993             *
4994             * @param groupId the group ID
4995             * @param urlTitle the url title
4996             * @param retrieveFromCache whether to use the finder cache
4997             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4998             * @throws SystemException if a system exception occurred
4999             */
5000            @Override
5001            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
5002                    boolean retrieveFromCache) throws SystemException {
5003                    Object[] finderArgs = new Object[] { groupId, urlTitle };
5004    
5005                    Object result = null;
5006    
5007                    if (retrieveFromCache) {
5008                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_UT,
5009                                            finderArgs, this);
5010                    }
5011    
5012                    if (result instanceof BlogsEntry) {
5013                            BlogsEntry blogsEntry = (BlogsEntry)result;
5014    
5015                            if ((groupId != blogsEntry.getGroupId()) ||
5016                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
5017                                    result = null;
5018                            }
5019                    }
5020    
5021                    if (result == null) {
5022                            StringBundler query = new StringBundler(4);
5023    
5024                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5025    
5026                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5027    
5028                            boolean bindUrlTitle = false;
5029    
5030                            if (urlTitle == null) {
5031                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5032                            }
5033                            else if (urlTitle.equals(StringPool.BLANK)) {
5034                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5035                            }
5036                            else {
5037                                    bindUrlTitle = true;
5038    
5039                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
5040                            }
5041    
5042                            String sql = query.toString();
5043    
5044                            Session session = null;
5045    
5046                            try {
5047                                    session = openSession();
5048    
5049                                    Query q = session.createQuery(sql);
5050    
5051                                    QueryPos qPos = QueryPos.getInstance(q);
5052    
5053                                    qPos.add(groupId);
5054    
5055                                    if (bindUrlTitle) {
5056                                            qPos.add(urlTitle);
5057                                    }
5058    
5059                                    List<BlogsEntry> list = q.list();
5060    
5061                                    if (list.isEmpty()) {
5062                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
5063                                                    finderArgs, list);
5064                                    }
5065                                    else {
5066                                            BlogsEntry blogsEntry = list.get(0);
5067    
5068                                            result = blogsEntry;
5069    
5070                                            cacheResult(blogsEntry);
5071    
5072                                            if ((blogsEntry.getGroupId() != groupId) ||
5073                                                            (blogsEntry.getUrlTitle() == null) ||
5074                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
5075                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
5076                                                            finderArgs, blogsEntry);
5077                                            }
5078                                    }
5079                            }
5080                            catch (Exception e) {
5081                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
5082                                            finderArgs);
5083    
5084                                    throw processException(e);
5085                            }
5086                            finally {
5087                                    closeSession(session);
5088                            }
5089                    }
5090    
5091                    if (result instanceof List<?>) {
5092                            return null;
5093                    }
5094                    else {
5095                            return (BlogsEntry)result;
5096                    }
5097            }
5098    
5099            /**
5100             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
5101             *
5102             * @param groupId the group ID
5103             * @param urlTitle the url title
5104             * @return the blogs entry that was removed
5105             * @throws SystemException if a system exception occurred
5106             */
5107            @Override
5108            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
5109                    throws NoSuchEntryException, SystemException {
5110                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
5111    
5112                    return remove(blogsEntry);
5113            }
5114    
5115            /**
5116             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
5117             *
5118             * @param groupId the group ID
5119             * @param urlTitle the url title
5120             * @return the number of matching blogs entries
5121             * @throws SystemException if a system exception occurred
5122             */
5123            @Override
5124            public int countByG_UT(long groupId, String urlTitle)
5125                    throws SystemException {
5126                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
5127    
5128                    Object[] finderArgs = new Object[] { groupId, urlTitle };
5129    
5130                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5131                                    this);
5132    
5133                    if (count == null) {
5134                            StringBundler query = new StringBundler(3);
5135    
5136                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5137    
5138                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
5139    
5140                            boolean bindUrlTitle = false;
5141    
5142                            if (urlTitle == null) {
5143                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
5144                            }
5145                            else if (urlTitle.equals(StringPool.BLANK)) {
5146                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
5147                            }
5148                            else {
5149                                    bindUrlTitle = true;
5150    
5151                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
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 (bindUrlTitle) {
5168                                            qPos.add(urlTitle);
5169                                    }
5170    
5171                                    count = (Long)q.uniqueResult();
5172    
5173                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5174                            }
5175                            catch (Exception e) {
5176                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5177    
5178                                    throw processException(e);
5179                            }
5180                            finally {
5181                                    closeSession(session);
5182                            }
5183                    }
5184    
5185                    return count.intValue();
5186            }
5187    
5188            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5189            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
5190            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
5191            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
5192            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5193                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5194                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
5195                            new String[] {
5196                                    Long.class.getName(), Date.class.getName(),
5197                                    
5198                            Integer.class.getName(), Integer.class.getName(),
5199                                    OrderByComparator.class.getName()
5200                            });
5201            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5202                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5203                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
5204                            new String[] { Long.class.getName(), Date.class.getName() });
5205    
5206            /**
5207             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5208             *
5209             * @param groupId the group ID
5210             * @param displayDate the display date
5211             * @return the matching blogs entries
5212             * @throws SystemException if a system exception occurred
5213             */
5214            @Override
5215            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate)
5216                    throws SystemException {
5217                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5218                            QueryUtil.ALL_POS, null);
5219            }
5220    
5221            /**
5222             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5223             *
5224             * <p>
5225             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5226             * </p>
5227             *
5228             * @param groupId the group ID
5229             * @param displayDate the display date
5230             * @param start the lower bound of the range of blogs entries
5231             * @param end the upper bound of the range of blogs entries (not inclusive)
5232             * @return the range of matching blogs entries
5233             * @throws SystemException if a system exception occurred
5234             */
5235            @Override
5236            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5237                    int start, int end) throws SystemException {
5238                    return findByG_LtD(groupId, displayDate, start, end, null);
5239            }
5240    
5241            /**
5242             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
5243             *
5244             * <p>
5245             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5246             * </p>
5247             *
5248             * @param groupId the group ID
5249             * @param displayDate the display date
5250             * @param start the lower bound of the range of blogs entries
5251             * @param end the upper bound of the range of blogs entries (not inclusive)
5252             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5253             * @return the ordered range of matching blogs entries
5254             * @throws SystemException if a system exception occurred
5255             */
5256            @Override
5257            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
5258                    int start, int end, OrderByComparator orderByComparator)
5259                    throws SystemException {
5260                    boolean pagination = true;
5261                    FinderPath finderPath = null;
5262                    Object[] finderArgs = null;
5263    
5264                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
5265                    finderArgs = new Object[] {
5266                                    groupId, displayDate,
5267                                    
5268                                    start, end, orderByComparator
5269                            };
5270    
5271                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5272                                    finderArgs, this);
5273    
5274                    if ((list != null) && !list.isEmpty()) {
5275                            for (BlogsEntry blogsEntry : list) {
5276                                    if ((groupId != blogsEntry.getGroupId()) ||
5277                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
5278                                                                                                                                    .getTime())) {
5279                                            list = null;
5280    
5281                                            break;
5282                                    }
5283                            }
5284                    }
5285    
5286                    if (list == null) {
5287                            StringBundler query = null;
5288    
5289                            if (orderByComparator != null) {
5290                                    query = new StringBundler(4 +
5291                                                    (orderByComparator.getOrderByFields().length * 3));
5292                            }
5293                            else {
5294                                    query = new StringBundler(4);
5295                            }
5296    
5297                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5298    
5299                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5300    
5301                            boolean bindDisplayDate = false;
5302    
5303                            if (displayDate == null) {
5304                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5305                            }
5306                            else {
5307                                    bindDisplayDate = true;
5308    
5309                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5310                            }
5311    
5312                            if (orderByComparator != null) {
5313                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5314                                            orderByComparator);
5315                            }
5316                            else
5317                             if (pagination) {
5318                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5319                            }
5320    
5321                            String sql = query.toString();
5322    
5323                            Session session = null;
5324    
5325                            try {
5326                                    session = openSession();
5327    
5328                                    Query q = session.createQuery(sql);
5329    
5330                                    QueryPos qPos = QueryPos.getInstance(q);
5331    
5332                                    qPos.add(groupId);
5333    
5334                                    if (bindDisplayDate) {
5335                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5336                                    }
5337    
5338                                    if (!pagination) {
5339                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5340                                                            start, end, false);
5341    
5342                                            Collections.sort(list);
5343    
5344                                            list = new UnmodifiableList<BlogsEntry>(list);
5345                                    }
5346                                    else {
5347                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5348                                                            start, end);
5349                                    }
5350    
5351                                    cacheResult(list);
5352    
5353                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5354                            }
5355                            catch (Exception e) {
5356                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5357    
5358                                    throw processException(e);
5359                            }
5360                            finally {
5361                                    closeSession(session);
5362                            }
5363                    }
5364    
5365                    return list;
5366            }
5367    
5368            /**
5369             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5370             *
5371             * @param groupId the group ID
5372             * @param displayDate the display date
5373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5374             * @return the first matching blogs entry
5375             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5376             * @throws SystemException if a system exception occurred
5377             */
5378            @Override
5379            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
5380                    OrderByComparator orderByComparator)
5381                    throws NoSuchEntryException, SystemException {
5382                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
5383                                    orderByComparator);
5384    
5385                    if (blogsEntry != null) {
5386                            return blogsEntry;
5387                    }
5388    
5389                    StringBundler msg = new StringBundler(6);
5390    
5391                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5392    
5393                    msg.append("groupId=");
5394                    msg.append(groupId);
5395    
5396                    msg.append(", displayDate=");
5397                    msg.append(displayDate);
5398    
5399                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5400    
5401                    throw new NoSuchEntryException(msg.toString());
5402            }
5403    
5404            /**
5405             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5406             *
5407             * @param groupId the group ID
5408             * @param displayDate the display date
5409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5410             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5411             * @throws SystemException if a system exception occurred
5412             */
5413            @Override
5414            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
5415                    OrderByComparator orderByComparator) throws SystemException {
5416                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
5417                                    orderByComparator);
5418    
5419                    if (!list.isEmpty()) {
5420                            return list.get(0);
5421                    }
5422    
5423                    return null;
5424            }
5425    
5426            /**
5427             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5428             *
5429             * @param groupId the group ID
5430             * @param displayDate the display date
5431             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5432             * @return the last matching blogs entry
5433             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5434             * @throws SystemException if a system exception occurred
5435             */
5436            @Override
5437            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
5438                    OrderByComparator orderByComparator)
5439                    throws NoSuchEntryException, SystemException {
5440                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
5441                                    orderByComparator);
5442    
5443                    if (blogsEntry != null) {
5444                            return blogsEntry;
5445                    }
5446    
5447                    StringBundler msg = new StringBundler(6);
5448    
5449                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5450    
5451                    msg.append("groupId=");
5452                    msg.append(groupId);
5453    
5454                    msg.append(", displayDate=");
5455                    msg.append(displayDate);
5456    
5457                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5458    
5459                    throw new NoSuchEntryException(msg.toString());
5460            }
5461    
5462            /**
5463             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5464             *
5465             * @param groupId the group ID
5466             * @param displayDate the display date
5467             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5468             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5469             * @throws SystemException if a system exception occurred
5470             */
5471            @Override
5472            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
5473                    OrderByComparator orderByComparator) throws SystemException {
5474                    int count = countByG_LtD(groupId, displayDate);
5475    
5476                    if (count == 0) {
5477                            return null;
5478                    }
5479    
5480                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
5481                                    count, orderByComparator);
5482    
5483                    if (!list.isEmpty()) {
5484                            return list.get(0);
5485                    }
5486    
5487                    return null;
5488            }
5489    
5490            /**
5491             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
5492             *
5493             * @param entryId the primary key of the current blogs entry
5494             * @param groupId the group ID
5495             * @param displayDate the display date
5496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5497             * @return the previous, current, and next blogs entry
5498             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5499             * @throws SystemException if a system exception occurred
5500             */
5501            @Override
5502            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
5503                    Date displayDate, OrderByComparator orderByComparator)
5504                    throws NoSuchEntryException, SystemException {
5505                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5506    
5507                    Session session = null;
5508    
5509                    try {
5510                            session = openSession();
5511    
5512                            BlogsEntry[] array = new BlogsEntryImpl[3];
5513    
5514                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5515                                            displayDate, orderByComparator, true);
5516    
5517                            array[1] = blogsEntry;
5518    
5519                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
5520                                            displayDate, orderByComparator, false);
5521    
5522                            return array;
5523                    }
5524                    catch (Exception e) {
5525                            throw processException(e);
5526                    }
5527                    finally {
5528                            closeSession(session);
5529                    }
5530            }
5531    
5532            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
5533                    BlogsEntry blogsEntry, long groupId, Date displayDate,
5534                    OrderByComparator orderByComparator, boolean previous) {
5535                    StringBundler query = null;
5536    
5537                    if (orderByComparator != null) {
5538                            query = new StringBundler(6 +
5539                                            (orderByComparator.getOrderByFields().length * 6));
5540                    }
5541                    else {
5542                            query = new StringBundler(3);
5543                    }
5544    
5545                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5546    
5547                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5548    
5549                    boolean bindDisplayDate = false;
5550    
5551                    if (displayDate == null) {
5552                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5553                    }
5554                    else {
5555                            bindDisplayDate = true;
5556    
5557                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5558                    }
5559    
5560                    if (orderByComparator != null) {
5561                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5562    
5563                            if (orderByConditionFields.length > 0) {
5564                                    query.append(WHERE_AND);
5565                            }
5566    
5567                            for (int i = 0; i < orderByConditionFields.length; i++) {
5568                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5569                                    query.append(orderByConditionFields[i]);
5570    
5571                                    if ((i + 1) < orderByConditionFields.length) {
5572                                            if (orderByComparator.isAscending() ^ previous) {
5573                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5574                                            }
5575                                            else {
5576                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5577                                            }
5578                                    }
5579                                    else {
5580                                            if (orderByComparator.isAscending() ^ previous) {
5581                                                    query.append(WHERE_GREATER_THAN);
5582                                            }
5583                                            else {
5584                                                    query.append(WHERE_LESSER_THAN);
5585                                            }
5586                                    }
5587                            }
5588    
5589                            query.append(ORDER_BY_CLAUSE);
5590    
5591                            String[] orderByFields = orderByComparator.getOrderByFields();
5592    
5593                            for (int i = 0; i < orderByFields.length; i++) {
5594                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5595                                    query.append(orderByFields[i]);
5596    
5597                                    if ((i + 1) < orderByFields.length) {
5598                                            if (orderByComparator.isAscending() ^ previous) {
5599                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5600                                            }
5601                                            else {
5602                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5603                                            }
5604                                    }
5605                                    else {
5606                                            if (orderByComparator.isAscending() ^ previous) {
5607                                                    query.append(ORDER_BY_ASC);
5608                                            }
5609                                            else {
5610                                                    query.append(ORDER_BY_DESC);
5611                                            }
5612                                    }
5613                            }
5614                    }
5615                    else {
5616                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5617                    }
5618    
5619                    String sql = query.toString();
5620    
5621                    Query q = session.createQuery(sql);
5622    
5623                    q.setFirstResult(0);
5624                    q.setMaxResults(2);
5625    
5626                    QueryPos qPos = QueryPos.getInstance(q);
5627    
5628                    qPos.add(groupId);
5629    
5630                    if (bindDisplayDate) {
5631                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5632                    }
5633    
5634                    if (orderByComparator != null) {
5635                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5636    
5637                            for (Object value : values) {
5638                                    qPos.add(value);
5639                            }
5640                    }
5641    
5642                    List<BlogsEntry> list = q.list();
5643    
5644                    if (list.size() == 2) {
5645                            return list.get(1);
5646                    }
5647                    else {
5648                            return null;
5649                    }
5650            }
5651    
5652            /**
5653             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5654             *
5655             * @param groupId the group ID
5656             * @param displayDate the display date
5657             * @return the matching blogs entries that the user has permission to view
5658             * @throws SystemException if a system exception occurred
5659             */
5660            @Override
5661            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate)
5662                    throws SystemException {
5663                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
5664                            QueryUtil.ALL_POS, null);
5665            }
5666    
5667            /**
5668             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
5669             *
5670             * <p>
5671             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5672             * </p>
5673             *
5674             * @param groupId the group ID
5675             * @param displayDate the display date
5676             * @param start the lower bound of the range of blogs entries
5677             * @param end the upper bound of the range of blogs entries (not inclusive)
5678             * @return the range of matching blogs entries that the user has permission to view
5679             * @throws SystemException if a system exception occurred
5680             */
5681            @Override
5682            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5683                    int start, int end) throws SystemException {
5684                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
5685            }
5686    
5687            /**
5688             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
5689             *
5690             * <p>
5691             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5692             * </p>
5693             *
5694             * @param groupId the group ID
5695             * @param displayDate the display date
5696             * @param start the lower bound of the range of blogs entries
5697             * @param end the upper bound of the range of blogs entries (not inclusive)
5698             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5699             * @return the ordered range of matching blogs entries that the user has permission to view
5700             * @throws SystemException if a system exception occurred
5701             */
5702            @Override
5703            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
5704                    int start, int end, OrderByComparator orderByComparator)
5705                    throws SystemException {
5706                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5707                            return findByG_LtD(groupId, displayDate, start, end,
5708                                    orderByComparator);
5709                    }
5710    
5711                    StringBundler query = null;
5712    
5713                    if (orderByComparator != null) {
5714                            query = new StringBundler(4 +
5715                                            (orderByComparator.getOrderByFields().length * 3));
5716                    }
5717                    else {
5718                            query = new StringBundler(4);
5719                    }
5720    
5721                    if (getDB().isSupportsInlineDistinct()) {
5722                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5723                    }
5724                    else {
5725                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5726                    }
5727    
5728                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5729    
5730                    boolean bindDisplayDate = false;
5731    
5732                    if (displayDate == null) {
5733                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5734                    }
5735                    else {
5736                            bindDisplayDate = true;
5737    
5738                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5739                    }
5740    
5741                    if (!getDB().isSupportsInlineDistinct()) {
5742                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5743                    }
5744    
5745                    if (orderByComparator != null) {
5746                            if (getDB().isSupportsInlineDistinct()) {
5747                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5748                                            orderByComparator, true);
5749                            }
5750                            else {
5751                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5752                                            orderByComparator, true);
5753                            }
5754                    }
5755                    else {
5756                            if (getDB().isSupportsInlineDistinct()) {
5757                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5758                            }
5759                            else {
5760                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5761                            }
5762                    }
5763    
5764                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5765                                    BlogsEntry.class.getName(),
5766                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5767    
5768                    Session session = null;
5769    
5770                    try {
5771                            session = openSession();
5772    
5773                            SQLQuery q = session.createSQLQuery(sql);
5774    
5775                            if (getDB().isSupportsInlineDistinct()) {
5776                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5777                            }
5778                            else {
5779                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5780                            }
5781    
5782                            QueryPos qPos = QueryPos.getInstance(q);
5783    
5784                            qPos.add(groupId);
5785    
5786                            if (bindDisplayDate) {
5787                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
5788                            }
5789    
5790                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5791                    }
5792                    catch (Exception e) {
5793                            throw processException(e);
5794                    }
5795                    finally {
5796                            closeSession(session);
5797                    }
5798            }
5799    
5800            /**
5801             * 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;.
5802             *
5803             * @param entryId the primary key of the current blogs entry
5804             * @param groupId the group ID
5805             * @param displayDate the display date
5806             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5807             * @return the previous, current, and next blogs entry
5808             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5809             * @throws SystemException if a system exception occurred
5810             */
5811            @Override
5812            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
5813                    long groupId, Date displayDate, OrderByComparator orderByComparator)
5814                    throws NoSuchEntryException, SystemException {
5815                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5816                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
5817                                    orderByComparator);
5818                    }
5819    
5820                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5821    
5822                    Session session = null;
5823    
5824                    try {
5825                            session = openSession();
5826    
5827                            BlogsEntry[] array = new BlogsEntryImpl[3];
5828    
5829                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5830                                            groupId, displayDate, orderByComparator, true);
5831    
5832                            array[1] = blogsEntry;
5833    
5834                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
5835                                            groupId, displayDate, orderByComparator, false);
5836    
5837                            return array;
5838                    }
5839                    catch (Exception e) {
5840                            throw processException(e);
5841                    }
5842                    finally {
5843                            closeSession(session);
5844                    }
5845            }
5846    
5847            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
5848                    BlogsEntry blogsEntry, long groupId, Date displayDate,
5849                    OrderByComparator orderByComparator, boolean previous) {
5850                    StringBundler query = null;
5851    
5852                    if (orderByComparator != null) {
5853                            query = new StringBundler(6 +
5854                                            (orderByComparator.getOrderByFields().length * 6));
5855                    }
5856                    else {
5857                            query = new StringBundler(3);
5858                    }
5859    
5860                    if (getDB().isSupportsInlineDistinct()) {
5861                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5862                    }
5863                    else {
5864                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5865                    }
5866    
5867                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
5868    
5869                    boolean bindDisplayDate = false;
5870    
5871                    if (displayDate == null) {
5872                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
5873                    }
5874                    else {
5875                            bindDisplayDate = true;
5876    
5877                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
5878                    }
5879    
5880                    if (!getDB().isSupportsInlineDistinct()) {
5881                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5882                    }
5883    
5884                    if (orderByComparator != null) {
5885                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5886    
5887                            if (orderByConditionFields.length > 0) {
5888                                    query.append(WHERE_AND);
5889                            }
5890    
5891                            for (int i = 0; i < orderByConditionFields.length; i++) {
5892                                    if (getDB().isSupportsInlineDistinct()) {
5893                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5894                                    }
5895                                    else {
5896                                            query.append(_ORDER_BY_ENTITY_TABLE);
5897                                    }
5898    
5899                                    query.append(orderByConditionFields[i]);
5900    
5901                                    if ((i + 1) < orderByConditionFields.length) {
5902                                            if (orderByComparator.isAscending() ^ previous) {
5903                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5904                                            }
5905                                            else {
5906                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5907                                            }
5908                                    }
5909                                    else {
5910                                            if (orderByComparator.isAscending() ^ previous) {
5911                                                    query.append(WHERE_GREATER_THAN);
5912                                            }
5913                                            else {
5914                                                    query.append(WHERE_LESSER_THAN);
5915                                            }
5916                                    }
5917                            }
5918    
5919                            query.append(ORDER_BY_CLAUSE);
5920    
5921                            String[] orderByFields = orderByComparator.getOrderByFields();
5922    
5923                            for (int i = 0; i < orderByFields.length; i++) {
5924                                    if (getDB().isSupportsInlineDistinct()) {
5925                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5926                                    }
5927                                    else {
5928                                            query.append(_ORDER_BY_ENTITY_TABLE);
5929                                    }
5930    
5931                                    query.append(orderByFields[i]);
5932    
5933                                    if ((i + 1) < orderByFields.length) {
5934                                            if (orderByComparator.isAscending() ^ previous) {
5935                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5936                                            }
5937                                            else {
5938                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5939                                            }
5940                                    }
5941                                    else {
5942                                            if (orderByComparator.isAscending() ^ previous) {
5943                                                    query.append(ORDER_BY_ASC);
5944                                            }
5945                                            else {
5946                                                    query.append(ORDER_BY_DESC);
5947                                            }
5948                                    }
5949                            }
5950                    }
5951                    else {
5952                            if (getDB().isSupportsInlineDistinct()) {
5953                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5954                            }
5955                            else {
5956                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5957                            }
5958                    }
5959    
5960                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5961                                    BlogsEntry.class.getName(),
5962                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5963    
5964                    SQLQuery q = session.createSQLQuery(sql);
5965    
5966                    q.setFirstResult(0);
5967                    q.setMaxResults(2);
5968    
5969                    if (getDB().isSupportsInlineDistinct()) {
5970                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5971                    }
5972                    else {
5973                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5974                    }
5975    
5976                    QueryPos qPos = QueryPos.getInstance(q);
5977    
5978                    qPos.add(groupId);
5979    
5980                    if (bindDisplayDate) {
5981                            qPos.add(CalendarUtil.getTimestamp(displayDate));
5982                    }
5983    
5984                    if (orderByComparator != null) {
5985                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5986    
5987                            for (Object value : values) {
5988                                    qPos.add(value);
5989                            }
5990                    }
5991    
5992                    List<BlogsEntry> list = q.list();
5993    
5994                    if (list.size() == 2) {
5995                            return list.get(1);
5996                    }
5997                    else {
5998                            return null;
5999                    }
6000            }
6001    
6002            /**
6003             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
6004             *
6005             * @param groupId the group ID
6006             * @param displayDate the display date
6007             * @throws SystemException if a system exception occurred
6008             */
6009            @Override
6010            public void removeByG_LtD(long groupId, Date displayDate)
6011                    throws SystemException {
6012                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
6013                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6014                            remove(blogsEntry);
6015                    }
6016            }
6017    
6018            /**
6019             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
6020             *
6021             * @param groupId the group ID
6022             * @param displayDate the display date
6023             * @return the number of matching blogs entries
6024             * @throws SystemException if a system exception occurred
6025             */
6026            @Override
6027            public int countByG_LtD(long groupId, Date displayDate)
6028                    throws SystemException {
6029                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
6030    
6031                    Object[] finderArgs = new Object[] { groupId, displayDate };
6032    
6033                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6034                                    this);
6035    
6036                    if (count == null) {
6037                            StringBundler query = new StringBundler(3);
6038    
6039                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6040    
6041                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
6042    
6043                            boolean bindDisplayDate = false;
6044    
6045                            if (displayDate == null) {
6046                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
6047                            }
6048                            else {
6049                                    bindDisplayDate = true;
6050    
6051                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
6052                            }
6053    
6054                            String sql = query.toString();
6055    
6056                            Session session = null;
6057    
6058                            try {
6059                                    session = openSession();
6060    
6061                                    Query q = session.createQuery(sql);
6062    
6063                                    QueryPos qPos = QueryPos.getInstance(q);
6064    
6065                                    qPos.add(groupId);
6066    
6067                                    if (bindDisplayDate) {
6068                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
6069                                    }
6070    
6071                                    count = (Long)q.uniqueResult();
6072    
6073                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6074                            }
6075                            catch (Exception e) {
6076                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6077    
6078                                    throw processException(e);
6079                            }
6080                            finally {
6081                                    closeSession(session);
6082                            }
6083                    }
6084    
6085                    return count.intValue();
6086            }
6087    
6088            /**
6089             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
6090             *
6091             * @param groupId the group ID
6092             * @param displayDate the display date
6093             * @return the number of matching blogs entries that the user has permission to view
6094             * @throws SystemException if a system exception occurred
6095             */
6096            @Override
6097            public int filterCountByG_LtD(long groupId, Date displayDate)
6098                    throws SystemException {
6099                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6100                            return countByG_LtD(groupId, displayDate);
6101                    }
6102    
6103                    StringBundler query = new StringBundler(3);
6104    
6105                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
6106    
6107                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
6108    
6109                    boolean bindDisplayDate = false;
6110    
6111                    if (displayDate == null) {
6112                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
6113                    }
6114                    else {
6115                            bindDisplayDate = true;
6116    
6117                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
6118                    }
6119    
6120                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6121                                    BlogsEntry.class.getName(),
6122                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6123    
6124                    Session session = null;
6125    
6126                    try {
6127                            session = openSession();
6128    
6129                            SQLQuery q = session.createSQLQuery(sql);
6130    
6131                            q.addScalar(COUNT_COLUMN_NAME,
6132                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6133    
6134                            QueryPos qPos = QueryPos.getInstance(q);
6135    
6136                            qPos.add(groupId);
6137    
6138                            if (bindDisplayDate) {
6139                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
6140                            }
6141    
6142                            Long count = (Long)q.uniqueResult();
6143    
6144                            return count.intValue();
6145                    }
6146                    catch (Exception e) {
6147                            throw processException(e);
6148                    }
6149                    finally {
6150                            closeSession(session);
6151                    }
6152            }
6153    
6154            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
6155            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
6156            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
6157            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6158                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6159                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
6160                            new String[] {
6161                                    Long.class.getName(), Integer.class.getName(),
6162                                    
6163                            Integer.class.getName(), Integer.class.getName(),
6164                                    OrderByComparator.class.getName()
6165                            });
6166            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6167                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6168                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
6169                            new String[] { Long.class.getName(), Integer.class.getName() });
6170    
6171            /**
6172             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
6173             *
6174             * @param groupId the group ID
6175             * @param status the status
6176             * @return the matching blogs entries
6177             * @throws SystemException if a system exception occurred
6178             */
6179            @Override
6180            public List<BlogsEntry> findByG_NotS(long groupId, int status)
6181                    throws SystemException {
6182                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
6183                            QueryUtil.ALL_POS, null);
6184            }
6185    
6186            /**
6187             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
6188             *
6189             * <p>
6190             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
6191             * </p>
6192             *
6193             * @param groupId the group ID
6194             * @param status the status
6195             * @param start the lower bound of the range of blogs entries
6196             * @param end the upper bound of the range of blogs entries (not inclusive)
6197             * @return the range of matching blogs entries
6198             * @throws SystemException if a system exception occurred
6199             */
6200            @Override
6201            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
6202                    int end) throws SystemException {
6203                    return findByG_NotS(groupId, status, start, end, null);
6204            }
6205    
6206            /**
6207             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
6208             *
6209             * <p>
6210             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
6211             * </p>
6212             *
6213             * @param groupId the group ID
6214             * @param status the status
6215             * @param start the lower bound of the range of blogs entries
6216             * @param end the upper bound of the range of blogs entries (not inclusive)
6217             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6218             * @return the ordered range of matching blogs entries
6219             * @throws SystemException if a system exception occurred
6220             */
6221            @Override
6222            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
6223                    int end, OrderByComparator orderByComparator) throws SystemException {
6224                    boolean pagination = true;
6225                    FinderPath finderPath = null;
6226                    Object[] finderArgs = null;
6227    
6228                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
6229                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
6230    
6231                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6232                                    finderArgs, this);
6233    
6234                    if ((list != null) && !list.isEmpty()) {
6235                            for (BlogsEntry blogsEntry : list) {
6236                                    if ((groupId != blogsEntry.getGroupId()) ||
6237                                                    (status == blogsEntry.getStatus())) {
6238                                            list = null;
6239    
6240                                            break;
6241                                    }
6242                            }
6243                    }
6244    
6245                    if (list == null) {
6246                            StringBundler query = null;
6247    
6248                            if (orderByComparator != null) {
6249                                    query = new StringBundler(4 +
6250                                                    (orderByComparator.getOrderByFields().length * 3));
6251                            }
6252                            else {
6253                                    query = new StringBundler(4);
6254                            }
6255    
6256                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6257    
6258                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6259    
6260                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6261    
6262                            if (orderByComparator != null) {
6263                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6264                                            orderByComparator);
6265                            }
6266                            else
6267                             if (pagination) {
6268                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6269                            }
6270    
6271                            String sql = query.toString();
6272    
6273                            Session session = null;
6274    
6275                            try {
6276                                    session = openSession();
6277    
6278                                    Query q = session.createQuery(sql);
6279    
6280                                    QueryPos qPos = QueryPos.getInstance(q);
6281    
6282                                    qPos.add(groupId);
6283    
6284                                    qPos.add(status);
6285    
6286                                    if (!pagination) {
6287                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6288                                                            start, end, false);
6289    
6290                                            Collections.sort(list);
6291    
6292                                            list = new UnmodifiableList<BlogsEntry>(list);
6293                                    }
6294                                    else {
6295                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6296                                                            start, end);
6297                                    }
6298    
6299                                    cacheResult(list);
6300    
6301                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6302                            }
6303                            catch (Exception e) {
6304                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6305    
6306                                    throw processException(e);
6307                            }
6308                            finally {
6309                                    closeSession(session);
6310                            }
6311                    }
6312    
6313                    return list;
6314            }
6315    
6316            /**
6317             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6318             *
6319             * @param groupId the group ID
6320             * @param status the status
6321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6322             * @return the first matching blogs entry
6323             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6324             * @throws SystemException if a system exception occurred
6325             */
6326            @Override
6327            public BlogsEntry findByG_NotS_First(long groupId, int status,
6328                    OrderByComparator orderByComparator)
6329                    throws NoSuchEntryException, SystemException {
6330                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
6331                                    orderByComparator);
6332    
6333                    if (blogsEntry != null) {
6334                            return blogsEntry;
6335                    }
6336    
6337                    StringBundler msg = new StringBundler(6);
6338    
6339                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6340    
6341                    msg.append("groupId=");
6342                    msg.append(groupId);
6343    
6344                    msg.append(", status=");
6345                    msg.append(status);
6346    
6347                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6348    
6349                    throw new NoSuchEntryException(msg.toString());
6350            }
6351    
6352            /**
6353             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6354             *
6355             * @param groupId the group ID
6356             * @param status the status
6357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6358             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6359             * @throws SystemException if a system exception occurred
6360             */
6361            @Override
6362            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
6363                    OrderByComparator orderByComparator) throws SystemException {
6364                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
6365                                    orderByComparator);
6366    
6367                    if (!list.isEmpty()) {
6368                            return list.get(0);
6369                    }
6370    
6371                    return null;
6372            }
6373    
6374            /**
6375             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6376             *
6377             * @param groupId the group ID
6378             * @param status the status
6379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6380             * @return the last matching blogs entry
6381             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6382             * @throws SystemException if a system exception occurred
6383             */
6384            @Override
6385            public BlogsEntry findByG_NotS_Last(long groupId, int status,
6386                    OrderByComparator orderByComparator)
6387                    throws NoSuchEntryException, SystemException {
6388                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
6389                                    orderByComparator);
6390    
6391                    if (blogsEntry != null) {
6392                            return blogsEntry;
6393                    }
6394    
6395                    StringBundler msg = new StringBundler(6);
6396    
6397                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6398    
6399                    msg.append("groupId=");
6400                    msg.append(groupId);
6401    
6402                    msg.append(", status=");
6403                    msg.append(status);
6404    
6405                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6406    
6407                    throw new NoSuchEntryException(msg.toString());
6408            }
6409    
6410            /**
6411             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6412             *
6413             * @param groupId the group ID
6414             * @param status the status
6415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6416             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6417             * @throws SystemException if a system exception occurred
6418             */
6419            @Override
6420            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
6421                    OrderByComparator orderByComparator) throws SystemException {
6422                    int count = countByG_NotS(groupId, status);
6423    
6424                    if (count == 0) {
6425                            return null;
6426                    }
6427    
6428                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
6429                                    orderByComparator);
6430    
6431                    if (!list.isEmpty()) {
6432                            return list.get(0);
6433                    }
6434    
6435                    return null;
6436            }
6437    
6438            /**
6439             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
6440             *
6441             * @param entryId the primary key of the current blogs entry
6442             * @param groupId the group ID
6443             * @param status the status
6444             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6445             * @return the previous, current, and next blogs entry
6446             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6447             * @throws SystemException if a system exception occurred
6448             */
6449            @Override
6450            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
6451                    int status, OrderByComparator orderByComparator)
6452                    throws NoSuchEntryException, SystemException {
6453                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6454    
6455                    Session session = null;
6456    
6457                    try {
6458                            session = openSession();
6459    
6460                            BlogsEntry[] array = new BlogsEntryImpl[3];
6461    
6462                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
6463                                            status, orderByComparator, true);
6464    
6465                            array[1] = blogsEntry;
6466    
6467                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
6468                                            status, orderByComparator, false);
6469    
6470                            return array;
6471                    }
6472                    catch (Exception e) {
6473                            throw processException(e);
6474                    }
6475                    finally {
6476                            closeSession(session);
6477                    }
6478            }
6479    
6480            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
6481                    BlogsEntry blogsEntry, long groupId, int status,
6482                    OrderByComparator orderByComparator, boolean previous) {
6483                    StringBundler query = null;
6484    
6485                    if (orderByComparator != null) {
6486                            query = new StringBundler(6 +
6487                                            (orderByComparator.getOrderByFields().length * 6));
6488                    }
6489                    else {
6490                            query = new StringBundler(3);
6491                    }
6492    
6493                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6494    
6495                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6496    
6497                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6498    
6499                    if (orderByComparator != null) {
6500                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6501    
6502                            if (orderByConditionFields.length > 0) {
6503                                    query.append(WHERE_AND);
6504                            }
6505    
6506                            for (int i = 0; i < orderByConditionFields.length; i++) {
6507                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6508                                    query.append(orderByConditionFields[i]);
6509    
6510                                    if ((i + 1) < orderByConditionFields.length) {
6511                                            if (orderByComparator.isAscending() ^ previous) {
6512                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6513                                            }
6514                                            else {
6515                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6516                                            }
6517                                    }
6518                                    else {
6519                                            if (orderByComparator.isAscending() ^ previous) {
6520                                                    query.append(WHERE_GREATER_THAN);
6521                                            }
6522                                            else {
6523                                                    query.append(WHERE_LESSER_THAN);
6524                                            }
6525                                    }
6526                            }
6527    
6528                            query.append(ORDER_BY_CLAUSE);
6529    
6530                            String[] orderByFields = orderByComparator.getOrderByFields();
6531    
6532                            for (int i = 0; i < orderByFields.length; i++) {
6533                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6534                                    query.append(orderByFields[i]);
6535    
6536                                    if ((i + 1) < orderByFields.length) {
6537                                            if (orderByComparator.isAscending() ^ previous) {
6538                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6539                                            }
6540                                            else {
6541                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6542                                            }
6543                                    }
6544                                    else {
6545                                            if (orderByComparator.isAscending() ^ previous) {
6546                                                    query.append(ORDER_BY_ASC);
6547                                            }
6548                                            else {
6549                                                    query.append(ORDER_BY_DESC);
6550                                            }
6551                                    }
6552                            }
6553                    }
6554                    else {
6555                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6556                    }
6557    
6558                    String sql = query.toString();
6559    
6560                    Query q = session.createQuery(sql);
6561    
6562                    q.setFirstResult(0);
6563                    q.setMaxResults(2);
6564    
6565                    QueryPos qPos = QueryPos.getInstance(q);
6566    
6567                    qPos.add(groupId);
6568    
6569                    qPos.add(status);
6570    
6571                    if (orderByComparator != null) {
6572                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6573    
6574                            for (Object value : values) {
6575                                    qPos.add(value);
6576                            }
6577                    }
6578    
6579                    List<BlogsEntry> list = q.list();
6580    
6581                    if (list.size() == 2) {
6582                            return list.get(1);
6583                    }
6584                    else {
6585                            return null;
6586                    }
6587            }
6588    
6589            /**
6590             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6591             *
6592             * @param groupId the group ID
6593             * @param status the status
6594             * @return the matching blogs entries that the user has permission to view
6595             * @throws SystemException if a system exception occurred
6596             */
6597            @Override
6598            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status)
6599                    throws SystemException {
6600                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
6601                            QueryUtil.ALL_POS, null);
6602            }
6603    
6604            /**
6605             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6606             *
6607             * <p>
6608             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.
6609             * </p>
6610             *
6611             * @param groupId the group ID
6612             * @param status the status
6613             * @param start the lower bound of the range of blogs entries
6614             * @param end the upper bound of the range of blogs entries (not inclusive)
6615             * @return the range of matching blogs entries that the user has permission to view
6616             * @throws SystemException if a system exception occurred
6617             */
6618            @Override
6619            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
6620                    int start, int end) throws SystemException {
6621                    return filterFindByG_NotS(groupId, status, start, end, null);
6622            }
6623    
6624            /**
6625             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
6626             *
6627             * <p>
6628             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
6629             * </p>
6630             *
6631             * @param groupId the group ID
6632             * @param status the status
6633             * @param start the lower bound of the range of blogs entries
6634             * @param end the upper bound of the range of blogs entries (not inclusive)
6635             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6636             * @return the ordered range of matching blogs entries that the user has permission to view
6637             * @throws SystemException if a system exception occurred
6638             */
6639            @Override
6640            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
6641                    int start, int end, OrderByComparator orderByComparator)
6642                    throws SystemException {
6643                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6644                            return findByG_NotS(groupId, status, start, end, orderByComparator);
6645                    }
6646    
6647                    StringBundler query = null;
6648    
6649                    if (orderByComparator != null) {
6650                            query = new StringBundler(4 +
6651                                            (orderByComparator.getOrderByFields().length * 3));
6652                    }
6653                    else {
6654                            query = new StringBundler(4);
6655                    }
6656    
6657                    if (getDB().isSupportsInlineDistinct()) {
6658                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6659                    }
6660                    else {
6661                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6662                    }
6663    
6664                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6665    
6666                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6667    
6668                    if (!getDB().isSupportsInlineDistinct()) {
6669                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6670                    }
6671    
6672                    if (orderByComparator != null) {
6673                            if (getDB().isSupportsInlineDistinct()) {
6674                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6675                                            orderByComparator, true);
6676                            }
6677                            else {
6678                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6679                                            orderByComparator, true);
6680                            }
6681                    }
6682                    else {
6683                            if (getDB().isSupportsInlineDistinct()) {
6684                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6685                            }
6686                            else {
6687                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6688                            }
6689                    }
6690    
6691                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6692                                    BlogsEntry.class.getName(),
6693                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6694    
6695                    Session session = null;
6696    
6697                    try {
6698                            session = openSession();
6699    
6700                            SQLQuery q = session.createSQLQuery(sql);
6701    
6702                            if (getDB().isSupportsInlineDistinct()) {
6703                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6704                            }
6705                            else {
6706                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6707                            }
6708    
6709                            QueryPos qPos = QueryPos.getInstance(q);
6710    
6711                            qPos.add(groupId);
6712    
6713                            qPos.add(status);
6714    
6715                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
6716                    }
6717                    catch (Exception e) {
6718                            throw processException(e);
6719                    }
6720                    finally {
6721                            closeSession(session);
6722                    }
6723            }
6724    
6725            /**
6726             * 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;.
6727             *
6728             * @param entryId the primary key of the current blogs entry
6729             * @param groupId the group ID
6730             * @param status the status
6731             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6732             * @return the previous, current, and next blogs entry
6733             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6734             * @throws SystemException if a system exception occurred
6735             */
6736            @Override
6737            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
6738                    long groupId, int status, OrderByComparator orderByComparator)
6739                    throws NoSuchEntryException, SystemException {
6740                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6741                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
6742                                    orderByComparator);
6743                    }
6744    
6745                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6746    
6747                    Session session = null;
6748    
6749                    try {
6750                            session = openSession();
6751    
6752                            BlogsEntry[] array = new BlogsEntryImpl[3];
6753    
6754                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
6755                                            groupId, status, orderByComparator, true);
6756    
6757                            array[1] = blogsEntry;
6758    
6759                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
6760                                            groupId, status, orderByComparator, false);
6761    
6762                            return array;
6763                    }
6764                    catch (Exception e) {
6765                            throw processException(e);
6766                    }
6767                    finally {
6768                            closeSession(session);
6769                    }
6770            }
6771    
6772            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
6773                    BlogsEntry blogsEntry, long groupId, int status,
6774                    OrderByComparator orderByComparator, boolean previous) {
6775                    StringBundler query = null;
6776    
6777                    if (orderByComparator != null) {
6778                            query = new StringBundler(6 +
6779                                            (orderByComparator.getOrderByFields().length * 6));
6780                    }
6781                    else {
6782                            query = new StringBundler(3);
6783                    }
6784    
6785                    if (getDB().isSupportsInlineDistinct()) {
6786                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
6787                    }
6788                    else {
6789                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
6790                    }
6791    
6792                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6793    
6794                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6795    
6796                    if (!getDB().isSupportsInlineDistinct()) {
6797                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
6798                    }
6799    
6800                    if (orderByComparator != null) {
6801                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6802    
6803                            if (orderByConditionFields.length > 0) {
6804                                    query.append(WHERE_AND);
6805                            }
6806    
6807                            for (int i = 0; i < orderByConditionFields.length; i++) {
6808                                    if (getDB().isSupportsInlineDistinct()) {
6809                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6810                                    }
6811                                    else {
6812                                            query.append(_ORDER_BY_ENTITY_TABLE);
6813                                    }
6814    
6815                                    query.append(orderByConditionFields[i]);
6816    
6817                                    if ((i + 1) < orderByConditionFields.length) {
6818                                            if (orderByComparator.isAscending() ^ previous) {
6819                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6820                                            }
6821                                            else {
6822                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6823                                            }
6824                                    }
6825                                    else {
6826                                            if (orderByComparator.isAscending() ^ previous) {
6827                                                    query.append(WHERE_GREATER_THAN);
6828                                            }
6829                                            else {
6830                                                    query.append(WHERE_LESSER_THAN);
6831                                            }
6832                                    }
6833                            }
6834    
6835                            query.append(ORDER_BY_CLAUSE);
6836    
6837                            String[] orderByFields = orderByComparator.getOrderByFields();
6838    
6839                            for (int i = 0; i < orderByFields.length; i++) {
6840                                    if (getDB().isSupportsInlineDistinct()) {
6841                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6842                                    }
6843                                    else {
6844                                            query.append(_ORDER_BY_ENTITY_TABLE);
6845                                    }
6846    
6847                                    query.append(orderByFields[i]);
6848    
6849                                    if ((i + 1) < orderByFields.length) {
6850                                            if (orderByComparator.isAscending() ^ previous) {
6851                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6852                                            }
6853                                            else {
6854                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6855                                            }
6856                                    }
6857                                    else {
6858                                            if (orderByComparator.isAscending() ^ previous) {
6859                                                    query.append(ORDER_BY_ASC);
6860                                            }
6861                                            else {
6862                                                    query.append(ORDER_BY_DESC);
6863                                            }
6864                                    }
6865                            }
6866                    }
6867                    else {
6868                            if (getDB().isSupportsInlineDistinct()) {
6869                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6870                            }
6871                            else {
6872                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
6873                            }
6874                    }
6875    
6876                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6877                                    BlogsEntry.class.getName(),
6878                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6879    
6880                    SQLQuery q = session.createSQLQuery(sql);
6881    
6882                    q.setFirstResult(0);
6883                    q.setMaxResults(2);
6884    
6885                    if (getDB().isSupportsInlineDistinct()) {
6886                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
6887                    }
6888                    else {
6889                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
6890                    }
6891    
6892                    QueryPos qPos = QueryPos.getInstance(q);
6893    
6894                    qPos.add(groupId);
6895    
6896                    qPos.add(status);
6897    
6898                    if (orderByComparator != null) {
6899                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6900    
6901                            for (Object value : values) {
6902                                    qPos.add(value);
6903                            }
6904                    }
6905    
6906                    List<BlogsEntry> list = q.list();
6907    
6908                    if (list.size() == 2) {
6909                            return list.get(1);
6910                    }
6911                    else {
6912                            return null;
6913                    }
6914            }
6915    
6916            /**
6917             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
6918             *
6919             * @param groupId the group ID
6920             * @param status the status
6921             * @throws SystemException if a system exception occurred
6922             */
6923            @Override
6924            public void removeByG_NotS(long groupId, int status)
6925                    throws SystemException {
6926                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
6927                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6928                            remove(blogsEntry);
6929                    }
6930            }
6931    
6932            /**
6933             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
6934             *
6935             * @param groupId the group ID
6936             * @param status the status
6937             * @return the number of matching blogs entries
6938             * @throws SystemException if a system exception occurred
6939             */
6940            @Override
6941            public int countByG_NotS(long groupId, int status)
6942                    throws SystemException {
6943                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
6944    
6945                    Object[] finderArgs = new Object[] { groupId, status };
6946    
6947                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6948                                    this);
6949    
6950                    if (count == null) {
6951                            StringBundler query = new StringBundler(3);
6952    
6953                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6954    
6955                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
6956    
6957                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
6958    
6959                            String sql = query.toString();
6960    
6961                            Session session = null;
6962    
6963                            try {
6964                                    session = openSession();
6965    
6966                                    Query q = session.createQuery(sql);
6967    
6968                                    QueryPos qPos = QueryPos.getInstance(q);
6969    
6970                                    qPos.add(groupId);
6971    
6972                                    qPos.add(status);
6973    
6974                                    count = (Long)q.uniqueResult();
6975    
6976                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6977                            }
6978                            catch (Exception e) {
6979                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6980    
6981                                    throw processException(e);
6982                            }
6983                            finally {
6984                                    closeSession(session);
6985                            }
6986                    }
6987    
6988                    return count.intValue();
6989            }
6990    
6991            /**
6992             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
6993             *
6994             * @param groupId the group ID
6995             * @param status the status
6996             * @return the number of matching blogs entries that the user has permission to view
6997             * @throws SystemException if a system exception occurred
6998             */
6999            @Override
7000            public int filterCountByG_NotS(long groupId, int status)
7001                    throws SystemException {
7002                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7003                            return countByG_NotS(groupId, status);
7004                    }
7005    
7006                    StringBundler query = new StringBundler(3);
7007    
7008                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
7009    
7010                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
7011    
7012                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
7013    
7014                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7015                                    BlogsEntry.class.getName(),
7016                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7017    
7018                    Session session = null;
7019    
7020                    try {
7021                            session = openSession();
7022    
7023                            SQLQuery q = session.createSQLQuery(sql);
7024    
7025                            q.addScalar(COUNT_COLUMN_NAME,
7026                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7027    
7028                            QueryPos qPos = QueryPos.getInstance(q);
7029    
7030                            qPos.add(groupId);
7031    
7032                            qPos.add(status);
7033    
7034                            Long count = (Long)q.uniqueResult();
7035    
7036                            return count.intValue();
7037                    }
7038                    catch (Exception e) {
7039                            throw processException(e);
7040                    }
7041                    finally {
7042                            closeSession(session);
7043                    }
7044            }
7045    
7046            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
7047            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
7048            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7049                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7050                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
7051                            new String[] {
7052                                    Long.class.getName(), Integer.class.getName(),
7053                                    
7054                            Integer.class.getName(), Integer.class.getName(),
7055                                    OrderByComparator.class.getName()
7056                            });
7057            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7058                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7059                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
7060                            new String[] { Long.class.getName(), Integer.class.getName() },
7061                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
7062                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
7063                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
7064                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
7065            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7066                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7067                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
7068                            new String[] { Long.class.getName(), Integer.class.getName() });
7069    
7070            /**
7071             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
7072             *
7073             * @param groupId the group ID
7074             * @param status the status
7075             * @return the matching blogs entries
7076             * @throws SystemException if a system exception occurred
7077             */
7078            @Override
7079            public List<BlogsEntry> findByG_S(long groupId, int status)
7080                    throws SystemException {
7081                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7082                            null);
7083            }
7084    
7085            /**
7086             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
7087             *
7088             * <p>
7089             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7090             * </p>
7091             *
7092             * @param groupId the group ID
7093             * @param status the status
7094             * @param start the lower bound of the range of blogs entries
7095             * @param end the upper bound of the range of blogs entries (not inclusive)
7096             * @return the range of matching blogs entries
7097             * @throws SystemException if a system exception occurred
7098             */
7099            @Override
7100            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
7101                    int end) throws SystemException {
7102                    return findByG_S(groupId, status, start, end, null);
7103            }
7104    
7105            /**
7106             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
7107             *
7108             * <p>
7109             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7110             * </p>
7111             *
7112             * @param groupId the group ID
7113             * @param status the status
7114             * @param start the lower bound of the range of blogs entries
7115             * @param end the upper bound of the range of blogs entries (not inclusive)
7116             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7117             * @return the ordered range of matching blogs entries
7118             * @throws SystemException if a system exception occurred
7119             */
7120            @Override
7121            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
7122                    int end, OrderByComparator orderByComparator) throws SystemException {
7123                    boolean pagination = true;
7124                    FinderPath finderPath = null;
7125                    Object[] finderArgs = null;
7126    
7127                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7128                                    (orderByComparator == null)) {
7129                            pagination = false;
7130                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
7131                            finderArgs = new Object[] { groupId, status };
7132                    }
7133                    else {
7134                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
7135                            finderArgs = new Object[] {
7136                                            groupId, status,
7137                                            
7138                                            start, end, orderByComparator
7139                                    };
7140                    }
7141    
7142                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7143                                    finderArgs, this);
7144    
7145                    if ((list != null) && !list.isEmpty()) {
7146                            for (BlogsEntry blogsEntry : list) {
7147                                    if ((groupId != blogsEntry.getGroupId()) ||
7148                                                    (status != blogsEntry.getStatus())) {
7149                                            list = null;
7150    
7151                                            break;
7152                                    }
7153                            }
7154                    }
7155    
7156                    if (list == null) {
7157                            StringBundler query = null;
7158    
7159                            if (orderByComparator != null) {
7160                                    query = new StringBundler(4 +
7161                                                    (orderByComparator.getOrderByFields().length * 3));
7162                            }
7163                            else {
7164                                    query = new StringBundler(4);
7165                            }
7166    
7167                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7168    
7169                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7170    
7171                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
7172    
7173                            if (orderByComparator != null) {
7174                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7175                                            orderByComparator);
7176                            }
7177                            else
7178                             if (pagination) {
7179                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7180                            }
7181    
7182                            String sql = query.toString();
7183    
7184                            Session session = null;
7185    
7186                            try {
7187                                    session = openSession();
7188    
7189                                    Query q = session.createQuery(sql);
7190    
7191                                    QueryPos qPos = QueryPos.getInstance(q);
7192    
7193                                    qPos.add(groupId);
7194    
7195                                    qPos.add(status);
7196    
7197                                    if (!pagination) {
7198                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7199                                                            start, end, false);
7200    
7201                                            Collections.sort(list);
7202    
7203                                            list = new UnmodifiableList<BlogsEntry>(list);
7204                                    }
7205                                    else {
7206                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7207                                                            start, end);
7208                                    }
7209    
7210                                    cacheResult(list);
7211    
7212                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7213                            }
7214                            catch (Exception e) {
7215                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7216    
7217                                    throw processException(e);
7218                            }
7219                            finally {
7220                                    closeSession(session);
7221                            }
7222                    }
7223    
7224                    return list;
7225            }
7226    
7227            /**
7228             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7229             *
7230             * @param groupId the group ID
7231             * @param status the status
7232             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7233             * @return the first matching blogs entry
7234             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7235             * @throws SystemException if a system exception occurred
7236             */
7237            @Override
7238            public BlogsEntry findByG_S_First(long groupId, int status,
7239                    OrderByComparator orderByComparator)
7240                    throws NoSuchEntryException, SystemException {
7241                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
7242                                    orderByComparator);
7243    
7244                    if (blogsEntry != null) {
7245                            return blogsEntry;
7246                    }
7247    
7248                    StringBundler msg = new StringBundler(6);
7249    
7250                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7251    
7252                    msg.append("groupId=");
7253                    msg.append(groupId);
7254    
7255                    msg.append(", status=");
7256                    msg.append(status);
7257    
7258                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7259    
7260                    throw new NoSuchEntryException(msg.toString());
7261            }
7262    
7263            /**
7264             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7265             *
7266             * @param groupId the group ID
7267             * @param status the status
7268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7269             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7270             * @throws SystemException if a system exception occurred
7271             */
7272            @Override
7273            public BlogsEntry fetchByG_S_First(long groupId, int status,
7274                    OrderByComparator orderByComparator) throws SystemException {
7275                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
7276                                    orderByComparator);
7277    
7278                    if (!list.isEmpty()) {
7279                            return list.get(0);
7280                    }
7281    
7282                    return null;
7283            }
7284    
7285            /**
7286             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7287             *
7288             * @param groupId the group ID
7289             * @param status the status
7290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7291             * @return the last matching blogs entry
7292             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7293             * @throws SystemException if a system exception occurred
7294             */
7295            @Override
7296            public BlogsEntry findByG_S_Last(long groupId, int status,
7297                    OrderByComparator orderByComparator)
7298                    throws NoSuchEntryException, SystemException {
7299                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
7300                                    orderByComparator);
7301    
7302                    if (blogsEntry != null) {
7303                            return blogsEntry;
7304                    }
7305    
7306                    StringBundler msg = new StringBundler(6);
7307    
7308                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7309    
7310                    msg.append("groupId=");
7311                    msg.append(groupId);
7312    
7313                    msg.append(", status=");
7314                    msg.append(status);
7315    
7316                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7317    
7318                    throw new NoSuchEntryException(msg.toString());
7319            }
7320    
7321            /**
7322             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7323             *
7324             * @param groupId the group ID
7325             * @param status the status
7326             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7327             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7328             * @throws SystemException if a system exception occurred
7329             */
7330            @Override
7331            public BlogsEntry fetchByG_S_Last(long groupId, int status,
7332                    OrderByComparator orderByComparator) throws SystemException {
7333                    int count = countByG_S(groupId, status);
7334    
7335                    if (count == 0) {
7336                            return null;
7337                    }
7338    
7339                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
7340                                    orderByComparator);
7341    
7342                    if (!list.isEmpty()) {
7343                            return list.get(0);
7344                    }
7345    
7346                    return null;
7347            }
7348    
7349            /**
7350             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
7351             *
7352             * @param entryId the primary key of the current blogs entry
7353             * @param groupId the group ID
7354             * @param status the status
7355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7356             * @return the previous, current, and next blogs entry
7357             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7358             * @throws SystemException if a system exception occurred
7359             */
7360            @Override
7361            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
7362                    int status, OrderByComparator orderByComparator)
7363                    throws NoSuchEntryException, SystemException {
7364                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7365    
7366                    Session session = null;
7367    
7368                    try {
7369                            session = openSession();
7370    
7371                            BlogsEntry[] array = new BlogsEntryImpl[3];
7372    
7373                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
7374                                            status, orderByComparator, true);
7375    
7376                            array[1] = blogsEntry;
7377    
7378                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
7379                                            status, orderByComparator, false);
7380    
7381                            return array;
7382                    }
7383                    catch (Exception e) {
7384                            throw processException(e);
7385                    }
7386                    finally {
7387                            closeSession(session);
7388                    }
7389            }
7390    
7391            protected BlogsEntry getByG_S_PrevAndNext(Session session,
7392                    BlogsEntry blogsEntry, long groupId, int status,
7393                    OrderByComparator orderByComparator, boolean previous) {
7394                    StringBundler query = null;
7395    
7396                    if (orderByComparator != null) {
7397                            query = new StringBundler(6 +
7398                                            (orderByComparator.getOrderByFields().length * 6));
7399                    }
7400                    else {
7401                            query = new StringBundler(3);
7402                    }
7403    
7404                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7405    
7406                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7407    
7408                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7409    
7410                    if (orderByComparator != null) {
7411                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7412    
7413                            if (orderByConditionFields.length > 0) {
7414                                    query.append(WHERE_AND);
7415                            }
7416    
7417                            for (int i = 0; i < orderByConditionFields.length; i++) {
7418                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7419                                    query.append(orderByConditionFields[i]);
7420    
7421                                    if ((i + 1) < orderByConditionFields.length) {
7422                                            if (orderByComparator.isAscending() ^ previous) {
7423                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7424                                            }
7425                                            else {
7426                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7427                                            }
7428                                    }
7429                                    else {
7430                                            if (orderByComparator.isAscending() ^ previous) {
7431                                                    query.append(WHERE_GREATER_THAN);
7432                                            }
7433                                            else {
7434                                                    query.append(WHERE_LESSER_THAN);
7435                                            }
7436                                    }
7437                            }
7438    
7439                            query.append(ORDER_BY_CLAUSE);
7440    
7441                            String[] orderByFields = orderByComparator.getOrderByFields();
7442    
7443                            for (int i = 0; i < orderByFields.length; i++) {
7444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7445                                    query.append(orderByFields[i]);
7446    
7447                                    if ((i + 1) < orderByFields.length) {
7448                                            if (orderByComparator.isAscending() ^ previous) {
7449                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7450                                            }
7451                                            else {
7452                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7453                                            }
7454                                    }
7455                                    else {
7456                                            if (orderByComparator.isAscending() ^ previous) {
7457                                                    query.append(ORDER_BY_ASC);
7458                                            }
7459                                            else {
7460                                                    query.append(ORDER_BY_DESC);
7461                                            }
7462                                    }
7463                            }
7464                    }
7465                    else {
7466                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7467                    }
7468    
7469                    String sql = query.toString();
7470    
7471                    Query q = session.createQuery(sql);
7472    
7473                    q.setFirstResult(0);
7474                    q.setMaxResults(2);
7475    
7476                    QueryPos qPos = QueryPos.getInstance(q);
7477    
7478                    qPos.add(groupId);
7479    
7480                    qPos.add(status);
7481    
7482                    if (orderByComparator != null) {
7483                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7484    
7485                            for (Object value : values) {
7486                                    qPos.add(value);
7487                            }
7488                    }
7489    
7490                    List<BlogsEntry> list = q.list();
7491    
7492                    if (list.size() == 2) {
7493                            return list.get(1);
7494                    }
7495                    else {
7496                            return null;
7497                    }
7498            }
7499    
7500            /**
7501             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7502             *
7503             * @param groupId the group ID
7504             * @param status the status
7505             * @return the matching blogs entries that the user has permission to view
7506             * @throws SystemException if a system exception occurred
7507             */
7508            @Override
7509            public List<BlogsEntry> filterFindByG_S(long groupId, int status)
7510                    throws SystemException {
7511                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
7512                            QueryUtil.ALL_POS, null);
7513            }
7514    
7515            /**
7516             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7517             *
7518             * <p>
7519             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7520             * </p>
7521             *
7522             * @param groupId the group ID
7523             * @param status the status
7524             * @param start the lower bound of the range of blogs entries
7525             * @param end the upper bound of the range of blogs entries (not inclusive)
7526             * @return the range of matching blogs entries that the user has permission to view
7527             * @throws SystemException if a system exception occurred
7528             */
7529            @Override
7530            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7531                    int start, int end) throws SystemException {
7532                    return filterFindByG_S(groupId, status, start, end, null);
7533            }
7534    
7535            /**
7536             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
7537             *
7538             * <p>
7539             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7540             * </p>
7541             *
7542             * @param groupId the group ID
7543             * @param status the status
7544             * @param start the lower bound of the range of blogs entries
7545             * @param end the upper bound of the range of blogs entries (not inclusive)
7546             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7547             * @return the ordered range of matching blogs entries that the user has permission to view
7548             * @throws SystemException if a system exception occurred
7549             */
7550            @Override
7551            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
7552                    int start, int end, OrderByComparator orderByComparator)
7553                    throws SystemException {
7554                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7555                            return findByG_S(groupId, status, start, end, orderByComparator);
7556                    }
7557    
7558                    StringBundler query = null;
7559    
7560                    if (orderByComparator != null) {
7561                            query = new StringBundler(4 +
7562                                            (orderByComparator.getOrderByFields().length * 3));
7563                    }
7564                    else {
7565                            query = new StringBundler(4);
7566                    }
7567    
7568                    if (getDB().isSupportsInlineDistinct()) {
7569                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7570                    }
7571                    else {
7572                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7573                    }
7574    
7575                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7576    
7577                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7578    
7579                    if (!getDB().isSupportsInlineDistinct()) {
7580                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7581                    }
7582    
7583                    if (orderByComparator != null) {
7584                            if (getDB().isSupportsInlineDistinct()) {
7585                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7586                                            orderByComparator, true);
7587                            }
7588                            else {
7589                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7590                                            orderByComparator, true);
7591                            }
7592                    }
7593                    else {
7594                            if (getDB().isSupportsInlineDistinct()) {
7595                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7596                            }
7597                            else {
7598                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7599                            }
7600                    }
7601    
7602                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7603                                    BlogsEntry.class.getName(),
7604                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7605    
7606                    Session session = null;
7607    
7608                    try {
7609                            session = openSession();
7610    
7611                            SQLQuery q = session.createSQLQuery(sql);
7612    
7613                            if (getDB().isSupportsInlineDistinct()) {
7614                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7615                            }
7616                            else {
7617                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7618                            }
7619    
7620                            QueryPos qPos = QueryPos.getInstance(q);
7621    
7622                            qPos.add(groupId);
7623    
7624                            qPos.add(status);
7625    
7626                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
7627                    }
7628                    catch (Exception e) {
7629                            throw processException(e);
7630                    }
7631                    finally {
7632                            closeSession(session);
7633                    }
7634            }
7635    
7636            /**
7637             * 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;.
7638             *
7639             * @param entryId the primary key of the current blogs entry
7640             * @param groupId the group ID
7641             * @param status the status
7642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7643             * @return the previous, current, and next blogs entry
7644             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7645             * @throws SystemException if a system exception occurred
7646             */
7647            @Override
7648            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
7649                    int status, OrderByComparator orderByComparator)
7650                    throws NoSuchEntryException, SystemException {
7651                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7652                            return findByG_S_PrevAndNext(entryId, groupId, status,
7653                                    orderByComparator);
7654                    }
7655    
7656                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7657    
7658                    Session session = null;
7659    
7660                    try {
7661                            session = openSession();
7662    
7663                            BlogsEntry[] array = new BlogsEntryImpl[3];
7664    
7665                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7666                                            status, orderByComparator, true);
7667    
7668                            array[1] = blogsEntry;
7669    
7670                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
7671                                            status, orderByComparator, false);
7672    
7673                            return array;
7674                    }
7675                    catch (Exception e) {
7676                            throw processException(e);
7677                    }
7678                    finally {
7679                            closeSession(session);
7680                    }
7681            }
7682    
7683            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
7684                    BlogsEntry blogsEntry, long groupId, int status,
7685                    OrderByComparator orderByComparator, boolean previous) {
7686                    StringBundler query = null;
7687    
7688                    if (orderByComparator != null) {
7689                            query = new StringBundler(6 +
7690                                            (orderByComparator.getOrderByFields().length * 6));
7691                    }
7692                    else {
7693                            query = new StringBundler(3);
7694                    }
7695    
7696                    if (getDB().isSupportsInlineDistinct()) {
7697                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
7698                    }
7699                    else {
7700                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
7701                    }
7702    
7703                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7704    
7705                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7706    
7707                    if (!getDB().isSupportsInlineDistinct()) {
7708                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
7709                    }
7710    
7711                    if (orderByComparator != null) {
7712                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7713    
7714                            if (orderByConditionFields.length > 0) {
7715                                    query.append(WHERE_AND);
7716                            }
7717    
7718                            for (int i = 0; i < orderByConditionFields.length; i++) {
7719                                    if (getDB().isSupportsInlineDistinct()) {
7720                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7721                                    }
7722                                    else {
7723                                            query.append(_ORDER_BY_ENTITY_TABLE);
7724                                    }
7725    
7726                                    query.append(orderByConditionFields[i]);
7727    
7728                                    if ((i + 1) < orderByConditionFields.length) {
7729                                            if (orderByComparator.isAscending() ^ previous) {
7730                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7731                                            }
7732                                            else {
7733                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7734                                            }
7735                                    }
7736                                    else {
7737                                            if (orderByComparator.isAscending() ^ previous) {
7738                                                    query.append(WHERE_GREATER_THAN);
7739                                            }
7740                                            else {
7741                                                    query.append(WHERE_LESSER_THAN);
7742                                            }
7743                                    }
7744                            }
7745    
7746                            query.append(ORDER_BY_CLAUSE);
7747    
7748                            String[] orderByFields = orderByComparator.getOrderByFields();
7749    
7750                            for (int i = 0; i < orderByFields.length; i++) {
7751                                    if (getDB().isSupportsInlineDistinct()) {
7752                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7753                                    }
7754                                    else {
7755                                            query.append(_ORDER_BY_ENTITY_TABLE);
7756                                    }
7757    
7758                                    query.append(orderByFields[i]);
7759    
7760                                    if ((i + 1) < orderByFields.length) {
7761                                            if (orderByComparator.isAscending() ^ previous) {
7762                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7763                                            }
7764                                            else {
7765                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7766                                            }
7767                                    }
7768                                    else {
7769                                            if (orderByComparator.isAscending() ^ previous) {
7770                                                    query.append(ORDER_BY_ASC);
7771                                            }
7772                                            else {
7773                                                    query.append(ORDER_BY_DESC);
7774                                            }
7775                                    }
7776                            }
7777                    }
7778                    else {
7779                            if (getDB().isSupportsInlineDistinct()) {
7780                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7781                            }
7782                            else {
7783                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
7784                            }
7785                    }
7786    
7787                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7788                                    BlogsEntry.class.getName(),
7789                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7790    
7791                    SQLQuery q = session.createSQLQuery(sql);
7792    
7793                    q.setFirstResult(0);
7794                    q.setMaxResults(2);
7795    
7796                    if (getDB().isSupportsInlineDistinct()) {
7797                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
7798                    }
7799                    else {
7800                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
7801                    }
7802    
7803                    QueryPos qPos = QueryPos.getInstance(q);
7804    
7805                    qPos.add(groupId);
7806    
7807                    qPos.add(status);
7808    
7809                    if (orderByComparator != null) {
7810                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7811    
7812                            for (Object value : values) {
7813                                    qPos.add(value);
7814                            }
7815                    }
7816    
7817                    List<BlogsEntry> list = q.list();
7818    
7819                    if (list.size() == 2) {
7820                            return list.get(1);
7821                    }
7822                    else {
7823                            return null;
7824                    }
7825            }
7826    
7827            /**
7828             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
7829             *
7830             * @param groupId the group ID
7831             * @param status the status
7832             * @throws SystemException if a system exception occurred
7833             */
7834            @Override
7835            public void removeByG_S(long groupId, int status) throws SystemException {
7836                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
7837                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7838                            remove(blogsEntry);
7839                    }
7840            }
7841    
7842            /**
7843             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
7844             *
7845             * @param groupId the group ID
7846             * @param status the status
7847             * @return the number of matching blogs entries
7848             * @throws SystemException if a system exception occurred
7849             */
7850            @Override
7851            public int countByG_S(long groupId, int status) throws SystemException {
7852                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
7853    
7854                    Object[] finderArgs = new Object[] { groupId, status };
7855    
7856                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7857                                    this);
7858    
7859                    if (count == null) {
7860                            StringBundler query = new StringBundler(3);
7861    
7862                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7863    
7864                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7865    
7866                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
7867    
7868                            String sql = query.toString();
7869    
7870                            Session session = null;
7871    
7872                            try {
7873                                    session = openSession();
7874    
7875                                    Query q = session.createQuery(sql);
7876    
7877                                    QueryPos qPos = QueryPos.getInstance(q);
7878    
7879                                    qPos.add(groupId);
7880    
7881                                    qPos.add(status);
7882    
7883                                    count = (Long)q.uniqueResult();
7884    
7885                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7886                            }
7887                            catch (Exception e) {
7888                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7889    
7890                                    throw processException(e);
7891                            }
7892                            finally {
7893                                    closeSession(session);
7894                            }
7895                    }
7896    
7897                    return count.intValue();
7898            }
7899    
7900            /**
7901             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
7902             *
7903             * @param groupId the group ID
7904             * @param status the status
7905             * @return the number of matching blogs entries that the user has permission to view
7906             * @throws SystemException if a system exception occurred
7907             */
7908            @Override
7909            public int filterCountByG_S(long groupId, int status)
7910                    throws SystemException {
7911                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7912                            return countByG_S(groupId, status);
7913                    }
7914    
7915                    StringBundler query = new StringBundler(3);
7916    
7917                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
7918    
7919                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
7920    
7921                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
7922    
7923                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7924                                    BlogsEntry.class.getName(),
7925                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7926    
7927                    Session session = null;
7928    
7929                    try {
7930                            session = openSession();
7931    
7932                            SQLQuery q = session.createSQLQuery(sql);
7933    
7934                            q.addScalar(COUNT_COLUMN_NAME,
7935                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7936    
7937                            QueryPos qPos = QueryPos.getInstance(q);
7938    
7939                            qPos.add(groupId);
7940    
7941                            qPos.add(status);
7942    
7943                            Long count = (Long)q.uniqueResult();
7944    
7945                            return count.intValue();
7946                    }
7947                    catch (Exception e) {
7948                            throw processException(e);
7949                    }
7950                    finally {
7951                            closeSession(session);
7952                    }
7953            }
7954    
7955            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
7956            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
7957            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7958                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7959                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
7960                            new String[] {
7961                                    Date.class.getName(), Integer.class.getName(),
7962                                    
7963                            Integer.class.getName(), Integer.class.getName(),
7964                                    OrderByComparator.class.getName()
7965                            });
7966            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7967                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7968                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
7969                            new String[] { Date.class.getName(), Integer.class.getName() });
7970    
7971            /**
7972             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7973             *
7974             * @param displayDate the display date
7975             * @param status the status
7976             * @return the matching blogs entries
7977             * @throws SystemException if a system exception occurred
7978             */
7979            @Override
7980            public List<BlogsEntry> findByLtD_S(Date displayDate, int status)
7981                    throws SystemException {
7982                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
7983                            QueryUtil.ALL_POS, null);
7984            }
7985    
7986            /**
7987             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7988             *
7989             * <p>
7990             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7991             * </p>
7992             *
7993             * @param displayDate the display date
7994             * @param status the status
7995             * @param start the lower bound of the range of blogs entries
7996             * @param end the upper bound of the range of blogs entries (not inclusive)
7997             * @return the range of matching blogs entries
7998             * @throws SystemException if a system exception occurred
7999             */
8000            @Override
8001            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8002                    int start, int end) throws SystemException {
8003                    return findByLtD_S(displayDate, status, start, end, null);
8004            }
8005    
8006            /**
8007             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8008             *
8009             * <p>
8010             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8011             * </p>
8012             *
8013             * @param displayDate the display date
8014             * @param status the status
8015             * @param start the lower bound of the range of blogs entries
8016             * @param end the upper bound of the range of blogs entries (not inclusive)
8017             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8018             * @return the ordered range of matching blogs entries
8019             * @throws SystemException if a system exception occurred
8020             */
8021            @Override
8022            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8023                    int start, int end, OrderByComparator orderByComparator)
8024                    throws SystemException {
8025                    boolean pagination = true;
8026                    FinderPath finderPath = null;
8027                    Object[] finderArgs = null;
8028    
8029                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
8030                    finderArgs = new Object[] {
8031                                    displayDate, status,
8032                                    
8033                                    start, end, orderByComparator
8034                            };
8035    
8036                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8037                                    finderArgs, this);
8038    
8039                    if ((list != null) && !list.isEmpty()) {
8040                            for (BlogsEntry blogsEntry : list) {
8041                                    if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
8042                                                                                                                            .getTime()) ||
8043                                                    (status != blogsEntry.getStatus())) {
8044                                            list = null;
8045    
8046                                            break;
8047                                    }
8048                            }
8049                    }
8050    
8051                    if (list == null) {
8052                            StringBundler query = null;
8053    
8054                            if (orderByComparator != null) {
8055                                    query = new StringBundler(4 +
8056                                                    (orderByComparator.getOrderByFields().length * 3));
8057                            }
8058                            else {
8059                                    query = new StringBundler(4);
8060                            }
8061    
8062                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8063    
8064                            boolean bindDisplayDate = false;
8065    
8066                            if (displayDate == null) {
8067                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8068                            }
8069                            else {
8070                                    bindDisplayDate = true;
8071    
8072                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8073                            }
8074    
8075                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8076    
8077                            if (orderByComparator != null) {
8078                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8079                                            orderByComparator);
8080                            }
8081                            else
8082                             if (pagination) {
8083                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8084                            }
8085    
8086                            String sql = query.toString();
8087    
8088                            Session session = null;
8089    
8090                            try {
8091                                    session = openSession();
8092    
8093                                    Query q = session.createQuery(sql);
8094    
8095                                    QueryPos qPos = QueryPos.getInstance(q);
8096    
8097                                    if (bindDisplayDate) {
8098                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8099                                    }
8100    
8101                                    qPos.add(status);
8102    
8103                                    if (!pagination) {
8104                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8105                                                            start, end, false);
8106    
8107                                            Collections.sort(list);
8108    
8109                                            list = new UnmodifiableList<BlogsEntry>(list);
8110                                    }
8111                                    else {
8112                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8113                                                            start, end);
8114                                    }
8115    
8116                                    cacheResult(list);
8117    
8118                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8119                            }
8120                            catch (Exception e) {
8121                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8122    
8123                                    throw processException(e);
8124                            }
8125                            finally {
8126                                    closeSession(session);
8127                            }
8128                    }
8129    
8130                    return list;
8131            }
8132    
8133            /**
8134             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8135             *
8136             * @param displayDate the display date
8137             * @param status the status
8138             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8139             * @return the first matching blogs entry
8140             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8141             * @throws SystemException if a system exception occurred
8142             */
8143            @Override
8144            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8145                    OrderByComparator orderByComparator)
8146                    throws NoSuchEntryException, SystemException {
8147                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8148                                    orderByComparator);
8149    
8150                    if (blogsEntry != null) {
8151                            return blogsEntry;
8152                    }
8153    
8154                    StringBundler msg = new StringBundler(6);
8155    
8156                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8157    
8158                    msg.append("displayDate=");
8159                    msg.append(displayDate);
8160    
8161                    msg.append(", status=");
8162                    msg.append(status);
8163    
8164                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8165    
8166                    throw new NoSuchEntryException(msg.toString());
8167            }
8168    
8169            /**
8170             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8171             *
8172             * @param displayDate the display date
8173             * @param status the status
8174             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8175             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8176             * @throws SystemException if a system exception occurred
8177             */
8178            @Override
8179            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8180                    OrderByComparator orderByComparator) throws SystemException {
8181                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8182                                    orderByComparator);
8183    
8184                    if (!list.isEmpty()) {
8185                            return list.get(0);
8186                    }
8187    
8188                    return null;
8189            }
8190    
8191            /**
8192             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8193             *
8194             * @param displayDate the display date
8195             * @param status the status
8196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8197             * @return the last matching blogs entry
8198             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8199             * @throws SystemException if a system exception occurred
8200             */
8201            @Override
8202            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8203                    OrderByComparator orderByComparator)
8204                    throws NoSuchEntryException, SystemException {
8205                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8206                                    orderByComparator);
8207    
8208                    if (blogsEntry != null) {
8209                            return blogsEntry;
8210                    }
8211    
8212                    StringBundler msg = new StringBundler(6);
8213    
8214                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8215    
8216                    msg.append("displayDate=");
8217                    msg.append(displayDate);
8218    
8219                    msg.append(", status=");
8220                    msg.append(status);
8221    
8222                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8223    
8224                    throw new NoSuchEntryException(msg.toString());
8225            }
8226    
8227            /**
8228             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8229             *
8230             * @param displayDate the display date
8231             * @param status the status
8232             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8233             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8234             * @throws SystemException if a system exception occurred
8235             */
8236            @Override
8237            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8238                    OrderByComparator orderByComparator) throws SystemException {
8239                    int count = countByLtD_S(displayDate, status);
8240    
8241                    if (count == 0) {
8242                            return null;
8243                    }
8244    
8245                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8246                                    count, orderByComparator);
8247    
8248                    if (!list.isEmpty()) {
8249                            return list.get(0);
8250                    }
8251    
8252                    return null;
8253            }
8254    
8255            /**
8256             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8257             *
8258             * @param entryId the primary key of the current blogs entry
8259             * @param displayDate the display date
8260             * @param status the status
8261             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8262             * @return the previous, current, and next blogs entry
8263             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8264             * @throws SystemException if a system exception occurred
8265             */
8266            @Override
8267            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8268                    int status, OrderByComparator orderByComparator)
8269                    throws NoSuchEntryException, SystemException {
8270                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8271    
8272                    Session session = null;
8273    
8274                    try {
8275                            session = openSession();
8276    
8277                            BlogsEntry[] array = new BlogsEntryImpl[3];
8278    
8279                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8280                                            status, orderByComparator, true);
8281    
8282                            array[1] = blogsEntry;
8283    
8284                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8285                                            status, orderByComparator, false);
8286    
8287                            return array;
8288                    }
8289                    catch (Exception e) {
8290                            throw processException(e);
8291                    }
8292                    finally {
8293                            closeSession(session);
8294                    }
8295            }
8296    
8297            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8298                    BlogsEntry blogsEntry, Date displayDate, int status,
8299                    OrderByComparator orderByComparator, boolean previous) {
8300                    StringBundler query = null;
8301    
8302                    if (orderByComparator != null) {
8303                            query = new StringBundler(6 +
8304                                            (orderByComparator.getOrderByFields().length * 6));
8305                    }
8306                    else {
8307                            query = new StringBundler(3);
8308                    }
8309    
8310                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8311    
8312                    boolean bindDisplayDate = false;
8313    
8314                    if (displayDate == null) {
8315                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8316                    }
8317                    else {
8318                            bindDisplayDate = true;
8319    
8320                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8321                    }
8322    
8323                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8324    
8325                    if (orderByComparator != null) {
8326                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8327    
8328                            if (orderByConditionFields.length > 0) {
8329                                    query.append(WHERE_AND);
8330                            }
8331    
8332                            for (int i = 0; i < orderByConditionFields.length; i++) {
8333                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8334                                    query.append(orderByConditionFields[i]);
8335    
8336                                    if ((i + 1) < orderByConditionFields.length) {
8337                                            if (orderByComparator.isAscending() ^ previous) {
8338                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8339                                            }
8340                                            else {
8341                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8342                                            }
8343                                    }
8344                                    else {
8345                                            if (orderByComparator.isAscending() ^ previous) {
8346                                                    query.append(WHERE_GREATER_THAN);
8347                                            }
8348                                            else {
8349                                                    query.append(WHERE_LESSER_THAN);
8350                                            }
8351                                    }
8352                            }
8353    
8354                            query.append(ORDER_BY_CLAUSE);
8355    
8356                            String[] orderByFields = orderByComparator.getOrderByFields();
8357    
8358                            for (int i = 0; i < orderByFields.length; i++) {
8359                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8360                                    query.append(orderByFields[i]);
8361    
8362                                    if ((i + 1) < orderByFields.length) {
8363                                            if (orderByComparator.isAscending() ^ previous) {
8364                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8365                                            }
8366                                            else {
8367                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8368                                            }
8369                                    }
8370                                    else {
8371                                            if (orderByComparator.isAscending() ^ previous) {
8372                                                    query.append(ORDER_BY_ASC);
8373                                            }
8374                                            else {
8375                                                    query.append(ORDER_BY_DESC);
8376                                            }
8377                                    }
8378                            }
8379                    }
8380                    else {
8381                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8382                    }
8383    
8384                    String sql = query.toString();
8385    
8386                    Query q = session.createQuery(sql);
8387    
8388                    q.setFirstResult(0);
8389                    q.setMaxResults(2);
8390    
8391                    QueryPos qPos = QueryPos.getInstance(q);
8392    
8393                    if (bindDisplayDate) {
8394                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8395                    }
8396    
8397                    qPos.add(status);
8398    
8399                    if (orderByComparator != null) {
8400                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8401    
8402                            for (Object value : values) {
8403                                    qPos.add(value);
8404                            }
8405                    }
8406    
8407                    List<BlogsEntry> list = q.list();
8408    
8409                    if (list.size() == 2) {
8410                            return list.get(1);
8411                    }
8412                    else {
8413                            return null;
8414                    }
8415            }
8416    
8417            /**
8418             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8419             *
8420             * @param displayDate the display date
8421             * @param status the status
8422             * @throws SystemException if a system exception occurred
8423             */
8424            @Override
8425            public void removeByLtD_S(Date displayDate, int status)
8426                    throws SystemException {
8427                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8428                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8429                            remove(blogsEntry);
8430                    }
8431            }
8432    
8433            /**
8434             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8435             *
8436             * @param displayDate the display date
8437             * @param status the status
8438             * @return the number of matching blogs entries
8439             * @throws SystemException if a system exception occurred
8440             */
8441            @Override
8442            public int countByLtD_S(Date displayDate, int status)
8443                    throws SystemException {
8444                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8445    
8446                    Object[] finderArgs = new Object[] { displayDate, status };
8447    
8448                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8449                                    this);
8450    
8451                    if (count == null) {
8452                            StringBundler query = new StringBundler(3);
8453    
8454                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8455    
8456                            boolean bindDisplayDate = false;
8457    
8458                            if (displayDate == null) {
8459                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8460                            }
8461                            else {
8462                                    bindDisplayDate = true;
8463    
8464                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8465                            }
8466    
8467                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8468    
8469                            String sql = query.toString();
8470    
8471                            Session session = null;
8472    
8473                            try {
8474                                    session = openSession();
8475    
8476                                    Query q = session.createQuery(sql);
8477    
8478                                    QueryPos qPos = QueryPos.getInstance(q);
8479    
8480                                    if (bindDisplayDate) {
8481                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8482                                    }
8483    
8484                                    qPos.add(status);
8485    
8486                                    count = (Long)q.uniqueResult();
8487    
8488                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8489                            }
8490                            catch (Exception e) {
8491                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8492    
8493                                    throw processException(e);
8494                            }
8495                            finally {
8496                                    closeSession(session);
8497                            }
8498                    }
8499    
8500                    return count.intValue();
8501            }
8502    
8503            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
8504            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8505            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8506            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8507                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8508                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
8509                            new String[] {
8510                                    Long.class.getName(), Long.class.getName(),
8511                                    Integer.class.getName(),
8512                                    
8513                            Integer.class.getName(), Integer.class.getName(),
8514                                    OrderByComparator.class.getName()
8515                            });
8516            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
8517                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8518                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8519                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
8520                            new String[] {
8521                                    Long.class.getName(), Long.class.getName(),
8522                                    Integer.class.getName()
8523                            });
8524    
8525            /**
8526             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8527             *
8528             * @param companyId the company ID
8529             * @param userId the user ID
8530             * @param status the status
8531             * @return the matching blogs entries
8532             * @throws SystemException if a system exception occurred
8533             */
8534            @Override
8535            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8536                    int status) throws SystemException {
8537                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
8538                            QueryUtil.ALL_POS, null);
8539            }
8540    
8541            /**
8542             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8543             *
8544             * <p>
8545             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8546             * </p>
8547             *
8548             * @param companyId the company ID
8549             * @param userId the user ID
8550             * @param status the status
8551             * @param start the lower bound of the range of blogs entries
8552             * @param end the upper bound of the range of blogs entries (not inclusive)
8553             * @return the range of matching blogs entries
8554             * @throws SystemException if a system exception occurred
8555             */
8556            @Override
8557            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8558                    int status, int start, int end) throws SystemException {
8559                    return findByC_U_NotS(companyId, userId, status, start, end, null);
8560            }
8561    
8562            /**
8563             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8564             *
8565             * <p>
8566             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8567             * </p>
8568             *
8569             * @param companyId the company ID
8570             * @param userId the user ID
8571             * @param status the status
8572             * @param start the lower bound of the range of blogs entries
8573             * @param end the upper bound of the range of blogs entries (not inclusive)
8574             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8575             * @return the ordered range of matching blogs entries
8576             * @throws SystemException if a system exception occurred
8577             */
8578            @Override
8579            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8580                    int status, int start, int end, OrderByComparator orderByComparator)
8581                    throws SystemException {
8582                    boolean pagination = true;
8583                    FinderPath finderPath = null;
8584                    Object[] finderArgs = null;
8585    
8586                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
8587                    finderArgs = new Object[] {
8588                                    companyId, userId, status,
8589                                    
8590                                    start, end, orderByComparator
8591                            };
8592    
8593                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8594                                    finderArgs, this);
8595    
8596                    if ((list != null) && !list.isEmpty()) {
8597                            for (BlogsEntry blogsEntry : list) {
8598                                    if ((companyId != blogsEntry.getCompanyId()) ||
8599                                                    (userId != blogsEntry.getUserId()) ||
8600                                                    (status == blogsEntry.getStatus())) {
8601                                            list = null;
8602    
8603                                            break;
8604                                    }
8605                            }
8606                    }
8607    
8608                    if (list == null) {
8609                            StringBundler query = null;
8610    
8611                            if (orderByComparator != null) {
8612                                    query = new StringBundler(5 +
8613                                                    (orderByComparator.getOrderByFields().length * 3));
8614                            }
8615                            else {
8616                                    query = new StringBundler(5);
8617                            }
8618    
8619                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8620    
8621                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8622    
8623                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8624    
8625                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8626    
8627                            if (orderByComparator != null) {
8628                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8629                                            orderByComparator);
8630                            }
8631                            else
8632                             if (pagination) {
8633                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8634                            }
8635    
8636                            String sql = query.toString();
8637    
8638                            Session session = null;
8639    
8640                            try {
8641                                    session = openSession();
8642    
8643                                    Query q = session.createQuery(sql);
8644    
8645                                    QueryPos qPos = QueryPos.getInstance(q);
8646    
8647                                    qPos.add(companyId);
8648    
8649                                    qPos.add(userId);
8650    
8651                                    qPos.add(status);
8652    
8653                                    if (!pagination) {
8654                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8655                                                            start, end, false);
8656    
8657                                            Collections.sort(list);
8658    
8659                                            list = new UnmodifiableList<BlogsEntry>(list);
8660                                    }
8661                                    else {
8662                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8663                                                            start, end);
8664                                    }
8665    
8666                                    cacheResult(list);
8667    
8668                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8669                            }
8670                            catch (Exception e) {
8671                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8672    
8673                                    throw processException(e);
8674                            }
8675                            finally {
8676                                    closeSession(session);
8677                            }
8678                    }
8679    
8680                    return list;
8681            }
8682    
8683            /**
8684             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8685             *
8686             * @param companyId the company ID
8687             * @param userId the user ID
8688             * @param status the status
8689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8690             * @return the first matching blogs entry
8691             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8692             * @throws SystemException if a system exception occurred
8693             */
8694            @Override
8695            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
8696                    int status, OrderByComparator orderByComparator)
8697                    throws NoSuchEntryException, SystemException {
8698                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
8699                                    status, orderByComparator);
8700    
8701                    if (blogsEntry != null) {
8702                            return blogsEntry;
8703                    }
8704    
8705                    StringBundler msg = new StringBundler(8);
8706    
8707                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8708    
8709                    msg.append("companyId=");
8710                    msg.append(companyId);
8711    
8712                    msg.append(", userId=");
8713                    msg.append(userId);
8714    
8715                    msg.append(", status=");
8716                    msg.append(status);
8717    
8718                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8719    
8720                    throw new NoSuchEntryException(msg.toString());
8721            }
8722    
8723            /**
8724             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8725             *
8726             * @param companyId the company ID
8727             * @param userId the user ID
8728             * @param status the status
8729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8730             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8731             * @throws SystemException if a system exception occurred
8732             */
8733            @Override
8734            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
8735                    int status, OrderByComparator orderByComparator)
8736                    throws SystemException {
8737                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
8738                                    orderByComparator);
8739    
8740                    if (!list.isEmpty()) {
8741                            return list.get(0);
8742                    }
8743    
8744                    return null;
8745            }
8746    
8747            /**
8748             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8749             *
8750             * @param companyId the company ID
8751             * @param userId the user ID
8752             * @param status the status
8753             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8754             * @return the last matching blogs entry
8755             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8756             * @throws SystemException if a system exception occurred
8757             */
8758            @Override
8759            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
8760                    int status, OrderByComparator orderByComparator)
8761                    throws NoSuchEntryException, SystemException {
8762                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
8763                                    orderByComparator);
8764    
8765                    if (blogsEntry != null) {
8766                            return blogsEntry;
8767                    }
8768    
8769                    StringBundler msg = new StringBundler(8);
8770    
8771                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8772    
8773                    msg.append("companyId=");
8774                    msg.append(companyId);
8775    
8776                    msg.append(", userId=");
8777                    msg.append(userId);
8778    
8779                    msg.append(", status=");
8780                    msg.append(status);
8781    
8782                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8783    
8784                    throw new NoSuchEntryException(msg.toString());
8785            }
8786    
8787            /**
8788             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8789             *
8790             * @param companyId the company ID
8791             * @param userId the user ID
8792             * @param status the status
8793             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8794             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8795             * @throws SystemException if a system exception occurred
8796             */
8797            @Override
8798            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
8799                    int status, OrderByComparator orderByComparator)
8800                    throws SystemException {
8801                    int count = countByC_U_NotS(companyId, userId, status);
8802    
8803                    if (count == 0) {
8804                            return null;
8805                    }
8806    
8807                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
8808                                    count - 1, count, orderByComparator);
8809    
8810                    if (!list.isEmpty()) {
8811                            return list.get(0);
8812                    }
8813    
8814                    return null;
8815            }
8816    
8817            /**
8818             * 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;.
8819             *
8820             * @param entryId the primary key of the current blogs entry
8821             * @param companyId the company ID
8822             * @param userId the user ID
8823             * @param status the status
8824             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8825             * @return the previous, current, and next blogs entry
8826             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8827             * @throws SystemException if a system exception occurred
8828             */
8829            @Override
8830            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
8831                    long companyId, long userId, int status,
8832                    OrderByComparator orderByComparator)
8833                    throws NoSuchEntryException, SystemException {
8834                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8835    
8836                    Session session = null;
8837    
8838                    try {
8839                            session = openSession();
8840    
8841                            BlogsEntry[] array = new BlogsEntryImpl[3];
8842    
8843                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8844                                            companyId, userId, status, orderByComparator, true);
8845    
8846                            array[1] = blogsEntry;
8847    
8848                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8849                                            companyId, userId, status, orderByComparator, false);
8850    
8851                            return array;
8852                    }
8853                    catch (Exception e) {
8854                            throw processException(e);
8855                    }
8856                    finally {
8857                            closeSession(session);
8858                    }
8859            }
8860    
8861            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
8862                    BlogsEntry blogsEntry, long companyId, long userId, int status,
8863                    OrderByComparator orderByComparator, boolean previous) {
8864                    StringBundler query = null;
8865    
8866                    if (orderByComparator != null) {
8867                            query = new StringBundler(6 +
8868                                            (orderByComparator.getOrderByFields().length * 6));
8869                    }
8870                    else {
8871                            query = new StringBundler(3);
8872                    }
8873    
8874                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8875    
8876                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8877    
8878                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8879    
8880                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8881    
8882                    if (orderByComparator != null) {
8883                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8884    
8885                            if (orderByConditionFields.length > 0) {
8886                                    query.append(WHERE_AND);
8887                            }
8888    
8889                            for (int i = 0; i < orderByConditionFields.length; i++) {
8890                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8891                                    query.append(orderByConditionFields[i]);
8892    
8893                                    if ((i + 1) < orderByConditionFields.length) {
8894                                            if (orderByComparator.isAscending() ^ previous) {
8895                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8896                                            }
8897                                            else {
8898                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8899                                            }
8900                                    }
8901                                    else {
8902                                            if (orderByComparator.isAscending() ^ previous) {
8903                                                    query.append(WHERE_GREATER_THAN);
8904                                            }
8905                                            else {
8906                                                    query.append(WHERE_LESSER_THAN);
8907                                            }
8908                                    }
8909                            }
8910    
8911                            query.append(ORDER_BY_CLAUSE);
8912    
8913                            String[] orderByFields = orderByComparator.getOrderByFields();
8914    
8915                            for (int i = 0; i < orderByFields.length; i++) {
8916                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8917                                    query.append(orderByFields[i]);
8918    
8919                                    if ((i + 1) < orderByFields.length) {
8920                                            if (orderByComparator.isAscending() ^ previous) {
8921                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8922                                            }
8923                                            else {
8924                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8925                                            }
8926                                    }
8927                                    else {
8928                                            if (orderByComparator.isAscending() ^ previous) {
8929                                                    query.append(ORDER_BY_ASC);
8930                                            }
8931                                            else {
8932                                                    query.append(ORDER_BY_DESC);
8933                                            }
8934                                    }
8935                            }
8936                    }
8937                    else {
8938                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8939                    }
8940    
8941                    String sql = query.toString();
8942    
8943                    Query q = session.createQuery(sql);
8944    
8945                    q.setFirstResult(0);
8946                    q.setMaxResults(2);
8947    
8948                    QueryPos qPos = QueryPos.getInstance(q);
8949    
8950                    qPos.add(companyId);
8951    
8952                    qPos.add(userId);
8953    
8954                    qPos.add(status);
8955    
8956                    if (orderByComparator != null) {
8957                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8958    
8959                            for (Object value : values) {
8960                                    qPos.add(value);
8961                            }
8962                    }
8963    
8964                    List<BlogsEntry> list = q.list();
8965    
8966                    if (list.size() == 2) {
8967                            return list.get(1);
8968                    }
8969                    else {
8970                            return null;
8971                    }
8972            }
8973    
8974            /**
8975             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
8976             *
8977             * @param companyId the company ID
8978             * @param userId the user ID
8979             * @param status the status
8980             * @throws SystemException if a system exception occurred
8981             */
8982            @Override
8983            public void removeByC_U_NotS(long companyId, long userId, int status)
8984                    throws SystemException {
8985                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
8986                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8987                            remove(blogsEntry);
8988                    }
8989            }
8990    
8991            /**
8992             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8993             *
8994             * @param companyId the company ID
8995             * @param userId the user ID
8996             * @param status the status
8997             * @return the number of matching blogs entries
8998             * @throws SystemException if a system exception occurred
8999             */
9000            @Override
9001            public int countByC_U_NotS(long companyId, long userId, int status)
9002                    throws SystemException {
9003                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
9004    
9005                    Object[] finderArgs = new Object[] { companyId, userId, status };
9006    
9007                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9008                                    this);
9009    
9010                    if (count == null) {
9011                            StringBundler query = new StringBundler(4);
9012    
9013                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9014    
9015                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
9016    
9017                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
9018    
9019                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
9020    
9021                            String sql = query.toString();
9022    
9023                            Session session = null;
9024    
9025                            try {
9026                                    session = openSession();
9027    
9028                                    Query q = session.createQuery(sql);
9029    
9030                                    QueryPos qPos = QueryPos.getInstance(q);
9031    
9032                                    qPos.add(companyId);
9033    
9034                                    qPos.add(userId);
9035    
9036                                    qPos.add(status);
9037    
9038                                    count = (Long)q.uniqueResult();
9039    
9040                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9041                            }
9042                            catch (Exception e) {
9043                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9044    
9045                                    throw processException(e);
9046                            }
9047                            finally {
9048                                    closeSession(session);
9049                            }
9050                    }
9051    
9052                    return count.intValue();
9053            }
9054    
9055            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9056            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
9057            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
9058            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9059                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9060                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
9061                            new String[] {
9062                                    Long.class.getName(), Long.class.getName(),
9063                                    Integer.class.getName(),
9064                                    
9065                            Integer.class.getName(), Integer.class.getName(),
9066                                    OrderByComparator.class.getName()
9067                            });
9068            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9069                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9070                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
9071                            new String[] {
9072                                    Long.class.getName(), Long.class.getName(),
9073                                    Integer.class.getName()
9074                            },
9075                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
9076                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9077                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9078                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9079                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9080            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9081                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9082                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
9083                            new String[] {
9084                                    Long.class.getName(), Long.class.getName(),
9085                                    Integer.class.getName()
9086                            });
9087    
9088            /**
9089             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9090             *
9091             * @param companyId the company ID
9092             * @param userId the user ID
9093             * @param status the status
9094             * @return the matching blogs entries
9095             * @throws SystemException if a system exception occurred
9096             */
9097            @Override
9098            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status)
9099                    throws SystemException {
9100                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
9101                            QueryUtil.ALL_POS, null);
9102            }
9103    
9104            /**
9105             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9106             *
9107             * <p>
9108             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9109             * </p>
9110             *
9111             * @param companyId the company ID
9112             * @param userId the user ID
9113             * @param status the status
9114             * @param start the lower bound of the range of blogs entries
9115             * @param end the upper bound of the range of blogs entries (not inclusive)
9116             * @return the range of matching blogs entries
9117             * @throws SystemException if a system exception occurred
9118             */
9119            @Override
9120            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
9121                    int status, int start, int end) throws SystemException {
9122                    return findByC_U_S(companyId, userId, status, start, end, null);
9123            }
9124    
9125            /**
9126             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9127             *
9128             * <p>
9129             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9130             * </p>
9131             *
9132             * @param companyId the company ID
9133             * @param userId the user ID
9134             * @param status the status
9135             * @param start the lower bound of the range of blogs entries
9136             * @param end the upper bound of the range of blogs entries (not inclusive)
9137             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9138             * @return the ordered range of matching blogs entries
9139             * @throws SystemException if a system exception occurred
9140             */
9141            @Override
9142            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
9143                    int status, int start, int end, OrderByComparator orderByComparator)
9144                    throws SystemException {
9145                    boolean pagination = true;
9146                    FinderPath finderPath = null;
9147                    Object[] finderArgs = null;
9148    
9149                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9150                                    (orderByComparator == null)) {
9151                            pagination = false;
9152                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
9153                            finderArgs = new Object[] { companyId, userId, status };
9154                    }
9155                    else {
9156                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
9157                            finderArgs = new Object[] {
9158                                            companyId, userId, status,
9159                                            
9160                                            start, end, orderByComparator
9161                                    };
9162                    }
9163    
9164                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9165                                    finderArgs, this);
9166    
9167                    if ((list != null) && !list.isEmpty()) {
9168                            for (BlogsEntry blogsEntry : list) {
9169                                    if ((companyId != blogsEntry.getCompanyId()) ||
9170                                                    (userId != blogsEntry.getUserId()) ||
9171                                                    (status != blogsEntry.getStatus())) {
9172                                            list = null;
9173    
9174                                            break;
9175                                    }
9176                            }
9177                    }
9178    
9179                    if (list == null) {
9180                            StringBundler query = null;
9181    
9182                            if (orderByComparator != null) {
9183                                    query = new StringBundler(5 +
9184                                                    (orderByComparator.getOrderByFields().length * 3));
9185                            }
9186                            else {
9187                                    query = new StringBundler(5);
9188                            }
9189    
9190                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9191    
9192                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9193    
9194                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9195    
9196                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9197    
9198                            if (orderByComparator != null) {
9199                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9200                                            orderByComparator);
9201                            }
9202                            else
9203                             if (pagination) {
9204                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9205                            }
9206    
9207                            String sql = query.toString();
9208    
9209                            Session session = null;
9210    
9211                            try {
9212                                    session = openSession();
9213    
9214                                    Query q = session.createQuery(sql);
9215    
9216                                    QueryPos qPos = QueryPos.getInstance(q);
9217    
9218                                    qPos.add(companyId);
9219    
9220                                    qPos.add(userId);
9221    
9222                                    qPos.add(status);
9223    
9224                                    if (!pagination) {
9225                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9226                                                            start, end, false);
9227    
9228                                            Collections.sort(list);
9229    
9230                                            list = new UnmodifiableList<BlogsEntry>(list);
9231                                    }
9232                                    else {
9233                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9234                                                            start, end);
9235                                    }
9236    
9237                                    cacheResult(list);
9238    
9239                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9240                            }
9241                            catch (Exception e) {
9242                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9243    
9244                                    throw processException(e);
9245                            }
9246                            finally {
9247                                    closeSession(session);
9248                            }
9249                    }
9250    
9251                    return list;
9252            }
9253    
9254            /**
9255             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9256             *
9257             * @param companyId the company ID
9258             * @param userId the user ID
9259             * @param status the status
9260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9261             * @return the first matching blogs entry
9262             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9263             * @throws SystemException if a system exception occurred
9264             */
9265            @Override
9266            public BlogsEntry findByC_U_S_First(long companyId, long userId,
9267                    int status, OrderByComparator orderByComparator)
9268                    throws NoSuchEntryException, SystemException {
9269                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
9270                                    orderByComparator);
9271    
9272                    if (blogsEntry != null) {
9273                            return blogsEntry;
9274                    }
9275    
9276                    StringBundler msg = new StringBundler(8);
9277    
9278                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9279    
9280                    msg.append("companyId=");
9281                    msg.append(companyId);
9282    
9283                    msg.append(", userId=");
9284                    msg.append(userId);
9285    
9286                    msg.append(", status=");
9287                    msg.append(status);
9288    
9289                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9290    
9291                    throw new NoSuchEntryException(msg.toString());
9292            }
9293    
9294            /**
9295             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9296             *
9297             * @param companyId the company ID
9298             * @param userId the user ID
9299             * @param status the status
9300             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9301             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9302             * @throws SystemException if a system exception occurred
9303             */
9304            @Override
9305            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
9306                    int status, OrderByComparator orderByComparator)
9307                    throws SystemException {
9308                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
9309                                    orderByComparator);
9310    
9311                    if (!list.isEmpty()) {
9312                            return list.get(0);
9313                    }
9314    
9315                    return null;
9316            }
9317    
9318            /**
9319             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9320             *
9321             * @param companyId the company ID
9322             * @param userId the user ID
9323             * @param status the status
9324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9325             * @return the last matching blogs entry
9326             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9327             * @throws SystemException if a system exception occurred
9328             */
9329            @Override
9330            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
9331                    OrderByComparator orderByComparator)
9332                    throws NoSuchEntryException, SystemException {
9333                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
9334                                    orderByComparator);
9335    
9336                    if (blogsEntry != null) {
9337                            return blogsEntry;
9338                    }
9339    
9340                    StringBundler msg = new StringBundler(8);
9341    
9342                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9343    
9344                    msg.append("companyId=");
9345                    msg.append(companyId);
9346    
9347                    msg.append(", userId=");
9348                    msg.append(userId);
9349    
9350                    msg.append(", status=");
9351                    msg.append(status);
9352    
9353                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9354    
9355                    throw new NoSuchEntryException(msg.toString());
9356            }
9357    
9358            /**
9359             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9360             *
9361             * @param companyId the company ID
9362             * @param userId the user ID
9363             * @param status the status
9364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9365             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9366             * @throws SystemException if a system exception occurred
9367             */
9368            @Override
9369            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
9370                    int status, OrderByComparator orderByComparator)
9371                    throws SystemException {
9372                    int count = countByC_U_S(companyId, userId, status);
9373    
9374                    if (count == 0) {
9375                            return null;
9376                    }
9377    
9378                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
9379                                    count - 1, count, orderByComparator);
9380    
9381                    if (!list.isEmpty()) {
9382                            return list.get(0);
9383                    }
9384    
9385                    return null;
9386            }
9387    
9388            /**
9389             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9390             *
9391             * @param entryId the primary key of the current blogs entry
9392             * @param companyId the company ID
9393             * @param userId the user ID
9394             * @param status the status
9395             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9396             * @return the previous, current, and next blogs entry
9397             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9398             * @throws SystemException if a system exception occurred
9399             */
9400            @Override
9401            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
9402                    long userId, int status, OrderByComparator orderByComparator)
9403                    throws NoSuchEntryException, SystemException {
9404                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9405    
9406                    Session session = null;
9407    
9408                    try {
9409                            session = openSession();
9410    
9411                            BlogsEntry[] array = new BlogsEntryImpl[3];
9412    
9413                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9414                                            userId, status, orderByComparator, true);
9415    
9416                            array[1] = blogsEntry;
9417    
9418                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9419                                            userId, status, orderByComparator, false);
9420    
9421                            return array;
9422                    }
9423                    catch (Exception e) {
9424                            throw processException(e);
9425                    }
9426                    finally {
9427                            closeSession(session);
9428                    }
9429            }
9430    
9431            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
9432                    BlogsEntry blogsEntry, long companyId, long userId, int status,
9433                    OrderByComparator orderByComparator, boolean previous) {
9434                    StringBundler query = null;
9435    
9436                    if (orderByComparator != null) {
9437                            query = new StringBundler(6 +
9438                                            (orderByComparator.getOrderByFields().length * 6));
9439                    }
9440                    else {
9441                            query = new StringBundler(3);
9442                    }
9443    
9444                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9445    
9446                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9447    
9448                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9449    
9450                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9451    
9452                    if (orderByComparator != null) {
9453                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9454    
9455                            if (orderByConditionFields.length > 0) {
9456                                    query.append(WHERE_AND);
9457                            }
9458    
9459                            for (int i = 0; i < orderByConditionFields.length; i++) {
9460                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9461                                    query.append(orderByConditionFields[i]);
9462    
9463                                    if ((i + 1) < orderByConditionFields.length) {
9464                                            if (orderByComparator.isAscending() ^ previous) {
9465                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9466                                            }
9467                                            else {
9468                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9469                                            }
9470                                    }
9471                                    else {
9472                                            if (orderByComparator.isAscending() ^ previous) {
9473                                                    query.append(WHERE_GREATER_THAN);
9474                                            }
9475                                            else {
9476                                                    query.append(WHERE_LESSER_THAN);
9477                                            }
9478                                    }
9479                            }
9480    
9481                            query.append(ORDER_BY_CLAUSE);
9482    
9483                            String[] orderByFields = orderByComparator.getOrderByFields();
9484    
9485                            for (int i = 0; i < orderByFields.length; i++) {
9486                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9487                                    query.append(orderByFields[i]);
9488    
9489                                    if ((i + 1) < orderByFields.length) {
9490                                            if (orderByComparator.isAscending() ^ previous) {
9491                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9492                                            }
9493                                            else {
9494                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9495                                            }
9496                                    }
9497                                    else {
9498                                            if (orderByComparator.isAscending() ^ previous) {
9499                                                    query.append(ORDER_BY_ASC);
9500                                            }
9501                                            else {
9502                                                    query.append(ORDER_BY_DESC);
9503                                            }
9504                                    }
9505                            }
9506                    }
9507                    else {
9508                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9509                    }
9510    
9511                    String sql = query.toString();
9512    
9513                    Query q = session.createQuery(sql);
9514    
9515                    q.setFirstResult(0);
9516                    q.setMaxResults(2);
9517    
9518                    QueryPos qPos = QueryPos.getInstance(q);
9519    
9520                    qPos.add(companyId);
9521    
9522                    qPos.add(userId);
9523    
9524                    qPos.add(status);
9525    
9526                    if (orderByComparator != null) {
9527                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9528    
9529                            for (Object value : values) {
9530                                    qPos.add(value);
9531                            }
9532                    }
9533    
9534                    List<BlogsEntry> list = q.list();
9535    
9536                    if (list.size() == 2) {
9537                            return list.get(1);
9538                    }
9539                    else {
9540                            return null;
9541                    }
9542            }
9543    
9544            /**
9545             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
9546             *
9547             * @param companyId the company ID
9548             * @param userId the user ID
9549             * @param status the status
9550             * @throws SystemException if a system exception occurred
9551             */
9552            @Override
9553            public void removeByC_U_S(long companyId, long userId, int status)
9554                    throws SystemException {
9555                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
9556                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9557                            remove(blogsEntry);
9558                    }
9559            }
9560    
9561            /**
9562             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9563             *
9564             * @param companyId the company ID
9565             * @param userId the user ID
9566             * @param status the status
9567             * @return the number of matching blogs entries
9568             * @throws SystemException if a system exception occurred
9569             */
9570            @Override
9571            public int countByC_U_S(long companyId, long userId, int status)
9572                    throws SystemException {
9573                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
9574    
9575                    Object[] finderArgs = new Object[] { companyId, userId, status };
9576    
9577                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9578                                    this);
9579    
9580                    if (count == null) {
9581                            StringBundler query = new StringBundler(4);
9582    
9583                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9584    
9585                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9586    
9587                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9588    
9589                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9590    
9591                            String sql = query.toString();
9592    
9593                            Session session = null;
9594    
9595                            try {
9596                                    session = openSession();
9597    
9598                                    Query q = session.createQuery(sql);
9599    
9600                                    QueryPos qPos = QueryPos.getInstance(q);
9601    
9602                                    qPos.add(companyId);
9603    
9604                                    qPos.add(userId);
9605    
9606                                    qPos.add(status);
9607    
9608                                    count = (Long)q.uniqueResult();
9609    
9610                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9611                            }
9612                            catch (Exception e) {
9613                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9614    
9615                                    throw processException(e);
9616                            }
9617                            finally {
9618                                    closeSession(session);
9619                            }
9620                    }
9621    
9622                    return count.intValue();
9623            }
9624    
9625            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9626            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
9627            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
9628            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
9629                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9630                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9631                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
9632                            new String[] {
9633                                    Long.class.getName(), Date.class.getName(),
9634                                    Integer.class.getName(),
9635                                    
9636                            Integer.class.getName(), Integer.class.getName(),
9637                                    OrderByComparator.class.getName()
9638                            });
9639            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
9640                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9641                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9642                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
9643                            new String[] {
9644                                    Long.class.getName(), Date.class.getName(),
9645                                    Integer.class.getName()
9646                            });
9647    
9648            /**
9649             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9650             *
9651             * @param companyId the company ID
9652             * @param displayDate the display date
9653             * @param status the status
9654             * @return the matching blogs entries
9655             * @throws SystemException if a system exception occurred
9656             */
9657            @Override
9658            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9659                    int status) throws SystemException {
9660                    return findByC_LtD_NotS(companyId, displayDate, status,
9661                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9662            }
9663    
9664            /**
9665             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9666             *
9667             * <p>
9668             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9669             * </p>
9670             *
9671             * @param companyId the company ID
9672             * @param displayDate the display date
9673             * @param status the status
9674             * @param start the lower bound of the range of blogs entries
9675             * @param end the upper bound of the range of blogs entries (not inclusive)
9676             * @return the range of matching blogs entries
9677             * @throws SystemException if a system exception occurred
9678             */
9679            @Override
9680            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9681                    int status, int start, int end) throws SystemException {
9682                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
9683            }
9684    
9685            /**
9686             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9687             *
9688             * <p>
9689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9690             * </p>
9691             *
9692             * @param companyId the company ID
9693             * @param displayDate the display date
9694             * @param status the status
9695             * @param start the lower bound of the range of blogs entries
9696             * @param end the upper bound of the range of blogs entries (not inclusive)
9697             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9698             * @return the ordered range of matching blogs entries
9699             * @throws SystemException if a system exception occurred
9700             */
9701            @Override
9702            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9703                    int status, int start, int end, OrderByComparator orderByComparator)
9704                    throws SystemException {
9705                    boolean pagination = true;
9706                    FinderPath finderPath = null;
9707                    Object[] finderArgs = null;
9708    
9709                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
9710                    finderArgs = new Object[] {
9711                                    companyId, displayDate, status,
9712                                    
9713                                    start, end, orderByComparator
9714                            };
9715    
9716                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9717                                    finderArgs, this);
9718    
9719                    if ((list != null) && !list.isEmpty()) {
9720                            for (BlogsEntry blogsEntry : list) {
9721                                    if ((companyId != blogsEntry.getCompanyId()) ||
9722                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
9723                                                                                                                                    .getTime()) ||
9724                                                    (status == blogsEntry.getStatus())) {
9725                                            list = null;
9726    
9727                                            break;
9728                                    }
9729                            }
9730                    }
9731    
9732                    if (list == null) {
9733                            StringBundler query = null;
9734    
9735                            if (orderByComparator != null) {
9736                                    query = new StringBundler(5 +
9737                                                    (orderByComparator.getOrderByFields().length * 3));
9738                            }
9739                            else {
9740                                    query = new StringBundler(5);
9741                            }
9742    
9743                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9744    
9745                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9746    
9747                            boolean bindDisplayDate = false;
9748    
9749                            if (displayDate == null) {
9750                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9751                            }
9752                            else {
9753                                    bindDisplayDate = true;
9754    
9755                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9756                            }
9757    
9758                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9759    
9760                            if (orderByComparator != null) {
9761                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9762                                            orderByComparator);
9763                            }
9764                            else
9765                             if (pagination) {
9766                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9767                            }
9768    
9769                            String sql = query.toString();
9770    
9771                            Session session = null;
9772    
9773                            try {
9774                                    session = openSession();
9775    
9776                                    Query q = session.createQuery(sql);
9777    
9778                                    QueryPos qPos = QueryPos.getInstance(q);
9779    
9780                                    qPos.add(companyId);
9781    
9782                                    if (bindDisplayDate) {
9783                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9784                                    }
9785    
9786                                    qPos.add(status);
9787    
9788                                    if (!pagination) {
9789                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9790                                                            start, end, false);
9791    
9792                                            Collections.sort(list);
9793    
9794                                            list = new UnmodifiableList<BlogsEntry>(list);
9795                                    }
9796                                    else {
9797                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9798                                                            start, end);
9799                                    }
9800    
9801                                    cacheResult(list);
9802    
9803                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9804                            }
9805                            catch (Exception e) {
9806                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9807    
9808                                    throw processException(e);
9809                            }
9810                            finally {
9811                                    closeSession(session);
9812                            }
9813                    }
9814    
9815                    return list;
9816            }
9817    
9818            /**
9819             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9820             *
9821             * @param companyId the company ID
9822             * @param displayDate the display date
9823             * @param status the status
9824             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9825             * @return the first matching blogs entry
9826             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9827             * @throws SystemException if a system exception occurred
9828             */
9829            @Override
9830            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
9831                    int status, OrderByComparator orderByComparator)
9832                    throws NoSuchEntryException, SystemException {
9833                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
9834                                    status, orderByComparator);
9835    
9836                    if (blogsEntry != null) {
9837                            return blogsEntry;
9838                    }
9839    
9840                    StringBundler msg = new StringBundler(8);
9841    
9842                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9843    
9844                    msg.append("companyId=");
9845                    msg.append(companyId);
9846    
9847                    msg.append(", displayDate=");
9848                    msg.append(displayDate);
9849    
9850                    msg.append(", status=");
9851                    msg.append(status);
9852    
9853                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9854    
9855                    throw new NoSuchEntryException(msg.toString());
9856            }
9857    
9858            /**
9859             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9860             *
9861             * @param companyId the company ID
9862             * @param displayDate the display date
9863             * @param status the status
9864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9865             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9866             * @throws SystemException if a system exception occurred
9867             */
9868            @Override
9869            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
9870                    int status, OrderByComparator orderByComparator)
9871                    throws SystemException {
9872                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9873                                    status, 0, 1, orderByComparator);
9874    
9875                    if (!list.isEmpty()) {
9876                            return list.get(0);
9877                    }
9878    
9879                    return null;
9880            }
9881    
9882            /**
9883             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9884             *
9885             * @param companyId the company ID
9886             * @param displayDate the display date
9887             * @param status the status
9888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9889             * @return the last matching blogs entry
9890             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9891             * @throws SystemException if a system exception occurred
9892             */
9893            @Override
9894            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
9895                    int status, OrderByComparator orderByComparator)
9896                    throws NoSuchEntryException, SystemException {
9897                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
9898                                    status, orderByComparator);
9899    
9900                    if (blogsEntry != null) {
9901                            return blogsEntry;
9902                    }
9903    
9904                    StringBundler msg = new StringBundler(8);
9905    
9906                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9907    
9908                    msg.append("companyId=");
9909                    msg.append(companyId);
9910    
9911                    msg.append(", displayDate=");
9912                    msg.append(displayDate);
9913    
9914                    msg.append(", status=");
9915                    msg.append(status);
9916    
9917                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9918    
9919                    throw new NoSuchEntryException(msg.toString());
9920            }
9921    
9922            /**
9923             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9924             *
9925             * @param companyId the company ID
9926             * @param displayDate the display date
9927             * @param status the status
9928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9929             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9930             * @throws SystemException if a system exception occurred
9931             */
9932            @Override
9933            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
9934                    int status, OrderByComparator orderByComparator)
9935                    throws SystemException {
9936                    int count = countByC_LtD_NotS(companyId, displayDate, status);
9937    
9938                    if (count == 0) {
9939                            return null;
9940                    }
9941    
9942                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9943                                    status, count - 1, count, orderByComparator);
9944    
9945                    if (!list.isEmpty()) {
9946                            return list.get(0);
9947                    }
9948    
9949                    return null;
9950            }
9951    
9952            /**
9953             * 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;.
9954             *
9955             * @param entryId the primary key of the current blogs entry
9956             * @param companyId the company ID
9957             * @param displayDate the display date
9958             * @param status the status
9959             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9960             * @return the previous, current, and next blogs entry
9961             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9962             * @throws SystemException if a system exception occurred
9963             */
9964            @Override
9965            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
9966                    long companyId, Date displayDate, int status,
9967                    OrderByComparator orderByComparator)
9968                    throws NoSuchEntryException, SystemException {
9969                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9970    
9971                    Session session = null;
9972    
9973                    try {
9974                            session = openSession();
9975    
9976                            BlogsEntry[] array = new BlogsEntryImpl[3];
9977    
9978                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9979                                            companyId, displayDate, status, orderByComparator, true);
9980    
9981                            array[1] = blogsEntry;
9982    
9983                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9984                                            companyId, displayDate, status, orderByComparator, false);
9985    
9986                            return array;
9987                    }
9988                    catch (Exception e) {
9989                            throw processException(e);
9990                    }
9991                    finally {
9992                            closeSession(session);
9993                    }
9994            }
9995    
9996            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
9997                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
9998                    OrderByComparator orderByComparator, boolean previous) {
9999                    StringBundler query = null;
10000    
10001                    if (orderByComparator != null) {
10002                            query = new StringBundler(6 +
10003                                            (orderByComparator.getOrderByFields().length * 6));
10004                    }
10005                    else {
10006                            query = new StringBundler(3);
10007                    }
10008    
10009                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10010    
10011                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
10012    
10013                    boolean bindDisplayDate = false;
10014    
10015                    if (displayDate == null) {
10016                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
10017                    }
10018                    else {
10019                            bindDisplayDate = true;
10020    
10021                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
10022                    }
10023    
10024                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
10025    
10026                    if (orderByComparator != null) {
10027                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10028    
10029                            if (orderByConditionFields.length > 0) {
10030                                    query.append(WHERE_AND);
10031                            }
10032    
10033                            for (int i = 0; i < orderByConditionFields.length; i++) {
10034                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10035                                    query.append(orderByConditionFields[i]);
10036    
10037                                    if ((i + 1) < orderByConditionFields.length) {
10038                                            if (orderByComparator.isAscending() ^ previous) {
10039                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10040                                            }
10041                                            else {
10042                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10043                                            }
10044                                    }
10045                                    else {
10046                                            if (orderByComparator.isAscending() ^ previous) {
10047                                                    query.append(WHERE_GREATER_THAN);
10048                                            }
10049                                            else {
10050                                                    query.append(WHERE_LESSER_THAN);
10051                                            }
10052                                    }
10053                            }
10054    
10055                            query.append(ORDER_BY_CLAUSE);
10056    
10057                            String[] orderByFields = orderByComparator.getOrderByFields();
10058    
10059                            for (int i = 0; i < orderByFields.length; i++) {
10060                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10061                                    query.append(orderByFields[i]);
10062    
10063                                    if ((i + 1) < orderByFields.length) {
10064                                            if (orderByComparator.isAscending() ^ previous) {
10065                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10066                                            }
10067                                            else {
10068                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10069                                            }
10070                                    }
10071                                    else {
10072                                            if (orderByComparator.isAscending() ^ previous) {
10073                                                    query.append(ORDER_BY_ASC);
10074                                            }
10075                                            else {
10076                                                    query.append(ORDER_BY_DESC);
10077                                            }
10078                                    }
10079                            }
10080                    }
10081                    else {
10082                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10083                    }
10084    
10085                    String sql = query.toString();
10086    
10087                    Query q = session.createQuery(sql);
10088    
10089                    q.setFirstResult(0);
10090                    q.setMaxResults(2);
10091    
10092                    QueryPos qPos = QueryPos.getInstance(q);
10093    
10094                    qPos.add(companyId);
10095    
10096                    if (bindDisplayDate) {
10097                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10098                    }
10099    
10100                    qPos.add(status);
10101    
10102                    if (orderByComparator != null) {
10103                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10104    
10105                            for (Object value : values) {
10106                                    qPos.add(value);
10107                            }
10108                    }
10109    
10110                    List<BlogsEntry> list = q.list();
10111    
10112                    if (list.size() == 2) {
10113                            return list.get(1);
10114                    }
10115                    else {
10116                            return null;
10117                    }
10118            }
10119    
10120            /**
10121             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
10122             *
10123             * @param companyId the company ID
10124             * @param displayDate the display date
10125             * @param status the status
10126             * @throws SystemException if a system exception occurred
10127             */
10128            @Override
10129            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status)
10130                    throws SystemException {
10131                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
10132                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10133                            remove(blogsEntry);
10134                    }
10135            }
10136    
10137            /**
10138             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
10139             *
10140             * @param companyId the company ID
10141             * @param displayDate the display date
10142             * @param status the status
10143             * @return the number of matching blogs entries
10144             * @throws SystemException if a system exception occurred
10145             */
10146            @Override
10147            public int countByC_LtD_NotS(long companyId, Date displayDate, int status)
10148                    throws SystemException {
10149                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
10150    
10151                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
10152    
10153                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10154                                    this);
10155    
10156                    if (count == null) {
10157                            StringBundler query = new StringBundler(4);
10158    
10159                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10160    
10161                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
10162    
10163                            boolean bindDisplayDate = false;
10164    
10165                            if (displayDate == null) {
10166                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
10167                            }
10168                            else {
10169                                    bindDisplayDate = true;
10170    
10171                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
10172                            }
10173    
10174                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
10175    
10176                            String sql = query.toString();
10177    
10178                            Session session = null;
10179    
10180                            try {
10181                                    session = openSession();
10182    
10183                                    Query q = session.createQuery(sql);
10184    
10185                                    QueryPos qPos = QueryPos.getInstance(q);
10186    
10187                                    qPos.add(companyId);
10188    
10189                                    if (bindDisplayDate) {
10190                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10191                                    }
10192    
10193                                    qPos.add(status);
10194    
10195                                    count = (Long)q.uniqueResult();
10196    
10197                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10198                            }
10199                            catch (Exception e) {
10200                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10201    
10202                                    throw processException(e);
10203                            }
10204                            finally {
10205                                    closeSession(session);
10206                            }
10207                    }
10208    
10209                    return count.intValue();
10210            }
10211    
10212            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
10213            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
10214            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
10215            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
10216            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10217                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10218                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
10219                            new String[] {
10220                                    Long.class.getName(), Date.class.getName(),
10221                                    Integer.class.getName(),
10222                                    
10223                            Integer.class.getName(), Integer.class.getName(),
10224                                    OrderByComparator.class.getName()
10225                            });
10226            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10227                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10228                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
10229                            new String[] {
10230                                    Long.class.getName(), Date.class.getName(),
10231                                    Integer.class.getName()
10232                            });
10233    
10234            /**
10235             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10236             *
10237             * @param companyId the company ID
10238             * @param displayDate the display date
10239             * @param status the status
10240             * @return the matching blogs entries
10241             * @throws SystemException if a system exception occurred
10242             */
10243            @Override
10244            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10245                    int status) throws SystemException {
10246                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
10247                            QueryUtil.ALL_POS, null);
10248            }
10249    
10250            /**
10251             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10252             *
10253             * <p>
10254             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10255             * </p>
10256             *
10257             * @param companyId the company ID
10258             * @param displayDate the display date
10259             * @param status the status
10260             * @param start the lower bound of the range of blogs entries
10261             * @param end the upper bound of the range of blogs entries (not inclusive)
10262             * @return the range of matching blogs entries
10263             * @throws SystemException if a system exception occurred
10264             */
10265            @Override
10266            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10267                    int status, int start, int end) throws SystemException {
10268                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
10269            }
10270    
10271            /**
10272             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10273             *
10274             * <p>
10275             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10276             * </p>
10277             *
10278             * @param companyId the company ID
10279             * @param displayDate the display date
10280             * @param status the status
10281             * @param start the lower bound of the range of blogs entries
10282             * @param end the upper bound of the range of blogs entries (not inclusive)
10283             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10284             * @return the ordered range of matching blogs entries
10285             * @throws SystemException if a system exception occurred
10286             */
10287            @Override
10288            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10289                    int status, int start, int end, OrderByComparator orderByComparator)
10290                    throws SystemException {
10291                    boolean pagination = true;
10292                    FinderPath finderPath = null;
10293                    Object[] finderArgs = null;
10294    
10295                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
10296                    finderArgs = new Object[] {
10297                                    companyId, displayDate, status,
10298                                    
10299                                    start, end, orderByComparator
10300                            };
10301    
10302                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10303                                    finderArgs, this);
10304    
10305                    if ((list != null) && !list.isEmpty()) {
10306                            for (BlogsEntry blogsEntry : list) {
10307                                    if ((companyId != blogsEntry.getCompanyId()) ||
10308                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
10309                                                                                                                                    .getTime()) ||
10310                                                    (status != blogsEntry.getStatus())) {
10311                                            list = null;
10312    
10313                                            break;
10314                                    }
10315                            }
10316                    }
10317    
10318                    if (list == null) {
10319                            StringBundler query = null;
10320    
10321                            if (orderByComparator != null) {
10322                                    query = new StringBundler(5 +
10323                                                    (orderByComparator.getOrderByFields().length * 3));
10324                            }
10325                            else {
10326                                    query = new StringBundler(5);
10327                            }
10328    
10329                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10330    
10331                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10332    
10333                            boolean bindDisplayDate = false;
10334    
10335                            if (displayDate == null) {
10336                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10337                            }
10338                            else {
10339                                    bindDisplayDate = true;
10340    
10341                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10342                            }
10343    
10344                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10345    
10346                            if (orderByComparator != null) {
10347                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10348                                            orderByComparator);
10349                            }
10350                            else
10351                             if (pagination) {
10352                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10353                            }
10354    
10355                            String sql = query.toString();
10356    
10357                            Session session = null;
10358    
10359                            try {
10360                                    session = openSession();
10361    
10362                                    Query q = session.createQuery(sql);
10363    
10364                                    QueryPos qPos = QueryPos.getInstance(q);
10365    
10366                                    qPos.add(companyId);
10367    
10368                                    if (bindDisplayDate) {
10369                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10370                                    }
10371    
10372                                    qPos.add(status);
10373    
10374                                    if (!pagination) {
10375                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10376                                                            start, end, false);
10377    
10378                                            Collections.sort(list);
10379    
10380                                            list = new UnmodifiableList<BlogsEntry>(list);
10381                                    }
10382                                    else {
10383                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10384                                                            start, end);
10385                                    }
10386    
10387                                    cacheResult(list);
10388    
10389                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10390                            }
10391                            catch (Exception e) {
10392                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10393    
10394                                    throw processException(e);
10395                            }
10396                            finally {
10397                                    closeSession(session);
10398                            }
10399                    }
10400    
10401                    return list;
10402            }
10403    
10404            /**
10405             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10406             *
10407             * @param companyId the company ID
10408             * @param displayDate the display date
10409             * @param status the status
10410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10411             * @return the first matching blogs entry
10412             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10413             * @throws SystemException if a system exception occurred
10414             */
10415            @Override
10416            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
10417                    int status, OrderByComparator orderByComparator)
10418                    throws NoSuchEntryException, SystemException {
10419                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
10420                                    status, orderByComparator);
10421    
10422                    if (blogsEntry != null) {
10423                            return blogsEntry;
10424                    }
10425    
10426                    StringBundler msg = new StringBundler(8);
10427    
10428                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10429    
10430                    msg.append("companyId=");
10431                    msg.append(companyId);
10432    
10433                    msg.append(", displayDate=");
10434                    msg.append(displayDate);
10435    
10436                    msg.append(", status=");
10437                    msg.append(status);
10438    
10439                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10440    
10441                    throw new NoSuchEntryException(msg.toString());
10442            }
10443    
10444            /**
10445             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10446             *
10447             * @param companyId the company ID
10448             * @param displayDate the display date
10449             * @param status the status
10450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10451             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10452             * @throws SystemException if a system exception occurred
10453             */
10454            @Override
10455            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
10456                    int status, OrderByComparator orderByComparator)
10457                    throws SystemException {
10458                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10459                                    0, 1, orderByComparator);
10460    
10461                    if (!list.isEmpty()) {
10462                            return list.get(0);
10463                    }
10464    
10465                    return null;
10466            }
10467    
10468            /**
10469             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10470             *
10471             * @param companyId the company ID
10472             * @param displayDate the display date
10473             * @param status the status
10474             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10475             * @return the last matching blogs entry
10476             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10477             * @throws SystemException if a system exception occurred
10478             */
10479            @Override
10480            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
10481                    int status, OrderByComparator orderByComparator)
10482                    throws NoSuchEntryException, SystemException {
10483                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
10484                                    status, orderByComparator);
10485    
10486                    if (blogsEntry != null) {
10487                            return blogsEntry;
10488                    }
10489    
10490                    StringBundler msg = new StringBundler(8);
10491    
10492                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10493    
10494                    msg.append("companyId=");
10495                    msg.append(companyId);
10496    
10497                    msg.append(", displayDate=");
10498                    msg.append(displayDate);
10499    
10500                    msg.append(", status=");
10501                    msg.append(status);
10502    
10503                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10504    
10505                    throw new NoSuchEntryException(msg.toString());
10506            }
10507    
10508            /**
10509             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10510             *
10511             * @param companyId the company ID
10512             * @param displayDate the display date
10513             * @param status the status
10514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10515             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10516             * @throws SystemException if a system exception occurred
10517             */
10518            @Override
10519            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
10520                    int status, OrderByComparator orderByComparator)
10521                    throws SystemException {
10522                    int count = countByC_LtD_S(companyId, displayDate, status);
10523    
10524                    if (count == 0) {
10525                            return null;
10526                    }
10527    
10528                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10529                                    count - 1, count, orderByComparator);
10530    
10531                    if (!list.isEmpty()) {
10532                            return list.get(0);
10533                    }
10534    
10535                    return null;
10536            }
10537    
10538            /**
10539             * 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;.
10540             *
10541             * @param entryId the primary key of the current blogs entry
10542             * @param companyId the company ID
10543             * @param displayDate the display date
10544             * @param status the status
10545             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10546             * @return the previous, current, and next blogs entry
10547             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10548             * @throws SystemException if a system exception occurred
10549             */
10550            @Override
10551            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
10552                    Date displayDate, int status, OrderByComparator orderByComparator)
10553                    throws NoSuchEntryException, SystemException {
10554                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10555    
10556                    Session session = null;
10557    
10558                    try {
10559                            session = openSession();
10560    
10561                            BlogsEntry[] array = new BlogsEntryImpl[3];
10562    
10563                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10564                                            displayDate, status, orderByComparator, true);
10565    
10566                            array[1] = blogsEntry;
10567    
10568                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10569                                            displayDate, status, orderByComparator, false);
10570    
10571                            return array;
10572                    }
10573                    catch (Exception e) {
10574                            throw processException(e);
10575                    }
10576                    finally {
10577                            closeSession(session);
10578                    }
10579            }
10580    
10581            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
10582                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
10583                    OrderByComparator orderByComparator, boolean previous) {
10584                    StringBundler query = null;
10585    
10586                    if (orderByComparator != null) {
10587                            query = new StringBundler(6 +
10588                                            (orderByComparator.getOrderByFields().length * 6));
10589                    }
10590                    else {
10591                            query = new StringBundler(3);
10592                    }
10593    
10594                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10595    
10596                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10597    
10598                    boolean bindDisplayDate = false;
10599    
10600                    if (displayDate == null) {
10601                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10602                    }
10603                    else {
10604                            bindDisplayDate = true;
10605    
10606                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10607                    }
10608    
10609                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10610    
10611                    if (orderByComparator != null) {
10612                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10613    
10614                            if (orderByConditionFields.length > 0) {
10615                                    query.append(WHERE_AND);
10616                            }
10617    
10618                            for (int i = 0; i < orderByConditionFields.length; i++) {
10619                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10620                                    query.append(orderByConditionFields[i]);
10621    
10622                                    if ((i + 1) < orderByConditionFields.length) {
10623                                            if (orderByComparator.isAscending() ^ previous) {
10624                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10625                                            }
10626                                            else {
10627                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10628                                            }
10629                                    }
10630                                    else {
10631                                            if (orderByComparator.isAscending() ^ previous) {
10632                                                    query.append(WHERE_GREATER_THAN);
10633                                            }
10634                                            else {
10635                                                    query.append(WHERE_LESSER_THAN);
10636                                            }
10637                                    }
10638                            }
10639    
10640                            query.append(ORDER_BY_CLAUSE);
10641    
10642                            String[] orderByFields = orderByComparator.getOrderByFields();
10643    
10644                            for (int i = 0; i < orderByFields.length; i++) {
10645                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10646                                    query.append(orderByFields[i]);
10647    
10648                                    if ((i + 1) < orderByFields.length) {
10649                                            if (orderByComparator.isAscending() ^ previous) {
10650                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10651                                            }
10652                                            else {
10653                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10654                                            }
10655                                    }
10656                                    else {
10657                                            if (orderByComparator.isAscending() ^ previous) {
10658                                                    query.append(ORDER_BY_ASC);
10659                                            }
10660                                            else {
10661                                                    query.append(ORDER_BY_DESC);
10662                                            }
10663                                    }
10664                            }
10665                    }
10666                    else {
10667                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10668                    }
10669    
10670                    String sql = query.toString();
10671    
10672                    Query q = session.createQuery(sql);
10673    
10674                    q.setFirstResult(0);
10675                    q.setMaxResults(2);
10676    
10677                    QueryPos qPos = QueryPos.getInstance(q);
10678    
10679                    qPos.add(companyId);
10680    
10681                    if (bindDisplayDate) {
10682                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10683                    }
10684    
10685                    qPos.add(status);
10686    
10687                    if (orderByComparator != null) {
10688                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10689    
10690                            for (Object value : values) {
10691                                    qPos.add(value);
10692                            }
10693                    }
10694    
10695                    List<BlogsEntry> list = q.list();
10696    
10697                    if (list.size() == 2) {
10698                            return list.get(1);
10699                    }
10700                    else {
10701                            return null;
10702                    }
10703            }
10704    
10705            /**
10706             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
10707             *
10708             * @param companyId the company ID
10709             * @param displayDate the display date
10710             * @param status the status
10711             * @throws SystemException if a system exception occurred
10712             */
10713            @Override
10714            public void removeByC_LtD_S(long companyId, Date displayDate, int status)
10715                    throws SystemException {
10716                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
10717                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10718                            remove(blogsEntry);
10719                    }
10720            }
10721    
10722            /**
10723             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10724             *
10725             * @param companyId the company ID
10726             * @param displayDate the display date
10727             * @param status the status
10728             * @return the number of matching blogs entries
10729             * @throws SystemException if a system exception occurred
10730             */
10731            @Override
10732            public int countByC_LtD_S(long companyId, Date displayDate, int status)
10733                    throws SystemException {
10734                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
10735    
10736                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
10737    
10738                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10739                                    this);
10740    
10741                    if (count == null) {
10742                            StringBundler query = new StringBundler(4);
10743    
10744                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10745    
10746                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10747    
10748                            boolean bindDisplayDate = false;
10749    
10750                            if (displayDate == null) {
10751                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10752                            }
10753                            else {
10754                                    bindDisplayDate = true;
10755    
10756                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10757                            }
10758    
10759                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10760    
10761                            String sql = query.toString();
10762    
10763                            Session session = null;
10764    
10765                            try {
10766                                    session = openSession();
10767    
10768                                    Query q = session.createQuery(sql);
10769    
10770                                    QueryPos qPos = QueryPos.getInstance(q);
10771    
10772                                    qPos.add(companyId);
10773    
10774                                    if (bindDisplayDate) {
10775                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10776                                    }
10777    
10778                                    qPos.add(status);
10779    
10780                                    count = (Long)q.uniqueResult();
10781    
10782                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10783                            }
10784                            catch (Exception e) {
10785                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10786    
10787                                    throw processException(e);
10788                            }
10789                            finally {
10790                                    closeSession(session);
10791                            }
10792                    }
10793    
10794                    return count.intValue();
10795            }
10796    
10797            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
10798            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
10799            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
10800            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
10801            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10802                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10803                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
10804                            new String[] {
10805                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
10806                                    
10807                            Integer.class.getName(), Integer.class.getName(),
10808                                    OrderByComparator.class.getName()
10809                            });
10810            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10811                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10812                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
10813                            new String[] {
10814                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
10815                            });
10816    
10817            /**
10818             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10819             *
10820             * @param groupId the group ID
10821             * @param userId the user ID
10822             * @param displayDate the display date
10823             * @return the matching blogs entries
10824             * @throws SystemException if a system exception occurred
10825             */
10826            @Override
10827            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10828                    Date displayDate) throws SystemException {
10829                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
10830                            QueryUtil.ALL_POS, null);
10831            }
10832    
10833            /**
10834             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10835             *
10836             * <p>
10837             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10838             * </p>
10839             *
10840             * @param groupId the group ID
10841             * @param userId the user ID
10842             * @param displayDate the display date
10843             * @param start the lower bound of the range of blogs entries
10844             * @param end the upper bound of the range of blogs entries (not inclusive)
10845             * @return the range of matching blogs entries
10846             * @throws SystemException if a system exception occurred
10847             */
10848            @Override
10849            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10850                    Date displayDate, int start, int end) throws SystemException {
10851                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
10852            }
10853    
10854            /**
10855             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10856             *
10857             * <p>
10858             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10859             * </p>
10860             *
10861             * @param groupId the group ID
10862             * @param userId the user ID
10863             * @param displayDate the display date
10864             * @param start the lower bound of the range of blogs entries
10865             * @param end the upper bound of the range of blogs entries (not inclusive)
10866             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10867             * @return the ordered range of matching blogs entries
10868             * @throws SystemException if a system exception occurred
10869             */
10870            @Override
10871            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10872                    Date displayDate, int start, int end,
10873                    OrderByComparator orderByComparator) throws SystemException {
10874                    boolean pagination = true;
10875                    FinderPath finderPath = null;
10876                    Object[] finderArgs = null;
10877    
10878                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
10879                    finderArgs = new Object[] {
10880                                    groupId, userId, displayDate,
10881                                    
10882                                    start, end, orderByComparator
10883                            };
10884    
10885                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10886                                    finderArgs, this);
10887    
10888                    if ((list != null) && !list.isEmpty()) {
10889                            for (BlogsEntry blogsEntry : list) {
10890                                    if ((groupId != blogsEntry.getGroupId()) ||
10891                                                    (userId != blogsEntry.getUserId()) ||
10892                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
10893                                                                                                                                    .getTime())) {
10894                                            list = null;
10895    
10896                                            break;
10897                                    }
10898                            }
10899                    }
10900    
10901                    if (list == null) {
10902                            StringBundler query = null;
10903    
10904                            if (orderByComparator != null) {
10905                                    query = new StringBundler(5 +
10906                                                    (orderByComparator.getOrderByFields().length * 3));
10907                            }
10908                            else {
10909                                    query = new StringBundler(5);
10910                            }
10911    
10912                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10913    
10914                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10915    
10916                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10917    
10918                            boolean bindDisplayDate = false;
10919    
10920                            if (displayDate == null) {
10921                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10922                            }
10923                            else {
10924                                    bindDisplayDate = true;
10925    
10926                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10927                            }
10928    
10929                            if (orderByComparator != null) {
10930                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10931                                            orderByComparator);
10932                            }
10933                            else
10934                             if (pagination) {
10935                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10936                            }
10937    
10938                            String sql = query.toString();
10939    
10940                            Session session = null;
10941    
10942                            try {
10943                                    session = openSession();
10944    
10945                                    Query q = session.createQuery(sql);
10946    
10947                                    QueryPos qPos = QueryPos.getInstance(q);
10948    
10949                                    qPos.add(groupId);
10950    
10951                                    qPos.add(userId);
10952    
10953                                    if (bindDisplayDate) {
10954                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10955                                    }
10956    
10957                                    if (!pagination) {
10958                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10959                                                            start, end, false);
10960    
10961                                            Collections.sort(list);
10962    
10963                                            list = new UnmodifiableList<BlogsEntry>(list);
10964                                    }
10965                                    else {
10966                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10967                                                            start, end);
10968                                    }
10969    
10970                                    cacheResult(list);
10971    
10972                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10973                            }
10974                            catch (Exception e) {
10975                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10976    
10977                                    throw processException(e);
10978                            }
10979                            finally {
10980                                    closeSession(session);
10981                            }
10982                    }
10983    
10984                    return list;
10985            }
10986    
10987            /**
10988             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10989             *
10990             * @param groupId the group ID
10991             * @param userId the user ID
10992             * @param displayDate the display date
10993             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10994             * @return the first matching blogs entry
10995             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10996             * @throws SystemException if a system exception occurred
10997             */
10998            @Override
10999            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
11000                    Date displayDate, OrderByComparator orderByComparator)
11001                    throws NoSuchEntryException, SystemException {
11002                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
11003                                    displayDate, orderByComparator);
11004    
11005                    if (blogsEntry != null) {
11006                            return blogsEntry;
11007                    }
11008    
11009                    StringBundler msg = new StringBundler(8);
11010    
11011                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11012    
11013                    msg.append("groupId=");
11014                    msg.append(groupId);
11015    
11016                    msg.append(", userId=");
11017                    msg.append(userId);
11018    
11019                    msg.append(", displayDate=");
11020                    msg.append(displayDate);
11021    
11022                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11023    
11024                    throw new NoSuchEntryException(msg.toString());
11025            }
11026    
11027            /**
11028             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11029             *
11030             * @param groupId the group ID
11031             * @param userId the user ID
11032             * @param displayDate the display date
11033             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11034             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11035             * @throws SystemException if a system exception occurred
11036             */
11037            @Override
11038            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
11039                    Date displayDate, OrderByComparator orderByComparator)
11040                    throws SystemException {
11041                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
11042                                    1, orderByComparator);
11043    
11044                    if (!list.isEmpty()) {
11045                            return list.get(0);
11046                    }
11047    
11048                    return null;
11049            }
11050    
11051            /**
11052             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11053             *
11054             * @param groupId the group ID
11055             * @param userId the user ID
11056             * @param displayDate the display date
11057             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11058             * @return the last matching blogs entry
11059             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11060             * @throws SystemException if a system exception occurred
11061             */
11062            @Override
11063            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
11064                    Date displayDate, OrderByComparator orderByComparator)
11065                    throws NoSuchEntryException, SystemException {
11066                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
11067                                    displayDate, orderByComparator);
11068    
11069                    if (blogsEntry != null) {
11070                            return blogsEntry;
11071                    }
11072    
11073                    StringBundler msg = new StringBundler(8);
11074    
11075                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11076    
11077                    msg.append("groupId=");
11078                    msg.append(groupId);
11079    
11080                    msg.append(", userId=");
11081                    msg.append(userId);
11082    
11083                    msg.append(", displayDate=");
11084                    msg.append(displayDate);
11085    
11086                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11087    
11088                    throw new NoSuchEntryException(msg.toString());
11089            }
11090    
11091            /**
11092             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11093             *
11094             * @param groupId the group ID
11095             * @param userId the user ID
11096             * @param displayDate the display date
11097             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11098             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11099             * @throws SystemException if a system exception occurred
11100             */
11101            @Override
11102            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
11103                    Date displayDate, OrderByComparator orderByComparator)
11104                    throws SystemException {
11105                    int count = countByG_U_LtD(groupId, userId, displayDate);
11106    
11107                    if (count == 0) {
11108                            return null;
11109                    }
11110    
11111                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
11112                                    count - 1, count, orderByComparator);
11113    
11114                    if (!list.isEmpty()) {
11115                            return list.get(0);
11116                    }
11117    
11118                    return null;
11119            }
11120    
11121            /**
11122             * 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;.
11123             *
11124             * @param entryId the primary key of the current blogs entry
11125             * @param groupId the group ID
11126             * @param userId the user ID
11127             * @param displayDate the display date
11128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11129             * @return the previous, current, and next blogs entry
11130             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11131             * @throws SystemException if a system exception occurred
11132             */
11133            @Override
11134            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
11135                    long userId, Date displayDate, OrderByComparator orderByComparator)
11136                    throws NoSuchEntryException, SystemException {
11137                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11138    
11139                    Session session = null;
11140    
11141                    try {
11142                            session = openSession();
11143    
11144                            BlogsEntry[] array = new BlogsEntryImpl[3];
11145    
11146                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
11147                                            userId, displayDate, orderByComparator, true);
11148    
11149                            array[1] = blogsEntry;
11150    
11151                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
11152                                            userId, displayDate, orderByComparator, false);
11153    
11154                            return array;
11155                    }
11156                    catch (Exception e) {
11157                            throw processException(e);
11158                    }
11159                    finally {
11160                            closeSession(session);
11161                    }
11162            }
11163    
11164            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
11165                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
11166                    OrderByComparator orderByComparator, boolean previous) {
11167                    StringBundler query = null;
11168    
11169                    if (orderByComparator != null) {
11170                            query = new StringBundler(6 +
11171                                            (orderByComparator.getOrderByFields().length * 6));
11172                    }
11173                    else {
11174                            query = new StringBundler(3);
11175                    }
11176    
11177                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11178    
11179                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11180    
11181                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11182    
11183                    boolean bindDisplayDate = false;
11184    
11185                    if (displayDate == null) {
11186                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11187                    }
11188                    else {
11189                            bindDisplayDate = true;
11190    
11191                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11192                    }
11193    
11194                    if (orderByComparator != null) {
11195                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11196    
11197                            if (orderByConditionFields.length > 0) {
11198                                    query.append(WHERE_AND);
11199                            }
11200    
11201                            for (int i = 0; i < orderByConditionFields.length; i++) {
11202                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11203                                    query.append(orderByConditionFields[i]);
11204    
11205                                    if ((i + 1) < orderByConditionFields.length) {
11206                                            if (orderByComparator.isAscending() ^ previous) {
11207                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11208                                            }
11209                                            else {
11210                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11211                                            }
11212                                    }
11213                                    else {
11214                                            if (orderByComparator.isAscending() ^ previous) {
11215                                                    query.append(WHERE_GREATER_THAN);
11216                                            }
11217                                            else {
11218                                                    query.append(WHERE_LESSER_THAN);
11219                                            }
11220                                    }
11221                            }
11222    
11223                            query.append(ORDER_BY_CLAUSE);
11224    
11225                            String[] orderByFields = orderByComparator.getOrderByFields();
11226    
11227                            for (int i = 0; i < orderByFields.length; i++) {
11228                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11229                                    query.append(orderByFields[i]);
11230    
11231                                    if ((i + 1) < orderByFields.length) {
11232                                            if (orderByComparator.isAscending() ^ previous) {
11233                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11234                                            }
11235                                            else {
11236                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11237                                            }
11238                                    }
11239                                    else {
11240                                            if (orderByComparator.isAscending() ^ previous) {
11241                                                    query.append(ORDER_BY_ASC);
11242                                            }
11243                                            else {
11244                                                    query.append(ORDER_BY_DESC);
11245                                            }
11246                                    }
11247                            }
11248                    }
11249                    else {
11250                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11251                    }
11252    
11253                    String sql = query.toString();
11254    
11255                    Query q = session.createQuery(sql);
11256    
11257                    q.setFirstResult(0);
11258                    q.setMaxResults(2);
11259    
11260                    QueryPos qPos = QueryPos.getInstance(q);
11261    
11262                    qPos.add(groupId);
11263    
11264                    qPos.add(userId);
11265    
11266                    if (bindDisplayDate) {
11267                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11268                    }
11269    
11270                    if (orderByComparator != null) {
11271                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11272    
11273                            for (Object value : values) {
11274                                    qPos.add(value);
11275                            }
11276                    }
11277    
11278                    List<BlogsEntry> list = q.list();
11279    
11280                    if (list.size() == 2) {
11281                            return list.get(1);
11282                    }
11283                    else {
11284                            return null;
11285                    }
11286            }
11287    
11288            /**
11289             * Returns all the blogs entries that the user has permission to view 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 matching blogs entries that the user has permission to view
11295             * @throws SystemException if a system exception occurred
11296             */
11297            @Override
11298            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11299                    Date displayDate) throws SystemException {
11300                    return filterFindByG_U_LtD(groupId, userId, displayDate,
11301                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11302            }
11303    
11304            /**
11305             * 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;.
11306             *
11307             * <p>
11308             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11309             * </p>
11310             *
11311             * @param groupId the group ID
11312             * @param userId the user ID
11313             * @param displayDate the display date
11314             * @param start the lower bound of the range of blogs entries
11315             * @param end the upper bound of the range of blogs entries (not inclusive)
11316             * @return the range of matching blogs entries that the user has permission to view
11317             * @throws SystemException if a system exception occurred
11318             */
11319            @Override
11320            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11321                    Date displayDate, int start, int end) throws SystemException {
11322                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
11323                            null);
11324            }
11325    
11326            /**
11327             * 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;.
11328             *
11329             * <p>
11330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11331             * </p>
11332             *
11333             * @param groupId the group ID
11334             * @param userId the user ID
11335             * @param displayDate the display date
11336             * @param start the lower bound of the range of blogs entries
11337             * @param end the upper bound of the range of blogs entries (not inclusive)
11338             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11339             * @return the ordered range of matching blogs entries that the user has permission to view
11340             * @throws SystemException if a system exception occurred
11341             */
11342            @Override
11343            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11344                    Date displayDate, int start, int end,
11345                    OrderByComparator orderByComparator) throws SystemException {
11346                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11347                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
11348                                    orderByComparator);
11349                    }
11350    
11351                    StringBundler query = null;
11352    
11353                    if (orderByComparator != null) {
11354                            query = new StringBundler(5 +
11355                                            (orderByComparator.getOrderByFields().length * 3));
11356                    }
11357                    else {
11358                            query = new StringBundler(5);
11359                    }
11360    
11361                    if (getDB().isSupportsInlineDistinct()) {
11362                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11363                    }
11364                    else {
11365                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11366                    }
11367    
11368                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11369    
11370                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11371    
11372                    boolean bindDisplayDate = false;
11373    
11374                    if (displayDate == null) {
11375                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11376                    }
11377                    else {
11378                            bindDisplayDate = true;
11379    
11380                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11381                    }
11382    
11383                    if (!getDB().isSupportsInlineDistinct()) {
11384                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11385                    }
11386    
11387                    if (orderByComparator != null) {
11388                            if (getDB().isSupportsInlineDistinct()) {
11389                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11390                                            orderByComparator, true);
11391                            }
11392                            else {
11393                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11394                                            orderByComparator, true);
11395                            }
11396                    }
11397                    else {
11398                            if (getDB().isSupportsInlineDistinct()) {
11399                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11400                            }
11401                            else {
11402                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11403                            }
11404                    }
11405    
11406                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11407                                    BlogsEntry.class.getName(),
11408                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11409    
11410                    Session session = null;
11411    
11412                    try {
11413                            session = openSession();
11414    
11415                            SQLQuery q = session.createSQLQuery(sql);
11416    
11417                            if (getDB().isSupportsInlineDistinct()) {
11418                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11419                            }
11420                            else {
11421                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11422                            }
11423    
11424                            QueryPos qPos = QueryPos.getInstance(q);
11425    
11426                            qPos.add(groupId);
11427    
11428                            qPos.add(userId);
11429    
11430                            if (bindDisplayDate) {
11431                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11432                            }
11433    
11434                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11435                    }
11436                    catch (Exception e) {
11437                            throw processException(e);
11438                    }
11439                    finally {
11440                            closeSession(session);
11441                    }
11442            }
11443    
11444            /**
11445             * 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;.
11446             *
11447             * @param entryId the primary key of the current blogs entry
11448             * @param groupId the group ID
11449             * @param userId the user ID
11450             * @param displayDate the display date
11451             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11452             * @return the previous, current, and next blogs entry
11453             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11454             * @throws SystemException if a system exception occurred
11455             */
11456            @Override
11457            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
11458                    long groupId, long userId, Date displayDate,
11459                    OrderByComparator orderByComparator)
11460                    throws NoSuchEntryException, SystemException {
11461                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11462                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
11463                                    displayDate, orderByComparator);
11464                    }
11465    
11466                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11467    
11468                    Session session = null;
11469    
11470                    try {
11471                            session = openSession();
11472    
11473                            BlogsEntry[] array = new BlogsEntryImpl[3];
11474    
11475                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11476                                            groupId, userId, displayDate, orderByComparator, true);
11477    
11478                            array[1] = blogsEntry;
11479    
11480                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11481                                            groupId, userId, displayDate, orderByComparator, false);
11482    
11483                            return array;
11484                    }
11485                    catch (Exception e) {
11486                            throw processException(e);
11487                    }
11488                    finally {
11489                            closeSession(session);
11490                    }
11491            }
11492    
11493            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
11494                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
11495                    OrderByComparator orderByComparator, boolean previous) {
11496                    StringBundler query = null;
11497    
11498                    if (orderByComparator != null) {
11499                            query = new StringBundler(6 +
11500                                            (orderByComparator.getOrderByFields().length * 6));
11501                    }
11502                    else {
11503                            query = new StringBundler(3);
11504                    }
11505    
11506                    if (getDB().isSupportsInlineDistinct()) {
11507                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11508                    }
11509                    else {
11510                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11511                    }
11512    
11513                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11514    
11515                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11516    
11517                    boolean bindDisplayDate = false;
11518    
11519                    if (displayDate == null) {
11520                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11521                    }
11522                    else {
11523                            bindDisplayDate = true;
11524    
11525                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11526                    }
11527    
11528                    if (!getDB().isSupportsInlineDistinct()) {
11529                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11530                    }
11531    
11532                    if (orderByComparator != null) {
11533                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11534    
11535                            if (orderByConditionFields.length > 0) {
11536                                    query.append(WHERE_AND);
11537                            }
11538    
11539                            for (int i = 0; i < orderByConditionFields.length; i++) {
11540                                    if (getDB().isSupportsInlineDistinct()) {
11541                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11542                                    }
11543                                    else {
11544                                            query.append(_ORDER_BY_ENTITY_TABLE);
11545                                    }
11546    
11547                                    query.append(orderByConditionFields[i]);
11548    
11549                                    if ((i + 1) < orderByConditionFields.length) {
11550                                            if (orderByComparator.isAscending() ^ previous) {
11551                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11552                                            }
11553                                            else {
11554                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11555                                            }
11556                                    }
11557                                    else {
11558                                            if (orderByComparator.isAscending() ^ previous) {
11559                                                    query.append(WHERE_GREATER_THAN);
11560                                            }
11561                                            else {
11562                                                    query.append(WHERE_LESSER_THAN);
11563                                            }
11564                                    }
11565                            }
11566    
11567                            query.append(ORDER_BY_CLAUSE);
11568    
11569                            String[] orderByFields = orderByComparator.getOrderByFields();
11570    
11571                            for (int i = 0; i < orderByFields.length; i++) {
11572                                    if (getDB().isSupportsInlineDistinct()) {
11573                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11574                                    }
11575                                    else {
11576                                            query.append(_ORDER_BY_ENTITY_TABLE);
11577                                    }
11578    
11579                                    query.append(orderByFields[i]);
11580    
11581                                    if ((i + 1) < orderByFields.length) {
11582                                            if (orderByComparator.isAscending() ^ previous) {
11583                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11584                                            }
11585                                            else {
11586                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11587                                            }
11588                                    }
11589                                    else {
11590                                            if (orderByComparator.isAscending() ^ previous) {
11591                                                    query.append(ORDER_BY_ASC);
11592                                            }
11593                                            else {
11594                                                    query.append(ORDER_BY_DESC);
11595                                            }
11596                                    }
11597                            }
11598                    }
11599                    else {
11600                            if (getDB().isSupportsInlineDistinct()) {
11601                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11602                            }
11603                            else {
11604                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11605                            }
11606                    }
11607    
11608                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11609                                    BlogsEntry.class.getName(),
11610                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11611    
11612                    SQLQuery q = session.createSQLQuery(sql);
11613    
11614                    q.setFirstResult(0);
11615                    q.setMaxResults(2);
11616    
11617                    if (getDB().isSupportsInlineDistinct()) {
11618                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11619                    }
11620                    else {
11621                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11622                    }
11623    
11624                    QueryPos qPos = QueryPos.getInstance(q);
11625    
11626                    qPos.add(groupId);
11627    
11628                    qPos.add(userId);
11629    
11630                    if (bindDisplayDate) {
11631                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11632                    }
11633    
11634                    if (orderByComparator != null) {
11635                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11636    
11637                            for (Object value : values) {
11638                                    qPos.add(value);
11639                            }
11640                    }
11641    
11642                    List<BlogsEntry> list = q.list();
11643    
11644                    if (list.size() == 2) {
11645                            return list.get(1);
11646                    }
11647                    else {
11648                            return null;
11649                    }
11650            }
11651    
11652            /**
11653             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
11654             *
11655             * @param groupId the group ID
11656             * @param userId the user ID
11657             * @param displayDate the display date
11658             * @throws SystemException if a system exception occurred
11659             */
11660            @Override
11661            public void removeByG_U_LtD(long groupId, long userId, Date displayDate)
11662                    throws SystemException {
11663                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
11664                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11665                            remove(blogsEntry);
11666                    }
11667            }
11668    
11669            /**
11670             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11671             *
11672             * @param groupId the group ID
11673             * @param userId the user ID
11674             * @param displayDate the display date
11675             * @return the number of matching blogs entries
11676             * @throws SystemException if a system exception occurred
11677             */
11678            @Override
11679            public int countByG_U_LtD(long groupId, long userId, Date displayDate)
11680                    throws SystemException {
11681                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
11682    
11683                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
11684    
11685                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11686                                    this);
11687    
11688                    if (count == null) {
11689                            StringBundler query = new StringBundler(4);
11690    
11691                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11692    
11693                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11694    
11695                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11696    
11697                            boolean bindDisplayDate = false;
11698    
11699                            if (displayDate == null) {
11700                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11701                            }
11702                            else {
11703                                    bindDisplayDate = true;
11704    
11705                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11706                            }
11707    
11708                            String sql = query.toString();
11709    
11710                            Session session = null;
11711    
11712                            try {
11713                                    session = openSession();
11714    
11715                                    Query q = session.createQuery(sql);
11716    
11717                                    QueryPos qPos = QueryPos.getInstance(q);
11718    
11719                                    qPos.add(groupId);
11720    
11721                                    qPos.add(userId);
11722    
11723                                    if (bindDisplayDate) {
11724                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11725                                    }
11726    
11727                                    count = (Long)q.uniqueResult();
11728    
11729                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11730                            }
11731                            catch (Exception e) {
11732                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11733    
11734                                    throw processException(e);
11735                            }
11736                            finally {
11737                                    closeSession(session);
11738                            }
11739                    }
11740    
11741                    return count.intValue();
11742            }
11743    
11744            /**
11745             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11746             *
11747             * @param groupId the group ID
11748             * @param userId the user ID
11749             * @param displayDate the display date
11750             * @return the number of matching blogs entries that the user has permission to view
11751             * @throws SystemException if a system exception occurred
11752             */
11753            @Override
11754            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate)
11755                    throws SystemException {
11756                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11757                            return countByG_U_LtD(groupId, userId, displayDate);
11758                    }
11759    
11760                    StringBundler query = new StringBundler(4);
11761    
11762                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11763    
11764                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11765    
11766                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11767    
11768                    boolean bindDisplayDate = false;
11769    
11770                    if (displayDate == null) {
11771                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11772                    }
11773                    else {
11774                            bindDisplayDate = true;
11775    
11776                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11777                    }
11778    
11779                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11780                                    BlogsEntry.class.getName(),
11781                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11782    
11783                    Session session = null;
11784    
11785                    try {
11786                            session = openSession();
11787    
11788                            SQLQuery q = session.createSQLQuery(sql);
11789    
11790                            q.addScalar(COUNT_COLUMN_NAME,
11791                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11792    
11793                            QueryPos qPos = QueryPos.getInstance(q);
11794    
11795                            qPos.add(groupId);
11796    
11797                            qPos.add(userId);
11798    
11799                            if (bindDisplayDate) {
11800                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11801                            }
11802    
11803                            Long count = (Long)q.uniqueResult();
11804    
11805                            return count.intValue();
11806                    }
11807                    catch (Exception e) {
11808                            throw processException(e);
11809                    }
11810                    finally {
11811                            closeSession(session);
11812                    }
11813            }
11814    
11815            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11816            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
11817            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
11818            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
11819            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11820                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11821                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
11822                            new String[] {
11823                                    Long.class.getName(), Long.class.getName(),
11824                                    Integer.class.getName(),
11825                                    
11826                            Integer.class.getName(), Integer.class.getName(),
11827                                    OrderByComparator.class.getName()
11828                            });
11829            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
11830                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11831                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11832                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
11833                            new String[] {
11834                                    Long.class.getName(), Long.class.getName(),
11835                                    Integer.class.getName()
11836                            });
11837    
11838            /**
11839             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11840             *
11841             * @param groupId the group ID
11842             * @param userId the user ID
11843             * @param status the status
11844             * @return the matching blogs entries
11845             * @throws SystemException if a system exception occurred
11846             */
11847            @Override
11848            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status)
11849                    throws SystemException {
11850                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11851                            QueryUtil.ALL_POS, null);
11852            }
11853    
11854            /**
11855             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11856             *
11857             * <p>
11858             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11859             * </p>
11860             *
11861             * @param groupId the group ID
11862             * @param userId the user ID
11863             * @param status the status
11864             * @param start the lower bound of the range of blogs entries
11865             * @param end the upper bound of the range of blogs entries (not inclusive)
11866             * @return the range of matching blogs entries
11867             * @throws SystemException if a system exception occurred
11868             */
11869            @Override
11870            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11871                    int status, int start, int end) throws SystemException {
11872                    return findByG_U_NotS(groupId, userId, status, start, end, null);
11873            }
11874    
11875            /**
11876             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11877             *
11878             * <p>
11879             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11880             * </p>
11881             *
11882             * @param groupId the group ID
11883             * @param userId the user ID
11884             * @param status the status
11885             * @param start the lower bound of the range of blogs entries
11886             * @param end the upper bound of the range of blogs entries (not inclusive)
11887             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11888             * @return the ordered range of matching blogs entries
11889             * @throws SystemException if a system exception occurred
11890             */
11891            @Override
11892            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11893                    int status, int start, int end, OrderByComparator orderByComparator)
11894                    throws SystemException {
11895                    boolean pagination = true;
11896                    FinderPath finderPath = null;
11897                    Object[] finderArgs = null;
11898    
11899                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
11900                    finderArgs = new Object[] {
11901                                    groupId, userId, status,
11902                                    
11903                                    start, end, orderByComparator
11904                            };
11905    
11906                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11907                                    finderArgs, this);
11908    
11909                    if ((list != null) && !list.isEmpty()) {
11910                            for (BlogsEntry blogsEntry : list) {
11911                                    if ((groupId != blogsEntry.getGroupId()) ||
11912                                                    (userId != blogsEntry.getUserId()) ||
11913                                                    (status == blogsEntry.getStatus())) {
11914                                            list = null;
11915    
11916                                            break;
11917                                    }
11918                            }
11919                    }
11920    
11921                    if (list == null) {
11922                            StringBundler query = null;
11923    
11924                            if (orderByComparator != null) {
11925                                    query = new StringBundler(5 +
11926                                                    (orderByComparator.getOrderByFields().length * 3));
11927                            }
11928                            else {
11929                                    query = new StringBundler(5);
11930                            }
11931    
11932                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11933    
11934                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11935    
11936                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11937    
11938                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11939    
11940                            if (orderByComparator != null) {
11941                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11942                                            orderByComparator);
11943                            }
11944                            else
11945                             if (pagination) {
11946                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11947                            }
11948    
11949                            String sql = query.toString();
11950    
11951                            Session session = null;
11952    
11953                            try {
11954                                    session = openSession();
11955    
11956                                    Query q = session.createQuery(sql);
11957    
11958                                    QueryPos qPos = QueryPos.getInstance(q);
11959    
11960                                    qPos.add(groupId);
11961    
11962                                    qPos.add(userId);
11963    
11964                                    qPos.add(status);
11965    
11966                                    if (!pagination) {
11967                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11968                                                            start, end, false);
11969    
11970                                            Collections.sort(list);
11971    
11972                                            list = new UnmodifiableList<BlogsEntry>(list);
11973                                    }
11974                                    else {
11975                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11976                                                            start, end);
11977                                    }
11978    
11979                                    cacheResult(list);
11980    
11981                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11982                            }
11983                            catch (Exception e) {
11984                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11985    
11986                                    throw processException(e);
11987                            }
11988                            finally {
11989                                    closeSession(session);
11990                            }
11991                    }
11992    
11993                    return list;
11994            }
11995    
11996            /**
11997             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11998             *
11999             * @param groupId the group ID
12000             * @param userId the user ID
12001             * @param status the status
12002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12003             * @return the first matching blogs entry
12004             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12005             * @throws SystemException if a system exception occurred
12006             */
12007            @Override
12008            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
12009                    int status, OrderByComparator orderByComparator)
12010                    throws NoSuchEntryException, SystemException {
12011                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
12012                                    orderByComparator);
12013    
12014                    if (blogsEntry != null) {
12015                            return blogsEntry;
12016                    }
12017    
12018                    StringBundler msg = new StringBundler(8);
12019    
12020                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12021    
12022                    msg.append("groupId=");
12023                    msg.append(groupId);
12024    
12025                    msg.append(", userId=");
12026                    msg.append(userId);
12027    
12028                    msg.append(", status=");
12029                    msg.append(status);
12030    
12031                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12032    
12033                    throw new NoSuchEntryException(msg.toString());
12034            }
12035    
12036            /**
12037             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12038             *
12039             * @param groupId the group ID
12040             * @param userId the user ID
12041             * @param status the status
12042             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12043             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12044             * @throws SystemException if a system exception occurred
12045             */
12046            @Override
12047            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
12048                    int status, OrderByComparator orderByComparator)
12049                    throws SystemException {
12050                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
12051                                    orderByComparator);
12052    
12053                    if (!list.isEmpty()) {
12054                            return list.get(0);
12055                    }
12056    
12057                    return null;
12058            }
12059    
12060            /**
12061             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12062             *
12063             * @param groupId the group ID
12064             * @param userId the user ID
12065             * @param status the status
12066             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12067             * @return the last matching blogs entry
12068             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12069             * @throws SystemException if a system exception occurred
12070             */
12071            @Override
12072            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
12073                    int status, OrderByComparator orderByComparator)
12074                    throws NoSuchEntryException, SystemException {
12075                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
12076                                    orderByComparator);
12077    
12078                    if (blogsEntry != null) {
12079                            return blogsEntry;
12080                    }
12081    
12082                    StringBundler msg = new StringBundler(8);
12083    
12084                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12085    
12086                    msg.append("groupId=");
12087                    msg.append(groupId);
12088    
12089                    msg.append(", userId=");
12090                    msg.append(userId);
12091    
12092                    msg.append(", status=");
12093                    msg.append(status);
12094    
12095                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12096    
12097                    throw new NoSuchEntryException(msg.toString());
12098            }
12099    
12100            /**
12101             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12102             *
12103             * @param groupId the group ID
12104             * @param userId the user ID
12105             * @param status the status
12106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12107             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12108             * @throws SystemException if a system exception occurred
12109             */
12110            @Override
12111            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
12112                    int status, OrderByComparator orderByComparator)
12113                    throws SystemException {
12114                    int count = countByG_U_NotS(groupId, userId, status);
12115    
12116                    if (count == 0) {
12117                            return null;
12118                    }
12119    
12120                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
12121                                    count - 1, count, orderByComparator);
12122    
12123                    if (!list.isEmpty()) {
12124                            return list.get(0);
12125                    }
12126    
12127                    return null;
12128            }
12129    
12130            /**
12131             * 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;.
12132             *
12133             * @param entryId the primary key of the current blogs entry
12134             * @param groupId the group ID
12135             * @param userId the user ID
12136             * @param status the status
12137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12138             * @return the previous, current, and next blogs entry
12139             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12140             * @throws SystemException if a system exception occurred
12141             */
12142            @Override
12143            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
12144                    long userId, int status, OrderByComparator orderByComparator)
12145                    throws NoSuchEntryException, SystemException {
12146                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12147    
12148                    Session session = null;
12149    
12150                    try {
12151                            session = openSession();
12152    
12153                            BlogsEntry[] array = new BlogsEntryImpl[3];
12154    
12155                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
12156                                            userId, status, orderByComparator, true);
12157    
12158                            array[1] = blogsEntry;
12159    
12160                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
12161                                            userId, status, orderByComparator, false);
12162    
12163                            return array;
12164                    }
12165                    catch (Exception e) {
12166                            throw processException(e);
12167                    }
12168                    finally {
12169                            closeSession(session);
12170                    }
12171            }
12172    
12173            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
12174                    BlogsEntry blogsEntry, long groupId, long userId, int status,
12175                    OrderByComparator orderByComparator, boolean previous) {
12176                    StringBundler query = null;
12177    
12178                    if (orderByComparator != null) {
12179                            query = new StringBundler(6 +
12180                                            (orderByComparator.getOrderByFields().length * 6));
12181                    }
12182                    else {
12183                            query = new StringBundler(3);
12184                    }
12185    
12186                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12187    
12188                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12189    
12190                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12191    
12192                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12193    
12194                    if (orderByComparator != null) {
12195                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12196    
12197                            if (orderByConditionFields.length > 0) {
12198                                    query.append(WHERE_AND);
12199                            }
12200    
12201                            for (int i = 0; i < orderByConditionFields.length; i++) {
12202                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12203                                    query.append(orderByConditionFields[i]);
12204    
12205                                    if ((i + 1) < orderByConditionFields.length) {
12206                                            if (orderByComparator.isAscending() ^ previous) {
12207                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12208                                            }
12209                                            else {
12210                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12211                                            }
12212                                    }
12213                                    else {
12214                                            if (orderByComparator.isAscending() ^ previous) {
12215                                                    query.append(WHERE_GREATER_THAN);
12216                                            }
12217                                            else {
12218                                                    query.append(WHERE_LESSER_THAN);
12219                                            }
12220                                    }
12221                            }
12222    
12223                            query.append(ORDER_BY_CLAUSE);
12224    
12225                            String[] orderByFields = orderByComparator.getOrderByFields();
12226    
12227                            for (int i = 0; i < orderByFields.length; i++) {
12228                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12229                                    query.append(orderByFields[i]);
12230    
12231                                    if ((i + 1) < orderByFields.length) {
12232                                            if (orderByComparator.isAscending() ^ previous) {
12233                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12234                                            }
12235                                            else {
12236                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12237                                            }
12238                                    }
12239                                    else {
12240                                            if (orderByComparator.isAscending() ^ previous) {
12241                                                    query.append(ORDER_BY_ASC);
12242                                            }
12243                                            else {
12244                                                    query.append(ORDER_BY_DESC);
12245                                            }
12246                                    }
12247                            }
12248                    }
12249                    else {
12250                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12251                    }
12252    
12253                    String sql = query.toString();
12254    
12255                    Query q = session.createQuery(sql);
12256    
12257                    q.setFirstResult(0);
12258                    q.setMaxResults(2);
12259    
12260                    QueryPos qPos = QueryPos.getInstance(q);
12261    
12262                    qPos.add(groupId);
12263    
12264                    qPos.add(userId);
12265    
12266                    qPos.add(status);
12267    
12268                    if (orderByComparator != null) {
12269                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12270    
12271                            for (Object value : values) {
12272                                    qPos.add(value);
12273                            }
12274                    }
12275    
12276                    List<BlogsEntry> list = q.list();
12277    
12278                    if (list.size() == 2) {
12279                            return list.get(1);
12280                    }
12281                    else {
12282                            return null;
12283                    }
12284            }
12285    
12286            /**
12287             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12288             *
12289             * @param groupId the group ID
12290             * @param userId the user ID
12291             * @param status the status
12292             * @return the matching blogs entries that the user has permission to view
12293             * @throws SystemException if a system exception occurred
12294             */
12295            @Override
12296            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12297                    int status) throws SystemException {
12298                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
12299                            QueryUtil.ALL_POS, null);
12300            }
12301    
12302            /**
12303             * 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;.
12304             *
12305             * <p>
12306             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12307             * </p>
12308             *
12309             * @param groupId the group ID
12310             * @param userId the user ID
12311             * @param status the status
12312             * @param start the lower bound of the range of blogs entries
12313             * @param end the upper bound of the range of blogs entries (not inclusive)
12314             * @return the range of matching blogs entries that the user has permission to view
12315             * @throws SystemException if a system exception occurred
12316             */
12317            @Override
12318            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12319                    int status, int start, int end) throws SystemException {
12320                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
12321            }
12322    
12323            /**
12324             * 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;.
12325             *
12326             * <p>
12327             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12328             * </p>
12329             *
12330             * @param groupId the group ID
12331             * @param userId the user ID
12332             * @param status the status
12333             * @param start the lower bound of the range of blogs entries
12334             * @param end the upper bound of the range of blogs entries (not inclusive)
12335             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12336             * @return the ordered range of matching blogs entries that the user has permission to view
12337             * @throws SystemException if a system exception occurred
12338             */
12339            @Override
12340            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12341                    int status, int start, int end, OrderByComparator orderByComparator)
12342                    throws SystemException {
12343                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12344                            return findByG_U_NotS(groupId, userId, status, start, end,
12345                                    orderByComparator);
12346                    }
12347    
12348                    StringBundler query = null;
12349    
12350                    if (orderByComparator != null) {
12351                            query = new StringBundler(5 +
12352                                            (orderByComparator.getOrderByFields().length * 3));
12353                    }
12354                    else {
12355                            query = new StringBundler(5);
12356                    }
12357    
12358                    if (getDB().isSupportsInlineDistinct()) {
12359                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12360                    }
12361                    else {
12362                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12363                    }
12364    
12365                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12366    
12367                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12368    
12369                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12370    
12371                    if (!getDB().isSupportsInlineDistinct()) {
12372                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12373                    }
12374    
12375                    if (orderByComparator != null) {
12376                            if (getDB().isSupportsInlineDistinct()) {
12377                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12378                                            orderByComparator, true);
12379                            }
12380                            else {
12381                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12382                                            orderByComparator, true);
12383                            }
12384                    }
12385                    else {
12386                            if (getDB().isSupportsInlineDistinct()) {
12387                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12388                            }
12389                            else {
12390                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12391                            }
12392                    }
12393    
12394                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12395                                    BlogsEntry.class.getName(),
12396                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12397    
12398                    Session session = null;
12399    
12400                    try {
12401                            session = openSession();
12402    
12403                            SQLQuery q = session.createSQLQuery(sql);
12404    
12405                            if (getDB().isSupportsInlineDistinct()) {
12406                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12407                            }
12408                            else {
12409                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12410                            }
12411    
12412                            QueryPos qPos = QueryPos.getInstance(q);
12413    
12414                            qPos.add(groupId);
12415    
12416                            qPos.add(userId);
12417    
12418                            qPos.add(status);
12419    
12420                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12421                    }
12422                    catch (Exception e) {
12423                            throw processException(e);
12424                    }
12425                    finally {
12426                            closeSession(session);
12427                    }
12428            }
12429    
12430            /**
12431             * 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;.
12432             *
12433             * @param entryId the primary key of the current blogs entry
12434             * @param groupId the group ID
12435             * @param userId the user ID
12436             * @param status the status
12437             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12438             * @return the previous, current, and next blogs entry
12439             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12440             * @throws SystemException if a system exception occurred
12441             */
12442            @Override
12443            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
12444                    long groupId, long userId, int status,
12445                    OrderByComparator orderByComparator)
12446                    throws NoSuchEntryException, SystemException {
12447                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12448                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
12449                                    orderByComparator);
12450                    }
12451    
12452                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12453    
12454                    Session session = null;
12455    
12456                    try {
12457                            session = openSession();
12458    
12459                            BlogsEntry[] array = new BlogsEntryImpl[3];
12460    
12461                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12462                                            groupId, userId, status, orderByComparator, true);
12463    
12464                            array[1] = blogsEntry;
12465    
12466                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12467                                            groupId, userId, status, orderByComparator, false);
12468    
12469                            return array;
12470                    }
12471                    catch (Exception e) {
12472                            throw processException(e);
12473                    }
12474                    finally {
12475                            closeSession(session);
12476                    }
12477            }
12478    
12479            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
12480                    BlogsEntry blogsEntry, long groupId, long userId, int status,
12481                    OrderByComparator orderByComparator, boolean previous) {
12482                    StringBundler query = null;
12483    
12484                    if (orderByComparator != null) {
12485                            query = new StringBundler(6 +
12486                                            (orderByComparator.getOrderByFields().length * 6));
12487                    }
12488                    else {
12489                            query = new StringBundler(3);
12490                    }
12491    
12492                    if (getDB().isSupportsInlineDistinct()) {
12493                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12494                    }
12495                    else {
12496                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12497                    }
12498    
12499                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12500    
12501                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12502    
12503                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12504    
12505                    if (!getDB().isSupportsInlineDistinct()) {
12506                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12507                    }
12508    
12509                    if (orderByComparator != null) {
12510                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12511    
12512                            if (orderByConditionFields.length > 0) {
12513                                    query.append(WHERE_AND);
12514                            }
12515    
12516                            for (int i = 0; i < orderByConditionFields.length; i++) {
12517                                    if (getDB().isSupportsInlineDistinct()) {
12518                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12519                                    }
12520                                    else {
12521                                            query.append(_ORDER_BY_ENTITY_TABLE);
12522                                    }
12523    
12524                                    query.append(orderByConditionFields[i]);
12525    
12526                                    if ((i + 1) < orderByConditionFields.length) {
12527                                            if (orderByComparator.isAscending() ^ previous) {
12528                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12529                                            }
12530                                            else {
12531                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12532                                            }
12533                                    }
12534                                    else {
12535                                            if (orderByComparator.isAscending() ^ previous) {
12536                                                    query.append(WHERE_GREATER_THAN);
12537                                            }
12538                                            else {
12539                                                    query.append(WHERE_LESSER_THAN);
12540                                            }
12541                                    }
12542                            }
12543    
12544                            query.append(ORDER_BY_CLAUSE);
12545    
12546                            String[] orderByFields = orderByComparator.getOrderByFields();
12547    
12548                            for (int i = 0; i < orderByFields.length; i++) {
12549                                    if (getDB().isSupportsInlineDistinct()) {
12550                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12551                                    }
12552                                    else {
12553                                            query.append(_ORDER_BY_ENTITY_TABLE);
12554                                    }
12555    
12556                                    query.append(orderByFields[i]);
12557    
12558                                    if ((i + 1) < orderByFields.length) {
12559                                            if (orderByComparator.isAscending() ^ previous) {
12560                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12561                                            }
12562                                            else {
12563                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12564                                            }
12565                                    }
12566                                    else {
12567                                            if (orderByComparator.isAscending() ^ previous) {
12568                                                    query.append(ORDER_BY_ASC);
12569                                            }
12570                                            else {
12571                                                    query.append(ORDER_BY_DESC);
12572                                            }
12573                                    }
12574                            }
12575                    }
12576                    else {
12577                            if (getDB().isSupportsInlineDistinct()) {
12578                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12579                            }
12580                            else {
12581                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12582                            }
12583                    }
12584    
12585                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12586                                    BlogsEntry.class.getName(),
12587                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12588    
12589                    SQLQuery q = session.createSQLQuery(sql);
12590    
12591                    q.setFirstResult(0);
12592                    q.setMaxResults(2);
12593    
12594                    if (getDB().isSupportsInlineDistinct()) {
12595                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12596                    }
12597                    else {
12598                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12599                    }
12600    
12601                    QueryPos qPos = QueryPos.getInstance(q);
12602    
12603                    qPos.add(groupId);
12604    
12605                    qPos.add(userId);
12606    
12607                    qPos.add(status);
12608    
12609                    if (orderByComparator != null) {
12610                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12611    
12612                            for (Object value : values) {
12613                                    qPos.add(value);
12614                            }
12615                    }
12616    
12617                    List<BlogsEntry> list = q.list();
12618    
12619                    if (list.size() == 2) {
12620                            return list.get(1);
12621                    }
12622                    else {
12623                            return null;
12624                    }
12625            }
12626    
12627            /**
12628             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
12629             *
12630             * @param groupId the group ID
12631             * @param userId the user ID
12632             * @param status the status
12633             * @throws SystemException if a system exception occurred
12634             */
12635            @Override
12636            public void removeByG_U_NotS(long groupId, long userId, int status)
12637                    throws SystemException {
12638                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
12639                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12640                            remove(blogsEntry);
12641                    }
12642            }
12643    
12644            /**
12645             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12646             *
12647             * @param groupId the group ID
12648             * @param userId the user ID
12649             * @param status the status
12650             * @return the number of matching blogs entries
12651             * @throws SystemException if a system exception occurred
12652             */
12653            @Override
12654            public int countByG_U_NotS(long groupId, long userId, int status)
12655                    throws SystemException {
12656                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
12657    
12658                    Object[] finderArgs = new Object[] { groupId, userId, status };
12659    
12660                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12661                                    this);
12662    
12663                    if (count == null) {
12664                            StringBundler query = new StringBundler(4);
12665    
12666                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12667    
12668                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12669    
12670                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12671    
12672                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12673    
12674                            String sql = query.toString();
12675    
12676                            Session session = null;
12677    
12678                            try {
12679                                    session = openSession();
12680    
12681                                    Query q = session.createQuery(sql);
12682    
12683                                    QueryPos qPos = QueryPos.getInstance(q);
12684    
12685                                    qPos.add(groupId);
12686    
12687                                    qPos.add(userId);
12688    
12689                                    qPos.add(status);
12690    
12691                                    count = (Long)q.uniqueResult();
12692    
12693                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12694                            }
12695                            catch (Exception e) {
12696                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12697    
12698                                    throw processException(e);
12699                            }
12700                            finally {
12701                                    closeSession(session);
12702                            }
12703                    }
12704    
12705                    return count.intValue();
12706            }
12707    
12708            /**
12709             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12710             *
12711             * @param groupId the group ID
12712             * @param userId the user ID
12713             * @param status the status
12714             * @return the number of matching blogs entries that the user has permission to view
12715             * @throws SystemException if a system exception occurred
12716             */
12717            @Override
12718            public int filterCountByG_U_NotS(long groupId, long userId, int status)
12719                    throws SystemException {
12720                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12721                            return countByG_U_NotS(groupId, userId, status);
12722                    }
12723    
12724                    StringBundler query = new StringBundler(4);
12725    
12726                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12727    
12728                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12729    
12730                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12731    
12732                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12733    
12734                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12735                                    BlogsEntry.class.getName(),
12736                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12737    
12738                    Session session = null;
12739    
12740                    try {
12741                            session = openSession();
12742    
12743                            SQLQuery q = session.createSQLQuery(sql);
12744    
12745                            q.addScalar(COUNT_COLUMN_NAME,
12746                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12747    
12748                            QueryPos qPos = QueryPos.getInstance(q);
12749    
12750                            qPos.add(groupId);
12751    
12752                            qPos.add(userId);
12753    
12754                            qPos.add(status);
12755    
12756                            Long count = (Long)q.uniqueResult();
12757    
12758                            return count.intValue();
12759                    }
12760                    catch (Exception e) {
12761                            throw processException(e);
12762                    }
12763                    finally {
12764                            closeSession(session);
12765                    }
12766            }
12767    
12768            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12769            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
12770            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
12771            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12772                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12773                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
12774                            new String[] {
12775                                    Long.class.getName(), Long.class.getName(),
12776                                    Integer.class.getName(),
12777                                    
12778                            Integer.class.getName(), Integer.class.getName(),
12779                                    OrderByComparator.class.getName()
12780                            });
12781            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12782                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12783                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
12784                            new String[] {
12785                                    Long.class.getName(), Long.class.getName(),
12786                                    Integer.class.getName()
12787                            },
12788                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
12789                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
12790                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
12791                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
12792                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
12793            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12794                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12795                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
12796                            new String[] {
12797                                    Long.class.getName(), Long.class.getName(),
12798                                    Integer.class.getName()
12799                            });
12800    
12801            /**
12802             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12803             *
12804             * @param groupId the group ID
12805             * @param userId the user ID
12806             * @param status the status
12807             * @return the matching blogs entries
12808             * @throws SystemException if a system exception occurred
12809             */
12810            @Override
12811            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status)
12812                    throws SystemException {
12813                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
12814                            QueryUtil.ALL_POS, null);
12815            }
12816    
12817            /**
12818             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12819             *
12820             * <p>
12821             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12822             * </p>
12823             *
12824             * @param groupId the group ID
12825             * @param userId the user ID
12826             * @param status the status
12827             * @param start the lower bound of the range of blogs entries
12828             * @param end the upper bound of the range of blogs entries (not inclusive)
12829             * @return the range of matching blogs entries
12830             * @throws SystemException if a system exception occurred
12831             */
12832            @Override
12833            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12834                    int start, int end) throws SystemException {
12835                    return findByG_U_S(groupId, userId, status, start, end, null);
12836            }
12837    
12838            /**
12839             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12840             *
12841             * <p>
12842             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12843             * </p>
12844             *
12845             * @param groupId the group ID
12846             * @param userId the user ID
12847             * @param status the status
12848             * @param start the lower bound of the range of blogs entries
12849             * @param end the upper bound of the range of blogs entries (not inclusive)
12850             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12851             * @return the ordered range of matching blogs entries
12852             * @throws SystemException if a system exception occurred
12853             */
12854            @Override
12855            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12856                    int start, int end, OrderByComparator orderByComparator)
12857                    throws SystemException {
12858                    boolean pagination = true;
12859                    FinderPath finderPath = null;
12860                    Object[] finderArgs = null;
12861    
12862                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12863                                    (orderByComparator == null)) {
12864                            pagination = false;
12865                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
12866                            finderArgs = new Object[] { groupId, userId, status };
12867                    }
12868                    else {
12869                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
12870                            finderArgs = new Object[] {
12871                                            groupId, userId, status,
12872                                            
12873                                            start, end, orderByComparator
12874                                    };
12875                    }
12876    
12877                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
12878                                    finderArgs, this);
12879    
12880                    if ((list != null) && !list.isEmpty()) {
12881                            for (BlogsEntry blogsEntry : list) {
12882                                    if ((groupId != blogsEntry.getGroupId()) ||
12883                                                    (userId != blogsEntry.getUserId()) ||
12884                                                    (status != blogsEntry.getStatus())) {
12885                                            list = null;
12886    
12887                                            break;
12888                                    }
12889                            }
12890                    }
12891    
12892                    if (list == null) {
12893                            StringBundler query = null;
12894    
12895                            if (orderByComparator != null) {
12896                                    query = new StringBundler(5 +
12897                                                    (orderByComparator.getOrderByFields().length * 3));
12898                            }
12899                            else {
12900                                    query = new StringBundler(5);
12901                            }
12902    
12903                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12904    
12905                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
12906    
12907                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
12908    
12909                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
12910    
12911                            if (orderByComparator != null) {
12912                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12913                                            orderByComparator);
12914                            }
12915                            else
12916                             if (pagination) {
12917                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12918                            }
12919    
12920                            String sql = query.toString();
12921    
12922                            Session session = null;
12923    
12924                            try {
12925                                    session = openSession();
12926    
12927                                    Query q = session.createQuery(sql);
12928    
12929                                    QueryPos qPos = QueryPos.getInstance(q);
12930    
12931                                    qPos.add(groupId);
12932    
12933                                    qPos.add(userId);
12934    
12935                                    qPos.add(status);
12936    
12937                                    if (!pagination) {
12938                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12939                                                            start, end, false);
12940    
12941                                            Collections.sort(list);
12942    
12943                                            list = new UnmodifiableList<BlogsEntry>(list);
12944                                    }
12945                                    else {
12946                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12947                                                            start, end);
12948                                    }
12949    
12950                                    cacheResult(list);
12951    
12952                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12953                            }
12954                            catch (Exception e) {
12955                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12956    
12957                                    throw processException(e);
12958                            }
12959                            finally {
12960                                    closeSession(session);
12961                            }
12962                    }
12963    
12964                    return list;
12965            }
12966    
12967            /**
12968             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
12969             *
12970             * @param groupId the group ID
12971             * @param userId the user ID
12972             * @param status the status
12973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12974             * @return the first matching blogs entry
12975             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12976             * @throws SystemException if a system exception occurred
12977             */
12978            @Override
12979            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
12980                    OrderByComparator orderByComparator)
12981                    throws NoSuchEntryException, SystemException {
12982                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
12983                                    orderByComparator);
12984    
12985                    if (blogsEntry != null) {
12986                            return blogsEntry;
12987                    }
12988    
12989                    StringBundler msg = new StringBundler(8);
12990    
12991                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12992    
12993                    msg.append("groupId=");
12994                    msg.append(groupId);
12995    
12996                    msg.append(", userId=");
12997                    msg.append(userId);
12998    
12999                    msg.append(", status=");
13000                    msg.append(status);
13001    
13002                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13003    
13004                    throw new NoSuchEntryException(msg.toString());
13005            }
13006    
13007            /**
13008             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13009             *
13010             * @param groupId the group ID
13011             * @param userId the user ID
13012             * @param status the status
13013             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13014             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13015             * @throws SystemException if a system exception occurred
13016             */
13017            @Override
13018            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
13019                    OrderByComparator orderByComparator) throws SystemException {
13020                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
13021                                    orderByComparator);
13022    
13023                    if (!list.isEmpty()) {
13024                            return list.get(0);
13025                    }
13026    
13027                    return null;
13028            }
13029    
13030            /**
13031             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13032             *
13033             * @param groupId the group ID
13034             * @param userId the user ID
13035             * @param status the status
13036             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13037             * @return the last matching blogs entry
13038             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13039             * @throws SystemException if a system exception occurred
13040             */
13041            @Override
13042            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
13043                    OrderByComparator orderByComparator)
13044                    throws NoSuchEntryException, SystemException {
13045                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
13046                                    orderByComparator);
13047    
13048                    if (blogsEntry != null) {
13049                            return blogsEntry;
13050                    }
13051    
13052                    StringBundler msg = new StringBundler(8);
13053    
13054                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13055    
13056                    msg.append("groupId=");
13057                    msg.append(groupId);
13058    
13059                    msg.append(", userId=");
13060                    msg.append(userId);
13061    
13062                    msg.append(", status=");
13063                    msg.append(status);
13064    
13065                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13066    
13067                    throw new NoSuchEntryException(msg.toString());
13068            }
13069    
13070            /**
13071             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13072             *
13073             * @param groupId the group ID
13074             * @param userId the user ID
13075             * @param status the status
13076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13077             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13078             * @throws SystemException if a system exception occurred
13079             */
13080            @Override
13081            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
13082                    OrderByComparator orderByComparator) throws SystemException {
13083                    int count = countByG_U_S(groupId, userId, status);
13084    
13085                    if (count == 0) {
13086                            return null;
13087                    }
13088    
13089                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
13090                                    count, orderByComparator);
13091    
13092                    if (!list.isEmpty()) {
13093                            return list.get(0);
13094                    }
13095    
13096                    return null;
13097            }
13098    
13099            /**
13100             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13101             *
13102             * @param entryId the primary key of the current blogs entry
13103             * @param groupId the group ID
13104             * @param userId the user ID
13105             * @param status the status
13106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13107             * @return the previous, current, and next blogs entry
13108             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13109             * @throws SystemException if a system exception occurred
13110             */
13111            @Override
13112            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
13113                    long userId, int status, OrderByComparator orderByComparator)
13114                    throws NoSuchEntryException, SystemException {
13115                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13116    
13117                    Session session = null;
13118    
13119                    try {
13120                            session = openSession();
13121    
13122                            BlogsEntry[] array = new BlogsEntryImpl[3];
13123    
13124                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
13125                                            userId, status, orderByComparator, true);
13126    
13127                            array[1] = blogsEntry;
13128    
13129                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
13130                                            userId, status, orderByComparator, false);
13131    
13132                            return array;
13133                    }
13134                    catch (Exception e) {
13135                            throw processException(e);
13136                    }
13137                    finally {
13138                            closeSession(session);
13139                    }
13140            }
13141    
13142            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
13143                    BlogsEntry blogsEntry, long groupId, long userId, int status,
13144                    OrderByComparator orderByComparator, boolean previous) {
13145                    StringBundler query = null;
13146    
13147                    if (orderByComparator != null) {
13148                            query = new StringBundler(6 +
13149                                            (orderByComparator.getOrderByFields().length * 6));
13150                    }
13151                    else {
13152                            query = new StringBundler(3);
13153                    }
13154    
13155                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13156    
13157                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13158    
13159                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13160    
13161                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13162    
13163                    if (orderByComparator != null) {
13164                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13165    
13166                            if (orderByConditionFields.length > 0) {
13167                                    query.append(WHERE_AND);
13168                            }
13169    
13170                            for (int i = 0; i < orderByConditionFields.length; i++) {
13171                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13172                                    query.append(orderByConditionFields[i]);
13173    
13174                                    if ((i + 1) < orderByConditionFields.length) {
13175                                            if (orderByComparator.isAscending() ^ previous) {
13176                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13177                                            }
13178                                            else {
13179                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13180                                            }
13181                                    }
13182                                    else {
13183                                            if (orderByComparator.isAscending() ^ previous) {
13184                                                    query.append(WHERE_GREATER_THAN);
13185                                            }
13186                                            else {
13187                                                    query.append(WHERE_LESSER_THAN);
13188                                            }
13189                                    }
13190                            }
13191    
13192                            query.append(ORDER_BY_CLAUSE);
13193    
13194                            String[] orderByFields = orderByComparator.getOrderByFields();
13195    
13196                            for (int i = 0; i < orderByFields.length; i++) {
13197                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13198                                    query.append(orderByFields[i]);
13199    
13200                                    if ((i + 1) < orderByFields.length) {
13201                                            if (orderByComparator.isAscending() ^ previous) {
13202                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13203                                            }
13204                                            else {
13205                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13206                                            }
13207                                    }
13208                                    else {
13209                                            if (orderByComparator.isAscending() ^ previous) {
13210                                                    query.append(ORDER_BY_ASC);
13211                                            }
13212                                            else {
13213                                                    query.append(ORDER_BY_DESC);
13214                                            }
13215                                    }
13216                            }
13217                    }
13218                    else {
13219                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13220                    }
13221    
13222                    String sql = query.toString();
13223    
13224                    Query q = session.createQuery(sql);
13225    
13226                    q.setFirstResult(0);
13227                    q.setMaxResults(2);
13228    
13229                    QueryPos qPos = QueryPos.getInstance(q);
13230    
13231                    qPos.add(groupId);
13232    
13233                    qPos.add(userId);
13234    
13235                    qPos.add(status);
13236    
13237                    if (orderByComparator != null) {
13238                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13239    
13240                            for (Object value : values) {
13241                                    qPos.add(value);
13242                            }
13243                    }
13244    
13245                    List<BlogsEntry> list = q.list();
13246    
13247                    if (list.size() == 2) {
13248                            return list.get(1);
13249                    }
13250                    else {
13251                            return null;
13252                    }
13253            }
13254    
13255            /**
13256             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
13257             *
13258             * @param groupId the group ID
13259             * @param userId the user ID
13260             * @param status the status
13261             * @return the matching blogs entries that the user has permission to view
13262             * @throws SystemException if a system exception occurred
13263             */
13264            @Override
13265            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
13266                    int status) throws SystemException {
13267                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
13268                            QueryUtil.ALL_POS, null);
13269            }
13270    
13271            /**
13272             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
13273             *
13274             * <p>
13275             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13276             * </p>
13277             *
13278             * @param groupId the group ID
13279             * @param userId the user ID
13280             * @param status the status
13281             * @param start the lower bound of the range of blogs entries
13282             * @param end the upper bound of the range of blogs entries (not inclusive)
13283             * @return the range of matching blogs entries that the user has permission to view
13284             * @throws SystemException if a system exception occurred
13285             */
13286            @Override
13287            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
13288                    int status, int start, int end) throws SystemException {
13289                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
13290            }
13291    
13292            /**
13293             * 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;.
13294             *
13295             * <p>
13296             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13297             * </p>
13298             *
13299             * @param groupId the group ID
13300             * @param userId the user ID
13301             * @param status the status
13302             * @param start the lower bound of the range of blogs entries
13303             * @param end the upper bound of the range of blogs entries (not inclusive)
13304             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13305             * @return the ordered range of matching blogs entries that the user has permission to view
13306             * @throws SystemException if a system exception occurred
13307             */
13308            @Override
13309            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
13310                    int status, int start, int end, OrderByComparator orderByComparator)
13311                    throws SystemException {
13312                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13313                            return findByG_U_S(groupId, userId, status, start, end,
13314                                    orderByComparator);
13315                    }
13316    
13317                    StringBundler query = null;
13318    
13319                    if (orderByComparator != null) {
13320                            query = new StringBundler(5 +
13321                                            (orderByComparator.getOrderByFields().length * 3));
13322                    }
13323                    else {
13324                            query = new StringBundler(5);
13325                    }
13326    
13327                    if (getDB().isSupportsInlineDistinct()) {
13328                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13329                    }
13330                    else {
13331                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13332                    }
13333    
13334                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13335    
13336                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13337    
13338                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13339    
13340                    if (!getDB().isSupportsInlineDistinct()) {
13341                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13342                    }
13343    
13344                    if (orderByComparator != null) {
13345                            if (getDB().isSupportsInlineDistinct()) {
13346                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13347                                            orderByComparator, true);
13348                            }
13349                            else {
13350                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13351                                            orderByComparator, true);
13352                            }
13353                    }
13354                    else {
13355                            if (getDB().isSupportsInlineDistinct()) {
13356                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13357                            }
13358                            else {
13359                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13360                            }
13361                    }
13362    
13363                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13364                                    BlogsEntry.class.getName(),
13365                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13366    
13367                    Session session = null;
13368    
13369                    try {
13370                            session = openSession();
13371    
13372                            SQLQuery q = session.createSQLQuery(sql);
13373    
13374                            if (getDB().isSupportsInlineDistinct()) {
13375                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13376                            }
13377                            else {
13378                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13379                            }
13380    
13381                            QueryPos qPos = QueryPos.getInstance(q);
13382    
13383                            qPos.add(groupId);
13384    
13385                            qPos.add(userId);
13386    
13387                            qPos.add(status);
13388    
13389                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13390                    }
13391                    catch (Exception e) {
13392                            throw processException(e);
13393                    }
13394                    finally {
13395                            closeSession(session);
13396                    }
13397            }
13398    
13399            /**
13400             * 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;.
13401             *
13402             * @param entryId the primary key of the current blogs entry
13403             * @param groupId the group ID
13404             * @param userId the user ID
13405             * @param status the status
13406             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13407             * @return the previous, current, and next blogs entry
13408             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13409             * @throws SystemException if a system exception occurred
13410             */
13411            @Override
13412            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
13413                    long groupId, long userId, int status,
13414                    OrderByComparator orderByComparator)
13415                    throws NoSuchEntryException, SystemException {
13416                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13417                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
13418                                    orderByComparator);
13419                    }
13420    
13421                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13422    
13423                    Session session = null;
13424    
13425                    try {
13426                            session = openSession();
13427    
13428                            BlogsEntry[] array = new BlogsEntryImpl[3];
13429    
13430                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13431                                            groupId, userId, status, orderByComparator, true);
13432    
13433                            array[1] = blogsEntry;
13434    
13435                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13436                                            groupId, userId, status, orderByComparator, false);
13437    
13438                            return array;
13439                    }
13440                    catch (Exception e) {
13441                            throw processException(e);
13442                    }
13443                    finally {
13444                            closeSession(session);
13445                    }
13446            }
13447    
13448            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
13449                    BlogsEntry blogsEntry, long groupId, long userId, int status,
13450                    OrderByComparator orderByComparator, boolean previous) {
13451                    StringBundler query = null;
13452    
13453                    if (orderByComparator != null) {
13454                            query = new StringBundler(6 +
13455                                            (orderByComparator.getOrderByFields().length * 6));
13456                    }
13457                    else {
13458                            query = new StringBundler(3);
13459                    }
13460    
13461                    if (getDB().isSupportsInlineDistinct()) {
13462                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13463                    }
13464                    else {
13465                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13466                    }
13467    
13468                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13469    
13470                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13471    
13472                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13473    
13474                    if (!getDB().isSupportsInlineDistinct()) {
13475                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13476                    }
13477    
13478                    if (orderByComparator != null) {
13479                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13480    
13481                            if (orderByConditionFields.length > 0) {
13482                                    query.append(WHERE_AND);
13483                            }
13484    
13485                            for (int i = 0; i < orderByConditionFields.length; i++) {
13486                                    if (getDB().isSupportsInlineDistinct()) {
13487                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13488                                    }
13489                                    else {
13490                                            query.append(_ORDER_BY_ENTITY_TABLE);
13491                                    }
13492    
13493                                    query.append(orderByConditionFields[i]);
13494    
13495                                    if ((i + 1) < orderByConditionFields.length) {
13496                                            if (orderByComparator.isAscending() ^ previous) {
13497                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13498                                            }
13499                                            else {
13500                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13501                                            }
13502                                    }
13503                                    else {
13504                                            if (orderByComparator.isAscending() ^ previous) {
13505                                                    query.append(WHERE_GREATER_THAN);
13506                                            }
13507                                            else {
13508                                                    query.append(WHERE_LESSER_THAN);
13509                                            }
13510                                    }
13511                            }
13512    
13513                            query.append(ORDER_BY_CLAUSE);
13514    
13515                            String[] orderByFields = orderByComparator.getOrderByFields();
13516    
13517                            for (int i = 0; i < orderByFields.length; i++) {
13518                                    if (getDB().isSupportsInlineDistinct()) {
13519                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13520                                    }
13521                                    else {
13522                                            query.append(_ORDER_BY_ENTITY_TABLE);
13523                                    }
13524    
13525                                    query.append(orderByFields[i]);
13526    
13527                                    if ((i + 1) < orderByFields.length) {
13528                                            if (orderByComparator.isAscending() ^ previous) {
13529                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13530                                            }
13531                                            else {
13532                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13533                                            }
13534                                    }
13535                                    else {
13536                                            if (orderByComparator.isAscending() ^ previous) {
13537                                                    query.append(ORDER_BY_ASC);
13538                                            }
13539                                            else {
13540                                                    query.append(ORDER_BY_DESC);
13541                                            }
13542                                    }
13543                            }
13544                    }
13545                    else {
13546                            if (getDB().isSupportsInlineDistinct()) {
13547                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13548                            }
13549                            else {
13550                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13551                            }
13552                    }
13553    
13554                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13555                                    BlogsEntry.class.getName(),
13556                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13557    
13558                    SQLQuery q = session.createSQLQuery(sql);
13559    
13560                    q.setFirstResult(0);
13561                    q.setMaxResults(2);
13562    
13563                    if (getDB().isSupportsInlineDistinct()) {
13564                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13565                    }
13566                    else {
13567                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13568                    }
13569    
13570                    QueryPos qPos = QueryPos.getInstance(q);
13571    
13572                    qPos.add(groupId);
13573    
13574                    qPos.add(userId);
13575    
13576                    qPos.add(status);
13577    
13578                    if (orderByComparator != null) {
13579                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13580    
13581                            for (Object value : values) {
13582                                    qPos.add(value);
13583                            }
13584                    }
13585    
13586                    List<BlogsEntry> list = q.list();
13587    
13588                    if (list.size() == 2) {
13589                            return list.get(1);
13590                    }
13591                    else {
13592                            return null;
13593                    }
13594            }
13595    
13596            /**
13597             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
13598             *
13599             * @param groupId the group ID
13600             * @param userId the user ID
13601             * @param status the status
13602             * @throws SystemException if a system exception occurred
13603             */
13604            @Override
13605            public void removeByG_U_S(long groupId, long userId, int status)
13606                    throws SystemException {
13607                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
13608                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13609                            remove(blogsEntry);
13610                    }
13611            }
13612    
13613            /**
13614             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
13615             *
13616             * @param groupId the group ID
13617             * @param userId the user ID
13618             * @param status the status
13619             * @return the number of matching blogs entries
13620             * @throws SystemException if a system exception occurred
13621             */
13622            @Override
13623            public int countByG_U_S(long groupId, long userId, int status)
13624                    throws SystemException {
13625                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
13626    
13627                    Object[] finderArgs = new Object[] { groupId, userId, status };
13628    
13629                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13630                                    this);
13631    
13632                    if (count == null) {
13633                            StringBundler query = new StringBundler(4);
13634    
13635                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13636    
13637                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13638    
13639                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13640    
13641                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13642    
13643                            String sql = query.toString();
13644    
13645                            Session session = null;
13646    
13647                            try {
13648                                    session = openSession();
13649    
13650                                    Query q = session.createQuery(sql);
13651    
13652                                    QueryPos qPos = QueryPos.getInstance(q);
13653    
13654                                    qPos.add(groupId);
13655    
13656                                    qPos.add(userId);
13657    
13658                                    qPos.add(status);
13659    
13660                                    count = (Long)q.uniqueResult();
13661    
13662                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13663                            }
13664                            catch (Exception e) {
13665                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13666    
13667                                    throw processException(e);
13668                            }
13669                            finally {
13670                                    closeSession(session);
13671                            }
13672                    }
13673    
13674                    return count.intValue();
13675            }
13676    
13677            /**
13678             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
13679             *
13680             * @param groupId the group ID
13681             * @param userId the user ID
13682             * @param status the status
13683             * @return the number of matching blogs entries that the user has permission to view
13684             * @throws SystemException if a system exception occurred
13685             */
13686            @Override
13687            public int filterCountByG_U_S(long groupId, long userId, int status)
13688                    throws SystemException {
13689                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13690                            return countByG_U_S(groupId, userId, status);
13691                    }
13692    
13693                    StringBundler query = new StringBundler(4);
13694    
13695                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13696    
13697                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13698    
13699                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13700    
13701                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13702    
13703                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13704                                    BlogsEntry.class.getName(),
13705                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13706    
13707                    Session session = null;
13708    
13709                    try {
13710                            session = openSession();
13711    
13712                            SQLQuery q = session.createSQLQuery(sql);
13713    
13714                            q.addScalar(COUNT_COLUMN_NAME,
13715                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13716    
13717                            QueryPos qPos = QueryPos.getInstance(q);
13718    
13719                            qPos.add(groupId);
13720    
13721                            qPos.add(userId);
13722    
13723                            qPos.add(status);
13724    
13725                            Long count = (Long)q.uniqueResult();
13726    
13727                            return count.intValue();
13728                    }
13729                    catch (Exception e) {
13730                            throw processException(e);
13731                    }
13732                    finally {
13733                            closeSession(session);
13734                    }
13735            }
13736    
13737            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13738            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
13739            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
13740            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
13741                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13742                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13743                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
13744                            new String[] {
13745                                    Long.class.getName(), Date.class.getName(),
13746                                    Integer.class.getName(),
13747                                    
13748                            Integer.class.getName(), Integer.class.getName(),
13749                                    OrderByComparator.class.getName()
13750                            });
13751            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
13752                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13753                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13754                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
13755                            new String[] {
13756                                    Long.class.getName(), Date.class.getName(),
13757                                    Integer.class.getName()
13758                            });
13759    
13760            /**
13761             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13762             *
13763             * @param groupId the group ID
13764             * @param displayDate the display date
13765             * @param status the status
13766             * @return the matching blogs entries
13767             * @throws SystemException if a system exception occurred
13768             */
13769            @Override
13770            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13771                    int status) throws SystemException {
13772                    return findByG_LtD_NotS(groupId, displayDate, status,
13773                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13774            }
13775    
13776            /**
13777             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13778             *
13779             * <p>
13780             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13781             * </p>
13782             *
13783             * @param groupId the group ID
13784             * @param displayDate the display date
13785             * @param status the status
13786             * @param start the lower bound of the range of blogs entries
13787             * @param end the upper bound of the range of blogs entries (not inclusive)
13788             * @return the range of matching blogs entries
13789             * @throws SystemException if a system exception occurred
13790             */
13791            @Override
13792            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13793                    int status, int start, int end) throws SystemException {
13794                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
13795            }
13796    
13797            /**
13798             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13799             *
13800             * <p>
13801             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13802             * </p>
13803             *
13804             * @param groupId the group ID
13805             * @param displayDate the display date
13806             * @param status the status
13807             * @param start the lower bound of the range of blogs entries
13808             * @param end the upper bound of the range of blogs entries (not inclusive)
13809             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13810             * @return the ordered range of matching blogs entries
13811             * @throws SystemException if a system exception occurred
13812             */
13813            @Override
13814            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13815                    int status, int start, int end, OrderByComparator orderByComparator)
13816                    throws SystemException {
13817                    boolean pagination = true;
13818                    FinderPath finderPath = null;
13819                    Object[] finderArgs = null;
13820    
13821                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
13822                    finderArgs = new Object[] {
13823                                    groupId, displayDate, status,
13824                                    
13825                                    start, end, orderByComparator
13826                            };
13827    
13828                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13829                                    finderArgs, this);
13830    
13831                    if ((list != null) && !list.isEmpty()) {
13832                            for (BlogsEntry blogsEntry : list) {
13833                                    if ((groupId != blogsEntry.getGroupId()) ||
13834                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
13835                                                                                                                                    .getTime()) ||
13836                                                    (status == blogsEntry.getStatus())) {
13837                                            list = null;
13838    
13839                                            break;
13840                                    }
13841                            }
13842                    }
13843    
13844                    if (list == null) {
13845                            StringBundler query = null;
13846    
13847                            if (orderByComparator != null) {
13848                                    query = new StringBundler(5 +
13849                                                    (orderByComparator.getOrderByFields().length * 3));
13850                            }
13851                            else {
13852                                    query = new StringBundler(5);
13853                            }
13854    
13855                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13856    
13857                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13858    
13859                            boolean bindDisplayDate = false;
13860    
13861                            if (displayDate == null) {
13862                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13863                            }
13864                            else {
13865                                    bindDisplayDate = true;
13866    
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 (orderByComparator != null) {
13873                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13874                                            orderByComparator);
13875                            }
13876                            else
13877                             if (pagination) {
13878                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13879                            }
13880    
13881                            String sql = query.toString();
13882    
13883                            Session session = null;
13884    
13885                            try {
13886                                    session = openSession();
13887    
13888                                    Query q = session.createQuery(sql);
13889    
13890                                    QueryPos qPos = QueryPos.getInstance(q);
13891    
13892                                    qPos.add(groupId);
13893    
13894                                    if (bindDisplayDate) {
13895                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13896                                    }
13897    
13898                                    qPos.add(status);
13899    
13900                                    if (!pagination) {
13901                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13902                                                            start, end, false);
13903    
13904                                            Collections.sort(list);
13905    
13906                                            list = new UnmodifiableList<BlogsEntry>(list);
13907                                    }
13908                                    else {
13909                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13910                                                            start, end);
13911                                    }
13912    
13913                                    cacheResult(list);
13914    
13915                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13916                            }
13917                            catch (Exception e) {
13918                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13919    
13920                                    throw processException(e);
13921                            }
13922                            finally {
13923                                    closeSession(session);
13924                            }
13925                    }
13926    
13927                    return list;
13928            }
13929    
13930            /**
13931             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13932             *
13933             * @param groupId the group ID
13934             * @param displayDate the display date
13935             * @param status the status
13936             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13937             * @return the first matching blogs entry
13938             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13939             * @throws SystemException if a system exception occurred
13940             */
13941            @Override
13942            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
13943                    int status, OrderByComparator orderByComparator)
13944                    throws NoSuchEntryException, SystemException {
13945                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
13946                                    status, orderByComparator);
13947    
13948                    if (blogsEntry != null) {
13949                            return blogsEntry;
13950                    }
13951    
13952                    StringBundler msg = new StringBundler(8);
13953    
13954                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13955    
13956                    msg.append("groupId=");
13957                    msg.append(groupId);
13958    
13959                    msg.append(", displayDate=");
13960                    msg.append(displayDate);
13961    
13962                    msg.append(", status=");
13963                    msg.append(status);
13964    
13965                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13966    
13967                    throw new NoSuchEntryException(msg.toString());
13968            }
13969    
13970            /**
13971             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13972             *
13973             * @param groupId the group ID
13974             * @param displayDate the display date
13975             * @param status the status
13976             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13977             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13978             * @throws SystemException if a system exception occurred
13979             */
13980            @Override
13981            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
13982                    int status, OrderByComparator orderByComparator)
13983                    throws SystemException {
13984                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13985                                    0, 1, orderByComparator);
13986    
13987                    if (!list.isEmpty()) {
13988                            return list.get(0);
13989                    }
13990    
13991                    return null;
13992            }
13993    
13994            /**
13995             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13996             *
13997             * @param groupId the group ID
13998             * @param displayDate the display date
13999             * @param status the status
14000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14001             * @return the last matching blogs entry
14002             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14003             * @throws SystemException if a system exception occurred
14004             */
14005            @Override
14006            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
14007                    int status, OrderByComparator orderByComparator)
14008                    throws NoSuchEntryException, SystemException {
14009                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
14010                                    status, orderByComparator);
14011    
14012                    if (blogsEntry != null) {
14013                            return blogsEntry;
14014                    }
14015    
14016                    StringBundler msg = new StringBundler(8);
14017    
14018                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14019    
14020                    msg.append("groupId=");
14021                    msg.append(groupId);
14022    
14023                    msg.append(", displayDate=");
14024                    msg.append(displayDate);
14025    
14026                    msg.append(", status=");
14027                    msg.append(status);
14028    
14029                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14030    
14031                    throw new NoSuchEntryException(msg.toString());
14032            }
14033    
14034            /**
14035             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14036             *
14037             * @param groupId the group ID
14038             * @param displayDate the display date
14039             * @param status the status
14040             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14041             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14042             * @throws SystemException if a system exception occurred
14043             */
14044            @Override
14045            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
14046                    int status, OrderByComparator orderByComparator)
14047                    throws SystemException {
14048                    int count = countByG_LtD_NotS(groupId, displayDate, status);
14049    
14050                    if (count == 0) {
14051                            return null;
14052                    }
14053    
14054                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
14055                                    count - 1, count, orderByComparator);
14056    
14057                    if (!list.isEmpty()) {
14058                            return list.get(0);
14059                    }
14060    
14061                    return null;
14062            }
14063    
14064            /**
14065             * 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;.
14066             *
14067             * @param entryId the primary key of the current blogs entry
14068             * @param groupId the group ID
14069             * @param displayDate the display date
14070             * @param status the status
14071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14072             * @return the previous, current, and next blogs entry
14073             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14074             * @throws SystemException if a system exception occurred
14075             */
14076            @Override
14077            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
14078                    long groupId, Date displayDate, int status,
14079                    OrderByComparator orderByComparator)
14080                    throws NoSuchEntryException, SystemException {
14081                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14082    
14083                    Session session = null;
14084    
14085                    try {
14086                            session = openSession();
14087    
14088                            BlogsEntry[] array = new BlogsEntryImpl[3];
14089    
14090                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14091                                            groupId, displayDate, status, orderByComparator, true);
14092    
14093                            array[1] = blogsEntry;
14094    
14095                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14096                                            groupId, displayDate, status, orderByComparator, false);
14097    
14098                            return array;
14099                    }
14100                    catch (Exception e) {
14101                            throw processException(e);
14102                    }
14103                    finally {
14104                            closeSession(session);
14105                    }
14106            }
14107    
14108            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
14109                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14110                    OrderByComparator orderByComparator, boolean previous) {
14111                    StringBundler query = null;
14112    
14113                    if (orderByComparator != null) {
14114                            query = new StringBundler(6 +
14115                                            (orderByComparator.getOrderByFields().length * 6));
14116                    }
14117                    else {
14118                            query = new StringBundler(3);
14119                    }
14120    
14121                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14122    
14123                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14124    
14125                    boolean bindDisplayDate = false;
14126    
14127                    if (displayDate == null) {
14128                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14129                    }
14130                    else {
14131                            bindDisplayDate = true;
14132    
14133                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14134                    }
14135    
14136                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14137    
14138                    if (orderByComparator != null) {
14139                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14140    
14141                            if (orderByConditionFields.length > 0) {
14142                                    query.append(WHERE_AND);
14143                            }
14144    
14145                            for (int i = 0; i < orderByConditionFields.length; i++) {
14146                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14147                                    query.append(orderByConditionFields[i]);
14148    
14149                                    if ((i + 1) < orderByConditionFields.length) {
14150                                            if (orderByComparator.isAscending() ^ previous) {
14151                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14152                                            }
14153                                            else {
14154                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14155                                            }
14156                                    }
14157                                    else {
14158                                            if (orderByComparator.isAscending() ^ previous) {
14159                                                    query.append(WHERE_GREATER_THAN);
14160                                            }
14161                                            else {
14162                                                    query.append(WHERE_LESSER_THAN);
14163                                            }
14164                                    }
14165                            }
14166    
14167                            query.append(ORDER_BY_CLAUSE);
14168    
14169                            String[] orderByFields = orderByComparator.getOrderByFields();
14170    
14171                            for (int i = 0; i < orderByFields.length; i++) {
14172                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14173                                    query.append(orderByFields[i]);
14174    
14175                                    if ((i + 1) < orderByFields.length) {
14176                                            if (orderByComparator.isAscending() ^ previous) {
14177                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14178                                            }
14179                                            else {
14180                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14181                                            }
14182                                    }
14183                                    else {
14184                                            if (orderByComparator.isAscending() ^ previous) {
14185                                                    query.append(ORDER_BY_ASC);
14186                                            }
14187                                            else {
14188                                                    query.append(ORDER_BY_DESC);
14189                                            }
14190                                    }
14191                            }
14192                    }
14193                    else {
14194                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14195                    }
14196    
14197                    String sql = query.toString();
14198    
14199                    Query q = session.createQuery(sql);
14200    
14201                    q.setFirstResult(0);
14202                    q.setMaxResults(2);
14203    
14204                    QueryPos qPos = QueryPos.getInstance(q);
14205    
14206                    qPos.add(groupId);
14207    
14208                    if (bindDisplayDate) {
14209                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14210                    }
14211    
14212                    qPos.add(status);
14213    
14214                    if (orderByComparator != null) {
14215                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14216    
14217                            for (Object value : values) {
14218                                    qPos.add(value);
14219                            }
14220                    }
14221    
14222                    List<BlogsEntry> list = q.list();
14223    
14224                    if (list.size() == 2) {
14225                            return list.get(1);
14226                    }
14227                    else {
14228                            return null;
14229                    }
14230            }
14231    
14232            /**
14233             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14234             *
14235             * @param groupId the group ID
14236             * @param displayDate the display date
14237             * @param status the status
14238             * @return the matching blogs entries that the user has permission to view
14239             * @throws SystemException if a system exception occurred
14240             */
14241            @Override
14242            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
14243                    Date displayDate, int status) throws SystemException {
14244                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
14245                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14246            }
14247    
14248            /**
14249             * 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;.
14250             *
14251             * <p>
14252             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14253             * </p>
14254             *
14255             * @param groupId the group ID
14256             * @param displayDate the display date
14257             * @param status the status
14258             * @param start the lower bound of the range of blogs entries
14259             * @param end the upper bound of the range of blogs entries (not inclusive)
14260             * @return the range of matching blogs entries that the user has permission to view
14261             * @throws SystemException if a system exception occurred
14262             */
14263            @Override
14264            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
14265                    Date displayDate, int status, int start, int end)
14266                    throws SystemException {
14267                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
14268                            null);
14269            }
14270    
14271            /**
14272             * 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;.
14273             *
14274             * <p>
14275             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14276             * </p>
14277             *
14278             * @param groupId the group ID
14279             * @param displayDate the display date
14280             * @param status the status
14281             * @param start the lower bound of the range of blogs entries
14282             * @param end the upper bound of the range of blogs entries (not inclusive)
14283             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14284             * @return the ordered range of matching blogs entries that the user has permission to view
14285             * @throws SystemException if a system exception occurred
14286             */
14287            @Override
14288            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
14289                    Date displayDate, int status, int start, int end,
14290                    OrderByComparator orderByComparator) throws SystemException {
14291                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14292                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
14293                                    orderByComparator);
14294                    }
14295    
14296                    StringBundler query = null;
14297    
14298                    if (orderByComparator != null) {
14299                            query = new StringBundler(5 +
14300                                            (orderByComparator.getOrderByFields().length * 3));
14301                    }
14302                    else {
14303                            query = new StringBundler(5);
14304                    }
14305    
14306                    if (getDB().isSupportsInlineDistinct()) {
14307                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14308                    }
14309                    else {
14310                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14311                    }
14312    
14313                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14314    
14315                    boolean bindDisplayDate = false;
14316    
14317                    if (displayDate == null) {
14318                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14319                    }
14320                    else {
14321                            bindDisplayDate = true;
14322    
14323                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14324                    }
14325    
14326                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14327    
14328                    if (!getDB().isSupportsInlineDistinct()) {
14329                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14330                    }
14331    
14332                    if (orderByComparator != null) {
14333                            if (getDB().isSupportsInlineDistinct()) {
14334                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14335                                            orderByComparator, true);
14336                            }
14337                            else {
14338                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14339                                            orderByComparator, true);
14340                            }
14341                    }
14342                    else {
14343                            if (getDB().isSupportsInlineDistinct()) {
14344                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14345                            }
14346                            else {
14347                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14348                            }
14349                    }
14350    
14351                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14352                                    BlogsEntry.class.getName(),
14353                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14354    
14355                    Session session = null;
14356    
14357                    try {
14358                            session = openSession();
14359    
14360                            SQLQuery q = session.createSQLQuery(sql);
14361    
14362                            if (getDB().isSupportsInlineDistinct()) {
14363                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14364                            }
14365                            else {
14366                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14367                            }
14368    
14369                            QueryPos qPos = QueryPos.getInstance(q);
14370    
14371                            qPos.add(groupId);
14372    
14373                            if (bindDisplayDate) {
14374                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14375                            }
14376    
14377                            qPos.add(status);
14378    
14379                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
14380                    }
14381                    catch (Exception e) {
14382                            throw processException(e);
14383                    }
14384                    finally {
14385                            closeSession(session);
14386                    }
14387            }
14388    
14389            /**
14390             * 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;.
14391             *
14392             * @param entryId the primary key of the current blogs entry
14393             * @param groupId the group ID
14394             * @param displayDate the display date
14395             * @param status the status
14396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14397             * @return the previous, current, and next blogs entry
14398             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14399             * @throws SystemException if a system exception occurred
14400             */
14401            @Override
14402            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
14403                    long groupId, Date displayDate, int status,
14404                    OrderByComparator orderByComparator)
14405                    throws NoSuchEntryException, SystemException {
14406                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14407                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
14408                                    status, orderByComparator);
14409                    }
14410    
14411                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14412    
14413                    Session session = null;
14414    
14415                    try {
14416                            session = openSession();
14417    
14418                            BlogsEntry[] array = new BlogsEntryImpl[3];
14419    
14420                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14421                                            groupId, displayDate, status, orderByComparator, true);
14422    
14423                            array[1] = blogsEntry;
14424    
14425                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14426                                            groupId, displayDate, status, orderByComparator, false);
14427    
14428                            return array;
14429                    }
14430                    catch (Exception e) {
14431                            throw processException(e);
14432                    }
14433                    finally {
14434                            closeSession(session);
14435                    }
14436            }
14437    
14438            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
14439                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14440                    OrderByComparator orderByComparator, boolean previous) {
14441                    StringBundler query = null;
14442    
14443                    if (orderByComparator != null) {
14444                            query = new StringBundler(6 +
14445                                            (orderByComparator.getOrderByFields().length * 6));
14446                    }
14447                    else {
14448                            query = new StringBundler(3);
14449                    }
14450    
14451                    if (getDB().isSupportsInlineDistinct()) {
14452                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14453                    }
14454                    else {
14455                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14456                    }
14457    
14458                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14459    
14460                    boolean bindDisplayDate = false;
14461    
14462                    if (displayDate == null) {
14463                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14464                    }
14465                    else {
14466                            bindDisplayDate = true;
14467    
14468                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14469                    }
14470    
14471                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14472    
14473                    if (!getDB().isSupportsInlineDistinct()) {
14474                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14475                    }
14476    
14477                    if (orderByComparator != null) {
14478                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14479    
14480                            if (orderByConditionFields.length > 0) {
14481                                    query.append(WHERE_AND);
14482                            }
14483    
14484                            for (int i = 0; i < orderByConditionFields.length; i++) {
14485                                    if (getDB().isSupportsInlineDistinct()) {
14486                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14487                                    }
14488                                    else {
14489                                            query.append(_ORDER_BY_ENTITY_TABLE);
14490                                    }
14491    
14492                                    query.append(orderByConditionFields[i]);
14493    
14494                                    if ((i + 1) < orderByConditionFields.length) {
14495                                            if (orderByComparator.isAscending() ^ previous) {
14496                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14497                                            }
14498                                            else {
14499                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14500                                            }
14501                                    }
14502                                    else {
14503                                            if (orderByComparator.isAscending() ^ previous) {
14504                                                    query.append(WHERE_GREATER_THAN);
14505                                            }
14506                                            else {
14507                                                    query.append(WHERE_LESSER_THAN);
14508                                            }
14509                                    }
14510                            }
14511    
14512                            query.append(ORDER_BY_CLAUSE);
14513    
14514                            String[] orderByFields = orderByComparator.getOrderByFields();
14515    
14516                            for (int i = 0; i < orderByFields.length; i++) {
14517                                    if (getDB().isSupportsInlineDistinct()) {
14518                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14519                                    }
14520                                    else {
14521                                            query.append(_ORDER_BY_ENTITY_TABLE);
14522                                    }
14523    
14524                                    query.append(orderByFields[i]);
14525    
14526                                    if ((i + 1) < orderByFields.length) {
14527                                            if (orderByComparator.isAscending() ^ previous) {
14528                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14529                                            }
14530                                            else {
14531                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14532                                            }
14533                                    }
14534                                    else {
14535                                            if (orderByComparator.isAscending() ^ previous) {
14536                                                    query.append(ORDER_BY_ASC);
14537                                            }
14538                                            else {
14539                                                    query.append(ORDER_BY_DESC);
14540                                            }
14541                                    }
14542                            }
14543                    }
14544                    else {
14545                            if (getDB().isSupportsInlineDistinct()) {
14546                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14547                            }
14548                            else {
14549                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14550                            }
14551                    }
14552    
14553                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14554                                    BlogsEntry.class.getName(),
14555                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14556    
14557                    SQLQuery q = session.createSQLQuery(sql);
14558    
14559                    q.setFirstResult(0);
14560                    q.setMaxResults(2);
14561    
14562                    if (getDB().isSupportsInlineDistinct()) {
14563                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14564                    }
14565                    else {
14566                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14567                    }
14568    
14569                    QueryPos qPos = QueryPos.getInstance(q);
14570    
14571                    qPos.add(groupId);
14572    
14573                    if (bindDisplayDate) {
14574                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14575                    }
14576    
14577                    qPos.add(status);
14578    
14579                    if (orderByComparator != null) {
14580                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14581    
14582                            for (Object value : values) {
14583                                    qPos.add(value);
14584                            }
14585                    }
14586    
14587                    List<BlogsEntry> list = q.list();
14588    
14589                    if (list.size() == 2) {
14590                            return list.get(1);
14591                    }
14592                    else {
14593                            return null;
14594                    }
14595            }
14596    
14597            /**
14598             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
14599             *
14600             * @param groupId the group ID
14601             * @param displayDate the display date
14602             * @param status the status
14603             * @throws SystemException if a system exception occurred
14604             */
14605            @Override
14606            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status)
14607                    throws SystemException {
14608                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
14609                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14610                            remove(blogsEntry);
14611                    }
14612            }
14613    
14614            /**
14615             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14616             *
14617             * @param groupId the group ID
14618             * @param displayDate the display date
14619             * @param status the status
14620             * @return the number of matching blogs entries
14621             * @throws SystemException if a system exception occurred
14622             */
14623            @Override
14624            public int countByG_LtD_NotS(long groupId, Date displayDate, int status)
14625                    throws SystemException {
14626                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
14627    
14628                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
14629    
14630                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14631                                    this);
14632    
14633                    if (count == null) {
14634                            StringBundler query = new StringBundler(4);
14635    
14636                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14637    
14638                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14639    
14640                            boolean bindDisplayDate = false;
14641    
14642                            if (displayDate == null) {
14643                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14644                            }
14645                            else {
14646                                    bindDisplayDate = true;
14647    
14648                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14649                            }
14650    
14651                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14652    
14653                            String sql = query.toString();
14654    
14655                            Session session = null;
14656    
14657                            try {
14658                                    session = openSession();
14659    
14660                                    Query q = session.createQuery(sql);
14661    
14662                                    QueryPos qPos = QueryPos.getInstance(q);
14663    
14664                                    qPos.add(groupId);
14665    
14666                                    if (bindDisplayDate) {
14667                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14668                                    }
14669    
14670                                    qPos.add(status);
14671    
14672                                    count = (Long)q.uniqueResult();
14673    
14674                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14675                            }
14676                            catch (Exception e) {
14677                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14678    
14679                                    throw processException(e);
14680                            }
14681                            finally {
14682                                    closeSession(session);
14683                            }
14684                    }
14685    
14686                    return count.intValue();
14687            }
14688    
14689            /**
14690             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14691             *
14692             * @param groupId the group ID
14693             * @param displayDate the display date
14694             * @param status the status
14695             * @return the number of matching blogs entries that the user has permission to view
14696             * @throws SystemException if a system exception occurred
14697             */
14698            @Override
14699            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
14700                    int status) throws SystemException {
14701                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14702                            return countByG_LtD_NotS(groupId, displayDate, status);
14703                    }
14704    
14705                    StringBundler query = new StringBundler(4);
14706    
14707                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
14708    
14709                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14710    
14711                    boolean bindDisplayDate = false;
14712    
14713                    if (displayDate == null) {
14714                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14715                    }
14716                    else {
14717                            bindDisplayDate = true;
14718    
14719                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14720                    }
14721    
14722                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14723    
14724                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14725                                    BlogsEntry.class.getName(),
14726                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14727    
14728                    Session session = null;
14729    
14730                    try {
14731                            session = openSession();
14732    
14733                            SQLQuery q = session.createSQLQuery(sql);
14734    
14735                            q.addScalar(COUNT_COLUMN_NAME,
14736                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14737    
14738                            QueryPos qPos = QueryPos.getInstance(q);
14739    
14740                            qPos.add(groupId);
14741    
14742                            if (bindDisplayDate) {
14743                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14744                            }
14745    
14746                            qPos.add(status);
14747    
14748                            Long count = (Long)q.uniqueResult();
14749    
14750                            return count.intValue();
14751                    }
14752                    catch (Exception e) {
14753                            throw processException(e);
14754                    }
14755                    finally {
14756                            closeSession(session);
14757                    }
14758            }
14759    
14760            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
14761            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
14762            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14763            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
14764            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14765                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14766                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
14767                            new String[] {
14768                                    Long.class.getName(), Date.class.getName(),
14769                                    Integer.class.getName(),
14770                                    
14771                            Integer.class.getName(), Integer.class.getName(),
14772                                    OrderByComparator.class.getName()
14773                            });
14774            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14775                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14776                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
14777                            new String[] {
14778                                    Long.class.getName(), Date.class.getName(),
14779                                    Integer.class.getName()
14780                            });
14781    
14782            /**
14783             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14784             *
14785             * @param groupId the group ID
14786             * @param displayDate the display date
14787             * @param status the status
14788             * @return the matching blogs entries
14789             * @throws SystemException if a system exception occurred
14790             */
14791            @Override
14792            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14793                    int status) throws SystemException {
14794                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
14795                            QueryUtil.ALL_POS, null);
14796            }
14797    
14798            /**
14799             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14800             *
14801             * <p>
14802             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14803             * </p>
14804             *
14805             * @param groupId the group ID
14806             * @param displayDate the display date
14807             * @param status the status
14808             * @param start the lower bound of the range of blogs entries
14809             * @param end the upper bound of the range of blogs entries (not inclusive)
14810             * @return the range of matching blogs entries
14811             * @throws SystemException if a system exception occurred
14812             */
14813            @Override
14814            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14815                    int status, int start, int end) throws SystemException {
14816                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
14817            }
14818    
14819            /**
14820             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14821             *
14822             * <p>
14823             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14824             * </p>
14825             *
14826             * @param groupId the group ID
14827             * @param displayDate the display date
14828             * @param status the status
14829             * @param start the lower bound of the range of blogs entries
14830             * @param end the upper bound of the range of blogs entries (not inclusive)
14831             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14832             * @return the ordered range of matching blogs entries
14833             * @throws SystemException if a system exception occurred
14834             */
14835            @Override
14836            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14837                    int status, int start, int end, OrderByComparator orderByComparator)
14838                    throws SystemException {
14839                    boolean pagination = true;
14840                    FinderPath finderPath = null;
14841                    Object[] finderArgs = null;
14842    
14843                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
14844                    finderArgs = new Object[] {
14845                                    groupId, displayDate, status,
14846                                    
14847                                    start, end, orderByComparator
14848                            };
14849    
14850                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14851                                    finderArgs, this);
14852    
14853                    if ((list != null) && !list.isEmpty()) {
14854                            for (BlogsEntry blogsEntry : list) {
14855                                    if ((groupId != blogsEntry.getGroupId()) ||
14856                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
14857                                                                                                                                    .getTime()) ||
14858                                                    (status != blogsEntry.getStatus())) {
14859                                            list = null;
14860    
14861                                            break;
14862                                    }
14863                            }
14864                    }
14865    
14866                    if (list == null) {
14867                            StringBundler query = null;
14868    
14869                            if (orderByComparator != null) {
14870                                    query = new StringBundler(5 +
14871                                                    (orderByComparator.getOrderByFields().length * 3));
14872                            }
14873                            else {
14874                                    query = new StringBundler(5);
14875                            }
14876    
14877                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14878    
14879                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14880    
14881                            boolean bindDisplayDate = false;
14882    
14883                            if (displayDate == null) {
14884                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14885                            }
14886                            else {
14887                                    bindDisplayDate = true;
14888    
14889                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14890                            }
14891    
14892                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14893    
14894                            if (orderByComparator != null) {
14895                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14896                                            orderByComparator);
14897                            }
14898                            else
14899                             if (pagination) {
14900                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14901                            }
14902    
14903                            String sql = query.toString();
14904    
14905                            Session session = null;
14906    
14907                            try {
14908                                    session = openSession();
14909    
14910                                    Query q = session.createQuery(sql);
14911    
14912                                    QueryPos qPos = QueryPos.getInstance(q);
14913    
14914                                    qPos.add(groupId);
14915    
14916                                    if (bindDisplayDate) {
14917                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14918                                    }
14919    
14920                                    qPos.add(status);
14921    
14922                                    if (!pagination) {
14923                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14924                                                            start, end, false);
14925    
14926                                            Collections.sort(list);
14927    
14928                                            list = new UnmodifiableList<BlogsEntry>(list);
14929                                    }
14930                                    else {
14931                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14932                                                            start, end);
14933                                    }
14934    
14935                                    cacheResult(list);
14936    
14937                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14938                            }
14939                            catch (Exception e) {
14940                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14941    
14942                                    throw processException(e);
14943                            }
14944                            finally {
14945                                    closeSession(session);
14946                            }
14947                    }
14948    
14949                    return list;
14950            }
14951    
14952            /**
14953             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14954             *
14955             * @param groupId the group ID
14956             * @param displayDate the display date
14957             * @param status the status
14958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14959             * @return the first matching blogs entry
14960             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14961             * @throws SystemException if a system exception occurred
14962             */
14963            @Override
14964            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
14965                    int status, OrderByComparator orderByComparator)
14966                    throws NoSuchEntryException, SystemException {
14967                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
14968                                    status, orderByComparator);
14969    
14970                    if (blogsEntry != null) {
14971                            return blogsEntry;
14972                    }
14973    
14974                    StringBundler msg = new StringBundler(8);
14975    
14976                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14977    
14978                    msg.append("groupId=");
14979                    msg.append(groupId);
14980    
14981                    msg.append(", displayDate=");
14982                    msg.append(displayDate);
14983    
14984                    msg.append(", status=");
14985                    msg.append(status);
14986    
14987                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14988    
14989                    throw new NoSuchEntryException(msg.toString());
14990            }
14991    
14992            /**
14993             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14994             *
14995             * @param groupId the group ID
14996             * @param displayDate the display date
14997             * @param status the status
14998             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14999             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15000             * @throws SystemException if a system exception occurred
15001             */
15002            @Override
15003            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
15004                    int status, OrderByComparator orderByComparator)
15005                    throws SystemException {
15006                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
15007                                    1, orderByComparator);
15008    
15009                    if (!list.isEmpty()) {
15010                            return list.get(0);
15011                    }
15012    
15013                    return null;
15014            }
15015    
15016            /**
15017             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15018             *
15019             * @param groupId the group ID
15020             * @param displayDate the display date
15021             * @param status the status
15022             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15023             * @return the last matching blogs entry
15024             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15025             * @throws SystemException if a system exception occurred
15026             */
15027            @Override
15028            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
15029                    int status, OrderByComparator orderByComparator)
15030                    throws NoSuchEntryException, SystemException {
15031                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
15032                                    status, orderByComparator);
15033    
15034                    if (blogsEntry != null) {
15035                            return blogsEntry;
15036                    }
15037    
15038                    StringBundler msg = new StringBundler(8);
15039    
15040                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15041    
15042                    msg.append("groupId=");
15043                    msg.append(groupId);
15044    
15045                    msg.append(", displayDate=");
15046                    msg.append(displayDate);
15047    
15048                    msg.append(", status=");
15049                    msg.append(status);
15050    
15051                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15052    
15053                    throw new NoSuchEntryException(msg.toString());
15054            }
15055    
15056            /**
15057             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15058             *
15059             * @param groupId the group ID
15060             * @param displayDate the display date
15061             * @param status the status
15062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15063             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15064             * @throws SystemException if a system exception occurred
15065             */
15066            @Override
15067            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
15068                    int status, OrderByComparator orderByComparator)
15069                    throws SystemException {
15070                    int count = countByG_LtD_S(groupId, displayDate, status);
15071    
15072                    if (count == 0) {
15073                            return null;
15074                    }
15075    
15076                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
15077                                    count - 1, count, orderByComparator);
15078    
15079                    if (!list.isEmpty()) {
15080                            return list.get(0);
15081                    }
15082    
15083                    return null;
15084            }
15085    
15086            /**
15087             * 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;.
15088             *
15089             * @param entryId the primary key of the current blogs entry
15090             * @param groupId the group ID
15091             * @param displayDate the display date
15092             * @param status the status
15093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15094             * @return the previous, current, and next blogs entry
15095             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15096             * @throws SystemException if a system exception occurred
15097             */
15098            @Override
15099            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
15100                    Date displayDate, int status, OrderByComparator orderByComparator)
15101                    throws NoSuchEntryException, SystemException {
15102                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15103    
15104                    Session session = null;
15105    
15106                    try {
15107                            session = openSession();
15108    
15109                            BlogsEntry[] array = new BlogsEntryImpl[3];
15110    
15111                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15112                                            displayDate, status, orderByComparator, true);
15113    
15114                            array[1] = blogsEntry;
15115    
15116                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15117                                            displayDate, status, orderByComparator, false);
15118    
15119                            return array;
15120                    }
15121                    catch (Exception e) {
15122                            throw processException(e);
15123                    }
15124                    finally {
15125                            closeSession(session);
15126                    }
15127            }
15128    
15129            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
15130                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
15131                    OrderByComparator orderByComparator, boolean previous) {
15132                    StringBundler query = null;
15133    
15134                    if (orderByComparator != null) {
15135                            query = new StringBundler(6 +
15136                                            (orderByComparator.getOrderByFields().length * 6));
15137                    }
15138                    else {
15139                            query = new StringBundler(3);
15140                    }
15141    
15142                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15143    
15144                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15145    
15146                    boolean bindDisplayDate = false;
15147    
15148                    if (displayDate == null) {
15149                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15150                    }
15151                    else {
15152                            bindDisplayDate = true;
15153    
15154                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15155                    }
15156    
15157                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15158    
15159                    if (orderByComparator != null) {
15160                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15161    
15162                            if (orderByConditionFields.length > 0) {
15163                                    query.append(WHERE_AND);
15164                            }
15165    
15166                            for (int i = 0; i < orderByConditionFields.length; i++) {
15167                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15168                                    query.append(orderByConditionFields[i]);
15169    
15170                                    if ((i + 1) < orderByConditionFields.length) {
15171                                            if (orderByComparator.isAscending() ^ previous) {
15172                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15173                                            }
15174                                            else {
15175                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15176                                            }
15177                                    }
15178                                    else {
15179                                            if (orderByComparator.isAscending() ^ previous) {
15180                                                    query.append(WHERE_GREATER_THAN);
15181                                            }
15182                                            else {
15183                                                    query.append(WHERE_LESSER_THAN);
15184                                            }
15185                                    }
15186                            }
15187    
15188                            query.append(ORDER_BY_CLAUSE);
15189    
15190                            String[] orderByFields = orderByComparator.getOrderByFields();
15191    
15192                            for (int i = 0; i < orderByFields.length; i++) {
15193                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15194                                    query.append(orderByFields[i]);
15195    
15196                                    if ((i + 1) < orderByFields.length) {
15197                                            if (orderByComparator.isAscending() ^ previous) {
15198                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15199                                            }
15200                                            else {
15201                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15202                                            }
15203                                    }
15204                                    else {
15205                                            if (orderByComparator.isAscending() ^ previous) {
15206                                                    query.append(ORDER_BY_ASC);
15207                                            }
15208                                            else {
15209                                                    query.append(ORDER_BY_DESC);
15210                                            }
15211                                    }
15212                            }
15213                    }
15214                    else {
15215                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15216                    }
15217    
15218                    String sql = query.toString();
15219    
15220                    Query q = session.createQuery(sql);
15221    
15222                    q.setFirstResult(0);
15223                    q.setMaxResults(2);
15224    
15225                    QueryPos qPos = QueryPos.getInstance(q);
15226    
15227                    qPos.add(groupId);
15228    
15229                    if (bindDisplayDate) {
15230                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15231                    }
15232    
15233                    qPos.add(status);
15234    
15235                    if (orderByComparator != null) {
15236                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15237    
15238                            for (Object value : values) {
15239                                    qPos.add(value);
15240                            }
15241                    }
15242    
15243                    List<BlogsEntry> list = q.list();
15244    
15245                    if (list.size() == 2) {
15246                            return list.get(1);
15247                    }
15248                    else {
15249                            return null;
15250                    }
15251            }
15252    
15253            /**
15254             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15255             *
15256             * @param groupId the group ID
15257             * @param displayDate the display date
15258             * @param status the status
15259             * @return the matching blogs entries that the user has permission to view
15260             * @throws SystemException if a system exception occurred
15261             */
15262            @Override
15263            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
15264                    int status) throws SystemException {
15265                    return filterFindByG_LtD_S(groupId, displayDate, status,
15266                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15267            }
15268    
15269            /**
15270             * 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;.
15271             *
15272             * <p>
15273             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15274             * </p>
15275             *
15276             * @param groupId the group ID
15277             * @param displayDate the display date
15278             * @param status the status
15279             * @param start the lower bound of the range of blogs entries
15280             * @param end the upper bound of the range of blogs entries (not inclusive)
15281             * @return the range of matching blogs entries that the user has permission to view
15282             * @throws SystemException if a system exception occurred
15283             */
15284            @Override
15285            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
15286                    int status, int start, int end) throws SystemException {
15287                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
15288                            null);
15289            }
15290    
15291            /**
15292             * 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;.
15293             *
15294             * <p>
15295             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15296             * </p>
15297             *
15298             * @param groupId the group ID
15299             * @param displayDate the display date
15300             * @param status the status
15301             * @param start the lower bound of the range of blogs entries
15302             * @param end the upper bound of the range of blogs entries (not inclusive)
15303             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15304             * @return the ordered range of matching blogs entries that the user has permission to view
15305             * @throws SystemException if a system exception occurred
15306             */
15307            @Override
15308            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
15309                    int status, int start, int end, OrderByComparator orderByComparator)
15310                    throws SystemException {
15311                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15312                            return findByG_LtD_S(groupId, displayDate, status, start, end,
15313                                    orderByComparator);
15314                    }
15315    
15316                    StringBundler query = null;
15317    
15318                    if (orderByComparator != null) {
15319                            query = new StringBundler(5 +
15320                                            (orderByComparator.getOrderByFields().length * 3));
15321                    }
15322                    else {
15323                            query = new StringBundler(5);
15324                    }
15325    
15326                    if (getDB().isSupportsInlineDistinct()) {
15327                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
15328                    }
15329                    else {
15330                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
15331                    }
15332    
15333                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15334    
15335                    boolean bindDisplayDate = false;
15336    
15337                    if (displayDate == null) {
15338                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15339                    }
15340                    else {
15341                            bindDisplayDate = true;
15342    
15343                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15344                    }
15345    
15346                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15347    
15348                    if (!getDB().isSupportsInlineDistinct()) {
15349                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
15350                    }
15351    
15352                    if (orderByComparator != null) {
15353                            if (getDB().isSupportsInlineDistinct()) {
15354                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15355                                            orderByComparator, true);
15356                            }
15357                            else {
15358                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15359                                            orderByComparator, true);
15360                            }
15361                    }
15362                    else {
15363                            if (getDB().isSupportsInlineDistinct()) {
15364                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15365                            }
15366                            else {
15367                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15368                            }
15369                    }
15370    
15371                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15372                                    BlogsEntry.class.getName(),
15373                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15374    
15375                    Session session = null;
15376    
15377                    try {
15378                            session = openSession();
15379    
15380                            SQLQuery q = session.createSQLQuery(sql);
15381    
15382                            if (getDB().isSupportsInlineDistinct()) {
15383                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15384                            }
15385                            else {
15386                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15387                            }
15388    
15389                            QueryPos qPos = QueryPos.getInstance(q);
15390    
15391                            qPos.add(groupId);
15392    
15393                            if (bindDisplayDate) {
15394                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
15395                            }
15396    
15397                            qPos.add(status);
15398    
15399                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
15400                    }
15401                    catch (Exception e) {
15402                            throw processException(e);
15403                    }
15404                    finally {
15405                            closeSession(session);
15406                    }
15407            }
15408    
15409            /**
15410             * 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;.
15411             *
15412             * @param entryId the primary key of the current blogs entry
15413             * @param groupId the group ID
15414             * @param displayDate the display date
15415             * @param status the status
15416             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15417             * @return the previous, current, and next blogs entry
15418             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15419             * @throws SystemException if a system exception occurred
15420             */
15421            @Override
15422            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
15423                    long groupId, Date displayDate, int status,
15424                    OrderByComparator orderByComparator)
15425                    throws NoSuchEntryException, SystemException {
15426                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15427                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
15428                                    status, orderByComparator);
15429                    }
15430    
15431                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15432    
15433                    Session session = null;
15434    
15435                    try {
15436                            session = openSession();
15437    
15438                            BlogsEntry[] array = new BlogsEntryImpl[3];
15439    
15440                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
15441                                            groupId, displayDate, status, orderByComparator, true);
15442    
15443                            array[1] = blogsEntry;
15444    
15445                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
15446                                            groupId, displayDate, status, orderByComparator, false);
15447    
15448                            return array;
15449                    }
15450                    catch (Exception e) {
15451                            throw processException(e);
15452                    }
15453                    finally {
15454                            closeSession(session);
15455                    }
15456            }
15457    
15458            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
15459                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
15460                    OrderByComparator orderByComparator, boolean previous) {
15461                    StringBundler query = null;
15462    
15463                    if (orderByComparator != null) {
15464                            query = new StringBundler(6 +
15465                                            (orderByComparator.getOrderByFields().length * 6));
15466                    }
15467                    else {
15468                            query = new StringBundler(3);
15469                    }
15470    
15471                    if (getDB().isSupportsInlineDistinct()) {
15472                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
15473                    }
15474                    else {
15475                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
15476                    }
15477    
15478                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15479    
15480                    boolean bindDisplayDate = false;
15481    
15482                    if (displayDate == null) {
15483                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15484                    }
15485                    else {
15486                            bindDisplayDate = true;
15487    
15488                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15489                    }
15490    
15491                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15492    
15493                    if (!getDB().isSupportsInlineDistinct()) {
15494                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
15495                    }
15496    
15497                    if (orderByComparator != null) {
15498                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15499    
15500                            if (orderByConditionFields.length > 0) {
15501                                    query.append(WHERE_AND);
15502                            }
15503    
15504                            for (int i = 0; i < orderByConditionFields.length; i++) {
15505                                    if (getDB().isSupportsInlineDistinct()) {
15506                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15507                                    }
15508                                    else {
15509                                            query.append(_ORDER_BY_ENTITY_TABLE);
15510                                    }
15511    
15512                                    query.append(orderByConditionFields[i]);
15513    
15514                                    if ((i + 1) < orderByConditionFields.length) {
15515                                            if (orderByComparator.isAscending() ^ previous) {
15516                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15517                                            }
15518                                            else {
15519                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15520                                            }
15521                                    }
15522                                    else {
15523                                            if (orderByComparator.isAscending() ^ previous) {
15524                                                    query.append(WHERE_GREATER_THAN);
15525                                            }
15526                                            else {
15527                                                    query.append(WHERE_LESSER_THAN);
15528                                            }
15529                                    }
15530                            }
15531    
15532                            query.append(ORDER_BY_CLAUSE);
15533    
15534                            String[] orderByFields = orderByComparator.getOrderByFields();
15535    
15536                            for (int i = 0; i < orderByFields.length; i++) {
15537                                    if (getDB().isSupportsInlineDistinct()) {
15538                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15539                                    }
15540                                    else {
15541                                            query.append(_ORDER_BY_ENTITY_TABLE);
15542                                    }
15543    
15544                                    query.append(orderByFields[i]);
15545    
15546                                    if ((i + 1) < orderByFields.length) {
15547                                            if (orderByComparator.isAscending() ^ previous) {
15548                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15549                                            }
15550                                            else {
15551                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15552                                            }
15553                                    }
15554                                    else {
15555                                            if (orderByComparator.isAscending() ^ previous) {
15556                                                    query.append(ORDER_BY_ASC);
15557                                            }
15558                                            else {
15559                                                    query.append(ORDER_BY_DESC);
15560                                            }
15561                                    }
15562                            }
15563                    }
15564                    else {
15565                            if (getDB().isSupportsInlineDistinct()) {
15566                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15567                            }
15568                            else {
15569                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15570                            }
15571                    }
15572    
15573                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15574                                    BlogsEntry.class.getName(),
15575                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15576    
15577                    SQLQuery q = session.createSQLQuery(sql);
15578    
15579                    q.setFirstResult(0);
15580                    q.setMaxResults(2);
15581    
15582                    if (getDB().isSupportsInlineDistinct()) {
15583                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15584                    }
15585                    else {
15586                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15587                    }
15588    
15589                    QueryPos qPos = QueryPos.getInstance(q);
15590    
15591                    qPos.add(groupId);
15592    
15593                    if (bindDisplayDate) {
15594                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15595                    }
15596    
15597                    qPos.add(status);
15598    
15599                    if (orderByComparator != null) {
15600                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15601    
15602                            for (Object value : values) {
15603                                    qPos.add(value);
15604                            }
15605                    }
15606    
15607                    List<BlogsEntry> list = q.list();
15608    
15609                    if (list.size() == 2) {
15610                            return list.get(1);
15611                    }
15612                    else {
15613                            return null;
15614                    }
15615            }
15616    
15617            /**
15618             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15619             *
15620             * @param groupId the group ID
15621             * @param displayDate the display date
15622             * @param status the status
15623             * @throws SystemException if a system exception occurred
15624             */
15625            @Override
15626            public void removeByG_LtD_S(long groupId, Date displayDate, int status)
15627                    throws SystemException {
15628                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
15629                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15630                            remove(blogsEntry);
15631                    }
15632            }
15633    
15634            /**
15635             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15636             *
15637             * @param groupId the group ID
15638             * @param displayDate the display date
15639             * @param status the status
15640             * @return the number of matching blogs entries
15641             * @throws SystemException if a system exception occurred
15642             */
15643            @Override
15644            public int countByG_LtD_S(long groupId, Date displayDate, int status)
15645                    throws SystemException {
15646                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
15647    
15648                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
15649    
15650                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15651                                    this);
15652    
15653                    if (count == null) {
15654                            StringBundler query = new StringBundler(4);
15655    
15656                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15657    
15658                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15659    
15660                            boolean bindDisplayDate = false;
15661    
15662                            if (displayDate == null) {
15663                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15664                            }
15665                            else {
15666                                    bindDisplayDate = true;
15667    
15668                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15669                            }
15670    
15671                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15672    
15673                            String sql = query.toString();
15674    
15675                            Session session = null;
15676    
15677                            try {
15678                                    session = openSession();
15679    
15680                                    Query q = session.createQuery(sql);
15681    
15682                                    QueryPos qPos = QueryPos.getInstance(q);
15683    
15684                                    qPos.add(groupId);
15685    
15686                                    if (bindDisplayDate) {
15687                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15688                                    }
15689    
15690                                    qPos.add(status);
15691    
15692                                    count = (Long)q.uniqueResult();
15693    
15694                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15695                            }
15696                            catch (Exception e) {
15697                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15698    
15699                                    throw processException(e);
15700                            }
15701                            finally {
15702                                    closeSession(session);
15703                            }
15704                    }
15705    
15706                    return count.intValue();
15707            }
15708    
15709            /**
15710             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15711             *
15712             * @param groupId the group ID
15713             * @param displayDate the display date
15714             * @param status the status
15715             * @return the number of matching blogs entries that the user has permission to view
15716             * @throws SystemException if a system exception occurred
15717             */
15718            @Override
15719            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status)
15720                    throws SystemException {
15721                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15722                            return countByG_LtD_S(groupId, displayDate, status);
15723                    }
15724    
15725                    StringBundler query = new StringBundler(4);
15726    
15727                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
15728    
15729                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15730    
15731                    boolean bindDisplayDate = false;
15732    
15733                    if (displayDate == null) {
15734                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15735                    }
15736                    else {
15737                            bindDisplayDate = true;
15738    
15739                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15740                    }
15741    
15742                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15743    
15744                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15745                                    BlogsEntry.class.getName(),
15746                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15747    
15748                    Session session = null;
15749    
15750                    try {
15751                            session = openSession();
15752    
15753                            SQLQuery q = session.createSQLQuery(sql);
15754    
15755                            q.addScalar(COUNT_COLUMN_NAME,
15756                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15757    
15758                            QueryPos qPos = QueryPos.getInstance(q);
15759    
15760                            qPos.add(groupId);
15761    
15762                            if (bindDisplayDate) {
15763                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
15764                            }
15765    
15766                            qPos.add(status);
15767    
15768                            Long count = (Long)q.uniqueResult();
15769    
15770                            return count.intValue();
15771                    }
15772                    catch (Exception e) {
15773                            throw processException(e);
15774                    }
15775                    finally {
15776                            closeSession(session);
15777                    }
15778            }
15779    
15780            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
15781            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
15782            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15783            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15784            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
15785                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15786                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15787                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
15788                            new String[] {
15789                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15790                                    Integer.class.getName(),
15791                                    
15792                            Integer.class.getName(), Integer.class.getName(),
15793                                    OrderByComparator.class.getName()
15794                            });
15795            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
15796                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15797                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15798                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
15799                            new String[] {
15800                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15801                                    Integer.class.getName()
15802                            });
15803    
15804            /**
15805             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15806             *
15807             * @param groupId the group ID
15808             * @param userId the user ID
15809             * @param displayDate the display date
15810             * @param status the status
15811             * @return the matching blogs entries
15812             * @throws SystemException if a system exception occurred
15813             */
15814            @Override
15815            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15816                    Date displayDate, int status) throws SystemException {
15817                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
15818                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15819            }
15820    
15821            /**
15822             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15823             *
15824             * <p>
15825             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15826             * </p>
15827             *
15828             * @param groupId the group ID
15829             * @param userId the user ID
15830             * @param displayDate the display date
15831             * @param status the status
15832             * @param start the lower bound of the range of blogs entries
15833             * @param end the upper bound of the range of blogs entries (not inclusive)
15834             * @return the range of matching blogs entries
15835             * @throws SystemException if a system exception occurred
15836             */
15837            @Override
15838            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15839                    Date displayDate, int status, int start, int end)
15840                    throws SystemException {
15841                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
15842                            end, null);
15843            }
15844    
15845            /**
15846             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15847             *
15848             * <p>
15849             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15850             * </p>
15851             *
15852             * @param groupId the group ID
15853             * @param userId the user ID
15854             * @param displayDate the display date
15855             * @param status the status
15856             * @param start the lower bound of the range of blogs entries
15857             * @param end the upper bound of the range of blogs entries (not inclusive)
15858             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15859             * @return the ordered range of matching blogs entries
15860             * @throws SystemException if a system exception occurred
15861             */
15862            @Override
15863            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15864                    Date displayDate, int status, int start, int end,
15865                    OrderByComparator orderByComparator) throws SystemException {
15866                    boolean pagination = true;
15867                    FinderPath finderPath = null;
15868                    Object[] finderArgs = null;
15869    
15870                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
15871                    finderArgs = new Object[] {
15872                                    groupId, userId, displayDate, status,
15873                                    
15874                                    start, end, orderByComparator
15875                            };
15876    
15877                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
15878                                    finderArgs, this);
15879    
15880                    if ((list != null) && !list.isEmpty()) {
15881                            for (BlogsEntry blogsEntry : list) {
15882                                    if ((groupId != blogsEntry.getGroupId()) ||
15883                                                    (userId != blogsEntry.getUserId()) ||
15884                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
15885                                                                                                                                    .getTime()) ||
15886                                                    (status == blogsEntry.getStatus())) {
15887                                            list = null;
15888    
15889                                            break;
15890                                    }
15891                            }
15892                    }
15893    
15894                    if (list == null) {
15895                            StringBundler query = null;
15896    
15897                            if (orderByComparator != null) {
15898                                    query = new StringBundler(6 +
15899                                                    (orderByComparator.getOrderByFields().length * 3));
15900                            }
15901                            else {
15902                                    query = new StringBundler(6);
15903                            }
15904    
15905                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15906    
15907                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15908    
15909                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15910    
15911                            boolean bindDisplayDate = false;
15912    
15913                            if (displayDate == null) {
15914                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
15915                            }
15916                            else {
15917                                    bindDisplayDate = true;
15918    
15919                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
15920                            }
15921    
15922                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
15923    
15924                            if (orderByComparator != null) {
15925                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15926                                            orderByComparator);
15927                            }
15928                            else
15929                             if (pagination) {
15930                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15931                            }
15932    
15933                            String sql = query.toString();
15934    
15935                            Session session = null;
15936    
15937                            try {
15938                                    session = openSession();
15939    
15940                                    Query q = session.createQuery(sql);
15941    
15942                                    QueryPos qPos = QueryPos.getInstance(q);
15943    
15944                                    qPos.add(groupId);
15945    
15946                                    qPos.add(userId);
15947    
15948                                    if (bindDisplayDate) {
15949                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15950                                    }
15951    
15952                                    qPos.add(status);
15953    
15954                                    if (!pagination) {
15955                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15956                                                            start, end, false);
15957    
15958                                            Collections.sort(list);
15959    
15960                                            list = new UnmodifiableList<BlogsEntry>(list);
15961                                    }
15962                                    else {
15963                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15964                                                            start, end);
15965                                    }
15966    
15967                                    cacheResult(list);
15968    
15969                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15970                            }
15971                            catch (Exception e) {
15972                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15973    
15974                                    throw processException(e);
15975                            }
15976                            finally {
15977                                    closeSession(session);
15978                            }
15979                    }
15980    
15981                    return list;
15982            }
15983    
15984            /**
15985             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15986             *
15987             * @param groupId the group ID
15988             * @param userId the user ID
15989             * @param displayDate the display date
15990             * @param status the status
15991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15992             * @return the first matching blogs entry
15993             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15994             * @throws SystemException if a system exception occurred
15995             */
15996            @Override
15997            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
15998                    Date displayDate, int status, OrderByComparator orderByComparator)
15999                    throws NoSuchEntryException, SystemException {
16000                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
16001                                    displayDate, status, orderByComparator);
16002    
16003                    if (blogsEntry != null) {
16004                            return blogsEntry;
16005                    }
16006    
16007                    StringBundler msg = new StringBundler(10);
16008    
16009                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16010    
16011                    msg.append("groupId=");
16012                    msg.append(groupId);
16013    
16014                    msg.append(", userId=");
16015                    msg.append(userId);
16016    
16017                    msg.append(", displayDate=");
16018                    msg.append(displayDate);
16019    
16020                    msg.append(", status=");
16021                    msg.append(status);
16022    
16023                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16024    
16025                    throw new NoSuchEntryException(msg.toString());
16026            }
16027    
16028            /**
16029             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16030             *
16031             * @param groupId the group ID
16032             * @param userId the user ID
16033             * @param displayDate the display date
16034             * @param status the status
16035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16036             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16037             * @throws SystemException if a system exception occurred
16038             */
16039            @Override
16040            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
16041                    Date displayDate, int status, OrderByComparator orderByComparator)
16042                    throws SystemException {
16043                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16044                                    displayDate, status, 0, 1, orderByComparator);
16045    
16046                    if (!list.isEmpty()) {
16047                            return list.get(0);
16048                    }
16049    
16050                    return null;
16051            }
16052    
16053            /**
16054             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16055             *
16056             * @param groupId the group ID
16057             * @param userId the user ID
16058             * @param displayDate the display date
16059             * @param status the status
16060             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16061             * @return the last matching blogs entry
16062             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
16063             * @throws SystemException if a system exception occurred
16064             */
16065            @Override
16066            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
16067                    Date displayDate, int status, OrderByComparator orderByComparator)
16068                    throws NoSuchEntryException, SystemException {
16069                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
16070                                    displayDate, status, orderByComparator);
16071    
16072                    if (blogsEntry != null) {
16073                            return blogsEntry;
16074                    }
16075    
16076                    StringBundler msg = new StringBundler(10);
16077    
16078                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16079    
16080                    msg.append("groupId=");
16081                    msg.append(groupId);
16082    
16083                    msg.append(", userId=");
16084                    msg.append(userId);
16085    
16086                    msg.append(", displayDate=");
16087                    msg.append(displayDate);
16088    
16089                    msg.append(", status=");
16090                    msg.append(status);
16091    
16092                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16093    
16094                    throw new NoSuchEntryException(msg.toString());
16095            }
16096    
16097            /**
16098             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16099             *
16100             * @param groupId the group ID
16101             * @param userId the user ID
16102             * @param displayDate the display date
16103             * @param status the status
16104             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16105             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16106             * @throws SystemException if a system exception occurred
16107             */
16108            @Override
16109            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
16110                    Date displayDate, int status, OrderByComparator orderByComparator)
16111                    throws SystemException {
16112                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16113    
16114                    if (count == 0) {
16115                            return null;
16116                    }
16117    
16118                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16119                                    displayDate, status, count - 1, count, orderByComparator);
16120    
16121                    if (!list.isEmpty()) {
16122                            return list.get(0);
16123                    }
16124    
16125                    return null;
16126            }
16127    
16128            /**
16129             * 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;.
16130             *
16131             * @param entryId the primary key of the current blogs entry
16132             * @param groupId the group ID
16133             * @param userId the user ID
16134             * @param displayDate the display date
16135             * @param status the status
16136             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16137             * @return the previous, current, and next blogs entry
16138             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16139             * @throws SystemException if a system exception occurred
16140             */
16141            @Override
16142            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
16143                    long groupId, long userId, Date displayDate, int status,
16144                    OrderByComparator orderByComparator)
16145                    throws NoSuchEntryException, SystemException {
16146                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16147    
16148                    Session session = null;
16149    
16150                    try {
16151                            session = openSession();
16152    
16153                            BlogsEntry[] array = new BlogsEntryImpl[3];
16154    
16155                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16156                                            groupId, userId, displayDate, status, orderByComparator,
16157                                            true);
16158    
16159                            array[1] = blogsEntry;
16160    
16161                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16162                                            groupId, userId, displayDate, status, orderByComparator,
16163                                            false);
16164    
16165                            return array;
16166                    }
16167                    catch (Exception e) {
16168                            throw processException(e);
16169                    }
16170                    finally {
16171                            closeSession(session);
16172                    }
16173            }
16174    
16175            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
16176                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16177                    int status, OrderByComparator orderByComparator, boolean previous) {
16178                    StringBundler query = null;
16179    
16180                    if (orderByComparator != null) {
16181                            query = new StringBundler(6 +
16182                                            (orderByComparator.getOrderByFields().length * 6));
16183                    }
16184                    else {
16185                            query = new StringBundler(3);
16186                    }
16187    
16188                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16189    
16190                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16191    
16192                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16193    
16194                    boolean bindDisplayDate = false;
16195    
16196                    if (displayDate == null) {
16197                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16198                    }
16199                    else {
16200                            bindDisplayDate = true;
16201    
16202                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16203                    }
16204    
16205                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16206    
16207                    if (orderByComparator != null) {
16208                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16209    
16210                            if (orderByConditionFields.length > 0) {
16211                                    query.append(WHERE_AND);
16212                            }
16213    
16214                            for (int i = 0; i < orderByConditionFields.length; i++) {
16215                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16216                                    query.append(orderByConditionFields[i]);
16217    
16218                                    if ((i + 1) < orderByConditionFields.length) {
16219                                            if (orderByComparator.isAscending() ^ previous) {
16220                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16221                                            }
16222                                            else {
16223                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16224                                            }
16225                                    }
16226                                    else {
16227                                            if (orderByComparator.isAscending() ^ previous) {
16228                                                    query.append(WHERE_GREATER_THAN);
16229                                            }
16230                                            else {
16231                                                    query.append(WHERE_LESSER_THAN);
16232                                            }
16233                                    }
16234                            }
16235    
16236                            query.append(ORDER_BY_CLAUSE);
16237    
16238                            String[] orderByFields = orderByComparator.getOrderByFields();
16239    
16240                            for (int i = 0; i < orderByFields.length; i++) {
16241                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16242                                    query.append(orderByFields[i]);
16243    
16244                                    if ((i + 1) < orderByFields.length) {
16245                                            if (orderByComparator.isAscending() ^ previous) {
16246                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16247                                            }
16248                                            else {
16249                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16250                                            }
16251                                    }
16252                                    else {
16253                                            if (orderByComparator.isAscending() ^ previous) {
16254                                                    query.append(ORDER_BY_ASC);
16255                                            }
16256                                            else {
16257                                                    query.append(ORDER_BY_DESC);
16258                                            }
16259                                    }
16260                            }
16261                    }
16262                    else {
16263                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16264                    }
16265    
16266                    String sql = query.toString();
16267    
16268                    Query q = session.createQuery(sql);
16269    
16270                    q.setFirstResult(0);
16271                    q.setMaxResults(2);
16272    
16273                    QueryPos qPos = QueryPos.getInstance(q);
16274    
16275                    qPos.add(groupId);
16276    
16277                    qPos.add(userId);
16278    
16279                    if (bindDisplayDate) {
16280                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16281                    }
16282    
16283                    qPos.add(status);
16284    
16285                    if (orderByComparator != null) {
16286                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16287    
16288                            for (Object value : values) {
16289                                    qPos.add(value);
16290                            }
16291                    }
16292    
16293                    List<BlogsEntry> list = q.list();
16294    
16295                    if (list.size() == 2) {
16296                            return list.get(1);
16297                    }
16298                    else {
16299                            return null;
16300                    }
16301            }
16302    
16303            /**
16304             * 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;.
16305             *
16306             * @param groupId the group ID
16307             * @param userId the user ID
16308             * @param displayDate the display date
16309             * @param status the status
16310             * @return the matching blogs entries that the user has permission to view
16311             * @throws SystemException if a system exception occurred
16312             */
16313            @Override
16314            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
16315                    Date displayDate, int status) throws SystemException {
16316                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
16317                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16318            }
16319    
16320            /**
16321             * 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;.
16322             *
16323             * <p>
16324             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16325             * </p>
16326             *
16327             * @param groupId the group ID
16328             * @param userId the user ID
16329             * @param displayDate the display date
16330             * @param status the status
16331             * @param start the lower bound of the range of blogs entries
16332             * @param end the upper bound of the range of blogs entries (not inclusive)
16333             * @return the range of matching blogs entries that the user has permission to view
16334             * @throws SystemException if a system exception occurred
16335             */
16336            @Override
16337            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
16338                    Date displayDate, int status, int start, int end)
16339                    throws SystemException {
16340                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
16341                            start, end, null);
16342            }
16343    
16344            /**
16345             * 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;.
16346             *
16347             * <p>
16348             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16349             * </p>
16350             *
16351             * @param groupId the group ID
16352             * @param userId the user ID
16353             * @param displayDate the display date
16354             * @param status the status
16355             * @param start the lower bound of the range of blogs entries
16356             * @param end the upper bound of the range of blogs entries (not inclusive)
16357             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16358             * @return the ordered range of matching blogs entries that the user has permission to view
16359             * @throws SystemException if a system exception occurred
16360             */
16361            @Override
16362            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
16363                    Date displayDate, int status, int start, int end,
16364                    OrderByComparator orderByComparator) throws SystemException {
16365                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16366                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
16367                                    start, end, orderByComparator);
16368                    }
16369    
16370                    StringBundler query = null;
16371    
16372                    if (orderByComparator != null) {
16373                            query = new StringBundler(6 +
16374                                            (orderByComparator.getOrderByFields().length * 3));
16375                    }
16376                    else {
16377                            query = new StringBundler(6);
16378                    }
16379    
16380                    if (getDB().isSupportsInlineDistinct()) {
16381                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16382                    }
16383                    else {
16384                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16385                    }
16386    
16387                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16388    
16389                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16390    
16391                    boolean bindDisplayDate = false;
16392    
16393                    if (displayDate == null) {
16394                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16395                    }
16396                    else {
16397                            bindDisplayDate = true;
16398    
16399                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16400                    }
16401    
16402                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16403    
16404                    if (!getDB().isSupportsInlineDistinct()) {
16405                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16406                    }
16407    
16408                    if (orderByComparator != null) {
16409                            if (getDB().isSupportsInlineDistinct()) {
16410                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16411                                            orderByComparator, true);
16412                            }
16413                            else {
16414                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16415                                            orderByComparator, true);
16416                            }
16417                    }
16418                    else {
16419                            if (getDB().isSupportsInlineDistinct()) {
16420                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16421                            }
16422                            else {
16423                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16424                            }
16425                    }
16426    
16427                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16428                                    BlogsEntry.class.getName(),
16429                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16430    
16431                    Session session = null;
16432    
16433                    try {
16434                            session = openSession();
16435    
16436                            SQLQuery q = session.createSQLQuery(sql);
16437    
16438                            if (getDB().isSupportsInlineDistinct()) {
16439                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16440                            }
16441                            else {
16442                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16443                            }
16444    
16445                            QueryPos qPos = QueryPos.getInstance(q);
16446    
16447                            qPos.add(groupId);
16448    
16449                            qPos.add(userId);
16450    
16451                            if (bindDisplayDate) {
16452                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
16453                            }
16454    
16455                            qPos.add(status);
16456    
16457                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16458                    }
16459                    catch (Exception e) {
16460                            throw processException(e);
16461                    }
16462                    finally {
16463                            closeSession(session);
16464                    }
16465            }
16466    
16467            /**
16468             * 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;.
16469             *
16470             * @param entryId the primary key of the current blogs entry
16471             * @param groupId the group ID
16472             * @param userId the user ID
16473             * @param displayDate the display date
16474             * @param status the status
16475             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16476             * @return the previous, current, and next blogs entry
16477             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16478             * @throws SystemException if a system exception occurred
16479             */
16480            @Override
16481            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
16482                    long groupId, long userId, Date displayDate, int status,
16483                    OrderByComparator orderByComparator)
16484                    throws NoSuchEntryException, SystemException {
16485                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16486                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
16487                                    displayDate, status, orderByComparator);
16488                    }
16489    
16490                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16491    
16492                    Session session = null;
16493    
16494                    try {
16495                            session = openSession();
16496    
16497                            BlogsEntry[] array = new BlogsEntryImpl[3];
16498    
16499                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16500                                            groupId, userId, displayDate, status, orderByComparator,
16501                                            true);
16502    
16503                            array[1] = blogsEntry;
16504    
16505                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16506                                            groupId, userId, displayDate, status, orderByComparator,
16507                                            false);
16508    
16509                            return array;
16510                    }
16511                    catch (Exception e) {
16512                            throw processException(e);
16513                    }
16514                    finally {
16515                            closeSession(session);
16516                    }
16517            }
16518    
16519            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
16520                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16521                    int status, OrderByComparator orderByComparator, boolean previous) {
16522                    StringBundler query = null;
16523    
16524                    if (orderByComparator != null) {
16525                            query = new StringBundler(6 +
16526                                            (orderByComparator.getOrderByFields().length * 6));
16527                    }
16528                    else {
16529                            query = new StringBundler(3);
16530                    }
16531    
16532                    if (getDB().isSupportsInlineDistinct()) {
16533                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16534                    }
16535                    else {
16536                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16537                    }
16538    
16539                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16540    
16541                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16542    
16543                    boolean bindDisplayDate = false;
16544    
16545                    if (displayDate == null) {
16546                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16547                    }
16548                    else {
16549                            bindDisplayDate = true;
16550    
16551                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16552                    }
16553    
16554                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16555    
16556                    if (!getDB().isSupportsInlineDistinct()) {
16557                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16558                    }
16559    
16560                    if (orderByComparator != null) {
16561                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16562    
16563                            if (orderByConditionFields.length > 0) {
16564                                    query.append(WHERE_AND);
16565                            }
16566    
16567                            for (int i = 0; i < orderByConditionFields.length; i++) {
16568                                    if (getDB().isSupportsInlineDistinct()) {
16569                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16570                                    }
16571                                    else {
16572                                            query.append(_ORDER_BY_ENTITY_TABLE);
16573                                    }
16574    
16575                                    query.append(orderByConditionFields[i]);
16576    
16577                                    if ((i + 1) < orderByConditionFields.length) {
16578                                            if (orderByComparator.isAscending() ^ previous) {
16579                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16580                                            }
16581                                            else {
16582                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16583                                            }
16584                                    }
16585                                    else {
16586                                            if (orderByComparator.isAscending() ^ previous) {
16587                                                    query.append(WHERE_GREATER_THAN);
16588                                            }
16589                                            else {
16590                                                    query.append(WHERE_LESSER_THAN);
16591                                            }
16592                                    }
16593                            }
16594    
16595                            query.append(ORDER_BY_CLAUSE);
16596    
16597                            String[] orderByFields = orderByComparator.getOrderByFields();
16598    
16599                            for (int i = 0; i < orderByFields.length; i++) {
16600                                    if (getDB().isSupportsInlineDistinct()) {
16601                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16602                                    }
16603                                    else {
16604                                            query.append(_ORDER_BY_ENTITY_TABLE);
16605                                    }
16606    
16607                                    query.append(orderByFields[i]);
16608    
16609                                    if ((i + 1) < orderByFields.length) {
16610                                            if (orderByComparator.isAscending() ^ previous) {
16611                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16612                                            }
16613                                            else {
16614                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16615                                            }
16616                                    }
16617                                    else {
16618                                            if (orderByComparator.isAscending() ^ previous) {
16619                                                    query.append(ORDER_BY_ASC);
16620                                            }
16621                                            else {
16622                                                    query.append(ORDER_BY_DESC);
16623                                            }
16624                                    }
16625                            }
16626                    }
16627                    else {
16628                            if (getDB().isSupportsInlineDistinct()) {
16629                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16630                            }
16631                            else {
16632                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16633                            }
16634                    }
16635    
16636                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16637                                    BlogsEntry.class.getName(),
16638                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16639    
16640                    SQLQuery q = session.createSQLQuery(sql);
16641    
16642                    q.setFirstResult(0);
16643                    q.setMaxResults(2);
16644    
16645                    if (getDB().isSupportsInlineDistinct()) {
16646                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16647                    }
16648                    else {
16649                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16650                    }
16651    
16652                    QueryPos qPos = QueryPos.getInstance(q);
16653    
16654                    qPos.add(groupId);
16655    
16656                    qPos.add(userId);
16657    
16658                    if (bindDisplayDate) {
16659                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16660                    }
16661    
16662                    qPos.add(status);
16663    
16664                    if (orderByComparator != null) {
16665                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16666    
16667                            for (Object value : values) {
16668                                    qPos.add(value);
16669                            }
16670                    }
16671    
16672                    List<BlogsEntry> list = q.list();
16673    
16674                    if (list.size() == 2) {
16675                            return list.get(1);
16676                    }
16677                    else {
16678                            return null;
16679                    }
16680            }
16681    
16682            /**
16683             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
16684             *
16685             * @param groupId the group ID
16686             * @param userId the user ID
16687             * @param displayDate the display date
16688             * @param status the status
16689             * @throws SystemException if a system exception occurred
16690             */
16691            @Override
16692            public void removeByG_U_LtD_NotS(long groupId, long userId,
16693                    Date displayDate, int status) throws SystemException {
16694                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
16695                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16696                            remove(blogsEntry);
16697                    }
16698            }
16699    
16700            /**
16701             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16702             *
16703             * @param groupId the group ID
16704             * @param userId the user ID
16705             * @param displayDate the display date
16706             * @param status the status
16707             * @return the number of matching blogs entries
16708             * @throws SystemException if a system exception occurred
16709             */
16710            @Override
16711            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
16712                    int status) throws SystemException {
16713                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
16714    
16715                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16716    
16717                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16718                                    this);
16719    
16720                    if (count == null) {
16721                            StringBundler query = new StringBundler(5);
16722    
16723                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16724    
16725                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16726    
16727                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16728    
16729                            boolean bindDisplayDate = false;
16730    
16731                            if (displayDate == null) {
16732                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16733                            }
16734                            else {
16735                                    bindDisplayDate = true;
16736    
16737                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16738                            }
16739    
16740                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16741    
16742                            String sql = query.toString();
16743    
16744                            Session session = null;
16745    
16746                            try {
16747                                    session = openSession();
16748    
16749                                    Query q = session.createQuery(sql);
16750    
16751                                    QueryPos qPos = QueryPos.getInstance(q);
16752    
16753                                    qPos.add(groupId);
16754    
16755                                    qPos.add(userId);
16756    
16757                                    if (bindDisplayDate) {
16758                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16759                                    }
16760    
16761                                    qPos.add(status);
16762    
16763                                    count = (Long)q.uniqueResult();
16764    
16765                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16766                            }
16767                            catch (Exception e) {
16768                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16769    
16770                                    throw processException(e);
16771                            }
16772                            finally {
16773                                    closeSession(session);
16774                            }
16775                    }
16776    
16777                    return count.intValue();
16778            }
16779    
16780            /**
16781             * 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;.
16782             *
16783             * @param groupId the group ID
16784             * @param userId the user ID
16785             * @param displayDate the display date
16786             * @param status the status
16787             * @return the number of matching blogs entries that the user has permission to view
16788             * @throws SystemException if a system exception occurred
16789             */
16790            @Override
16791            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
16792                    Date displayDate, int status) throws SystemException {
16793                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16794                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16795                    }
16796    
16797                    StringBundler query = new StringBundler(5);
16798    
16799                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16800    
16801                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16802    
16803                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16804    
16805                    boolean bindDisplayDate = false;
16806    
16807                    if (displayDate == null) {
16808                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16809                    }
16810                    else {
16811                            bindDisplayDate = true;
16812    
16813                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16814                    }
16815    
16816                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16817    
16818                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16819                                    BlogsEntry.class.getName(),
16820                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16821    
16822                    Session session = null;
16823    
16824                    try {
16825                            session = openSession();
16826    
16827                            SQLQuery q = session.createSQLQuery(sql);
16828    
16829                            q.addScalar(COUNT_COLUMN_NAME,
16830                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16831    
16832                            QueryPos qPos = QueryPos.getInstance(q);
16833    
16834                            qPos.add(groupId);
16835    
16836                            qPos.add(userId);
16837    
16838                            if (bindDisplayDate) {
16839                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
16840                            }
16841    
16842                            qPos.add(status);
16843    
16844                            Long count = (Long)q.uniqueResult();
16845    
16846                            return count.intValue();
16847                    }
16848                    catch (Exception e) {
16849                            throw processException(e);
16850                    }
16851                    finally {
16852                            closeSession(session);
16853                    }
16854            }
16855    
16856            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
16857            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
16858            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
16859            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16860            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
16861            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
16862                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16863                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16864                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
16865                            new String[] {
16866                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16867                                    Integer.class.getName(),
16868                                    
16869                            Integer.class.getName(), Integer.class.getName(),
16870                                    OrderByComparator.class.getName()
16871                            });
16872            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16873                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16874                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16875                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16876                            new String[] {
16877                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16878                                    Integer.class.getName()
16879                            });
16880    
16881            /**
16882             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16883             *
16884             * @param groupId the group ID
16885             * @param userId the user ID
16886             * @param displayDate the display date
16887             * @param status the status
16888             * @return the matching blogs entries
16889             * @throws SystemException if a system exception occurred
16890             */
16891            @Override
16892            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16893                    Date displayDate, int status) throws SystemException {
16894                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16895                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16896            }
16897    
16898            /**
16899             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16900             *
16901             * <p>
16902             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16903             * </p>
16904             *
16905             * @param groupId the group ID
16906             * @param userId the user ID
16907             * @param displayDate the display date
16908             * @param status the status
16909             * @param start the lower bound of the range of blogs entries
16910             * @param end the upper bound of the range of blogs entries (not inclusive)
16911             * @return the range of matching blogs entries
16912             * @throws SystemException if a system exception occurred
16913             */
16914            @Override
16915            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16916                    Date displayDate, int status, int start, int end)
16917                    throws SystemException {
16918                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16919                            end, null);
16920            }
16921    
16922            /**
16923             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16924             *
16925             * <p>
16926             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16927             * </p>
16928             *
16929             * @param groupId the group ID
16930             * @param userId the user ID
16931             * @param displayDate the display date
16932             * @param status the status
16933             * @param start the lower bound of the range of blogs entries
16934             * @param end the upper bound of the range of blogs entries (not inclusive)
16935             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16936             * @return the ordered range of matching blogs entries
16937             * @throws SystemException if a system exception occurred
16938             */
16939            @Override
16940            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16941                    Date displayDate, int status, int start, int end,
16942                    OrderByComparator orderByComparator) throws SystemException {
16943                    boolean pagination = true;
16944                    FinderPath finderPath = null;
16945                    Object[] finderArgs = null;
16946    
16947                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16948                    finderArgs = new Object[] {
16949                                    groupId, userId, displayDate, status,
16950                                    
16951                                    start, end, orderByComparator
16952                            };
16953    
16954                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
16955                                    finderArgs, this);
16956    
16957                    if ((list != null) && !list.isEmpty()) {
16958                            for (BlogsEntry blogsEntry : list) {
16959                                    if ((groupId != blogsEntry.getGroupId()) ||
16960                                                    (userId != blogsEntry.getUserId()) ||
16961                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
16962                                                                                                                                    .getTime()) ||
16963                                                    (status != blogsEntry.getStatus())) {
16964                                            list = null;
16965    
16966                                            break;
16967                                    }
16968                            }
16969                    }
16970    
16971                    if (list == null) {
16972                            StringBundler query = null;
16973    
16974                            if (orderByComparator != null) {
16975                                    query = new StringBundler(6 +
16976                                                    (orderByComparator.getOrderByFields().length * 3));
16977                            }
16978                            else {
16979                                    query = new StringBundler(6);
16980                            }
16981    
16982                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16983    
16984                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16985    
16986                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16987    
16988                            boolean bindDisplayDate = false;
16989    
16990                            if (displayDate == null) {
16991                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16992                            }
16993                            else {
16994                                    bindDisplayDate = true;
16995    
16996                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16997                            }
16998    
16999                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17000    
17001                            if (orderByComparator != null) {
17002                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17003                                            orderByComparator);
17004                            }
17005                            else
17006                             if (pagination) {
17007                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17008                            }
17009    
17010                            String sql = query.toString();
17011    
17012                            Session session = null;
17013    
17014                            try {
17015                                    session = openSession();
17016    
17017                                    Query q = session.createQuery(sql);
17018    
17019                                    QueryPos qPos = QueryPos.getInstance(q);
17020    
17021                                    qPos.add(groupId);
17022    
17023                                    qPos.add(userId);
17024    
17025                                    if (bindDisplayDate) {
17026                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17027                                    }
17028    
17029                                    qPos.add(status);
17030    
17031                                    if (!pagination) {
17032                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17033                                                            start, end, false);
17034    
17035                                            Collections.sort(list);
17036    
17037                                            list = new UnmodifiableList<BlogsEntry>(list);
17038                                    }
17039                                    else {
17040                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17041                                                            start, end);
17042                                    }
17043    
17044                                    cacheResult(list);
17045    
17046                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17047                            }
17048                            catch (Exception e) {
17049                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17050    
17051                                    throw processException(e);
17052                            }
17053                            finally {
17054                                    closeSession(session);
17055                            }
17056                    }
17057    
17058                    return list;
17059            }
17060    
17061            /**
17062             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17063             *
17064             * @param groupId the group ID
17065             * @param userId the user ID
17066             * @param displayDate the display date
17067             * @param status the status
17068             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17069             * @return the first matching blogs entry
17070             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
17071             * @throws SystemException if a system exception occurred
17072             */
17073            @Override
17074            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
17075                    Date displayDate, int status, OrderByComparator orderByComparator)
17076                    throws NoSuchEntryException, SystemException {
17077                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
17078                                    displayDate, status, orderByComparator);
17079    
17080                    if (blogsEntry != null) {
17081                            return blogsEntry;
17082                    }
17083    
17084                    StringBundler msg = new StringBundler(10);
17085    
17086                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17087    
17088                    msg.append("groupId=");
17089                    msg.append(groupId);
17090    
17091                    msg.append(", userId=");
17092                    msg.append(userId);
17093    
17094                    msg.append(", displayDate=");
17095                    msg.append(displayDate);
17096    
17097                    msg.append(", status=");
17098                    msg.append(status);
17099    
17100                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17101    
17102                    throw new NoSuchEntryException(msg.toString());
17103            }
17104    
17105            /**
17106             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17107             *
17108             * @param groupId the group ID
17109             * @param userId the user ID
17110             * @param displayDate the display date
17111             * @param status the status
17112             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17113             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17114             * @throws SystemException if a system exception occurred
17115             */
17116            @Override
17117            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
17118                    Date displayDate, int status, OrderByComparator orderByComparator)
17119                    throws SystemException {
17120                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
17121                                    status, 0, 1, orderByComparator);
17122    
17123                    if (!list.isEmpty()) {
17124                            return list.get(0);
17125                    }
17126    
17127                    return null;
17128            }
17129    
17130            /**
17131             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17132             *
17133             * @param groupId the group ID
17134             * @param userId the user ID
17135             * @param displayDate the display date
17136             * @param status the status
17137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17138             * @return the last matching blogs entry
17139             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
17140             * @throws SystemException if a system exception occurred
17141             */
17142            @Override
17143            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
17144                    Date displayDate, int status, OrderByComparator orderByComparator)
17145                    throws NoSuchEntryException, SystemException {
17146                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
17147                                    displayDate, status, orderByComparator);
17148    
17149                    if (blogsEntry != null) {
17150                            return blogsEntry;
17151                    }
17152    
17153                    StringBundler msg = new StringBundler(10);
17154    
17155                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17156    
17157                    msg.append("groupId=");
17158                    msg.append(groupId);
17159    
17160                    msg.append(", userId=");
17161                    msg.append(userId);
17162    
17163                    msg.append(", displayDate=");
17164                    msg.append(displayDate);
17165    
17166                    msg.append(", status=");
17167                    msg.append(status);
17168    
17169                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17170    
17171                    throw new NoSuchEntryException(msg.toString());
17172            }
17173    
17174            /**
17175             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17176             *
17177             * @param groupId the group ID
17178             * @param userId the user ID
17179             * @param displayDate the display date
17180             * @param status the status
17181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17182             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17183             * @throws SystemException if a system exception occurred
17184             */
17185            @Override
17186            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
17187                    Date displayDate, int status, OrderByComparator orderByComparator)
17188                    throws SystemException {
17189                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
17190    
17191                    if (count == 0) {
17192                            return null;
17193                    }
17194    
17195                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
17196                                    status, count - 1, count, orderByComparator);
17197    
17198                    if (!list.isEmpty()) {
17199                            return list.get(0);
17200                    }
17201    
17202                    return null;
17203            }
17204    
17205            /**
17206             * 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;.
17207             *
17208             * @param entryId the primary key of the current blogs entry
17209             * @param groupId the group ID
17210             * @param userId the user ID
17211             * @param displayDate the display date
17212             * @param status the status
17213             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17214             * @return the previous, current, and next blogs entry
17215             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17216             * @throws SystemException if a system exception occurred
17217             */
17218            @Override
17219            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
17220                    long userId, Date displayDate, int status,
17221                    OrderByComparator orderByComparator)
17222                    throws NoSuchEntryException, SystemException {
17223                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17224    
17225                    Session session = null;
17226    
17227                    try {
17228                            session = openSession();
17229    
17230                            BlogsEntry[] array = new BlogsEntryImpl[3];
17231    
17232                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
17233                                            userId, displayDate, status, orderByComparator, true);
17234    
17235                            array[1] = blogsEntry;
17236    
17237                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
17238                                            userId, displayDate, status, orderByComparator, false);
17239    
17240                            return array;
17241                    }
17242                    catch (Exception e) {
17243                            throw processException(e);
17244                    }
17245                    finally {
17246                            closeSession(session);
17247                    }
17248            }
17249    
17250            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
17251                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17252                    int status, OrderByComparator orderByComparator, boolean previous) {
17253                    StringBundler query = null;
17254    
17255                    if (orderByComparator != null) {
17256                            query = new StringBundler(6 +
17257                                            (orderByComparator.getOrderByFields().length * 6));
17258                    }
17259                    else {
17260                            query = new StringBundler(3);
17261                    }
17262    
17263                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17264    
17265                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17266    
17267                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17268    
17269                    boolean bindDisplayDate = false;
17270    
17271                    if (displayDate == null) {
17272                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17273                    }
17274                    else {
17275                            bindDisplayDate = true;
17276    
17277                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17278                    }
17279    
17280                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17281    
17282                    if (orderByComparator != null) {
17283                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17284    
17285                            if (orderByConditionFields.length > 0) {
17286                                    query.append(WHERE_AND);
17287                            }
17288    
17289                            for (int i = 0; i < orderByConditionFields.length; i++) {
17290                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17291                                    query.append(orderByConditionFields[i]);
17292    
17293                                    if ((i + 1) < orderByConditionFields.length) {
17294                                            if (orderByComparator.isAscending() ^ previous) {
17295                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17296                                            }
17297                                            else {
17298                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17299                                            }
17300                                    }
17301                                    else {
17302                                            if (orderByComparator.isAscending() ^ previous) {
17303                                                    query.append(WHERE_GREATER_THAN);
17304                                            }
17305                                            else {
17306                                                    query.append(WHERE_LESSER_THAN);
17307                                            }
17308                                    }
17309                            }
17310    
17311                            query.append(ORDER_BY_CLAUSE);
17312    
17313                            String[] orderByFields = orderByComparator.getOrderByFields();
17314    
17315                            for (int i = 0; i < orderByFields.length; i++) {
17316                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17317                                    query.append(orderByFields[i]);
17318    
17319                                    if ((i + 1) < orderByFields.length) {
17320                                            if (orderByComparator.isAscending() ^ previous) {
17321                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17322                                            }
17323                                            else {
17324                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17325                                            }
17326                                    }
17327                                    else {
17328                                            if (orderByComparator.isAscending() ^ previous) {
17329                                                    query.append(ORDER_BY_ASC);
17330                                            }
17331                                            else {
17332                                                    query.append(ORDER_BY_DESC);
17333                                            }
17334                                    }
17335                            }
17336                    }
17337                    else {
17338                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17339                    }
17340    
17341                    String sql = query.toString();
17342    
17343                    Query q = session.createQuery(sql);
17344    
17345                    q.setFirstResult(0);
17346                    q.setMaxResults(2);
17347    
17348                    QueryPos qPos = QueryPos.getInstance(q);
17349    
17350                    qPos.add(groupId);
17351    
17352                    qPos.add(userId);
17353    
17354                    if (bindDisplayDate) {
17355                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17356                    }
17357    
17358                    qPos.add(status);
17359    
17360                    if (orderByComparator != null) {
17361                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17362    
17363                            for (Object value : values) {
17364                                    qPos.add(value);
17365                            }
17366                    }
17367    
17368                    List<BlogsEntry> list = q.list();
17369    
17370                    if (list.size() == 2) {
17371                            return list.get(1);
17372                    }
17373                    else {
17374                            return null;
17375                    }
17376            }
17377    
17378            /**
17379             * 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;.
17380             *
17381             * @param groupId the group ID
17382             * @param userId the user ID
17383             * @param displayDate the display date
17384             * @param status the status
17385             * @return the matching blogs entries that the user has permission to view
17386             * @throws SystemException if a system exception occurred
17387             */
17388            @Override
17389            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17390                    Date displayDate, int status) throws SystemException {
17391                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17392                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17393            }
17394    
17395            /**
17396             * 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;.
17397             *
17398             * <p>
17399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
17400             * </p>
17401             *
17402             * @param groupId the group ID
17403             * @param userId the user ID
17404             * @param displayDate the display date
17405             * @param status the status
17406             * @param start the lower bound of the range of blogs entries
17407             * @param end the upper bound of the range of blogs entries (not inclusive)
17408             * @return the range of matching blogs entries that the user has permission to view
17409             * @throws SystemException if a system exception occurred
17410             */
17411            @Override
17412            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17413                    Date displayDate, int status, int start, int end)
17414                    throws SystemException {
17415                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17416                            start, end, null);
17417            }
17418    
17419            /**
17420             * 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;.
17421             *
17422             * <p>
17423             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
17424             * </p>
17425             *
17426             * @param groupId the group ID
17427             * @param userId the user ID
17428             * @param displayDate the display date
17429             * @param status the status
17430             * @param start the lower bound of the range of blogs entries
17431             * @param end the upper bound of the range of blogs entries (not inclusive)
17432             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17433             * @return the ordered range of matching blogs entries that the user has permission to view
17434             * @throws SystemException if a system exception occurred
17435             */
17436            @Override
17437            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17438                    Date displayDate, int status, int start, int end,
17439                    OrderByComparator orderByComparator) throws SystemException {
17440                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17441                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
17442                                    end, orderByComparator);
17443                    }
17444    
17445                    StringBundler query = null;
17446    
17447                    if (orderByComparator != null) {
17448                            query = new StringBundler(6 +
17449                                            (orderByComparator.getOrderByFields().length * 3));
17450                    }
17451                    else {
17452                            query = new StringBundler(6);
17453                    }
17454    
17455                    if (getDB().isSupportsInlineDistinct()) {
17456                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17457                    }
17458                    else {
17459                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17460                    }
17461    
17462                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17463    
17464                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17465    
17466                    boolean bindDisplayDate = false;
17467    
17468                    if (displayDate == null) {
17469                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17470                    }
17471                    else {
17472                            bindDisplayDate = true;
17473    
17474                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17475                    }
17476    
17477                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17478    
17479                    if (!getDB().isSupportsInlineDistinct()) {
17480                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17481                    }
17482    
17483                    if (orderByComparator != null) {
17484                            if (getDB().isSupportsInlineDistinct()) {
17485                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17486                                            orderByComparator, true);
17487                            }
17488                            else {
17489                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17490                                            orderByComparator, true);
17491                            }
17492                    }
17493                    else {
17494                            if (getDB().isSupportsInlineDistinct()) {
17495                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17496                            }
17497                            else {
17498                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17499                            }
17500                    }
17501    
17502                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17503                                    BlogsEntry.class.getName(),
17504                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17505    
17506                    Session session = null;
17507    
17508                    try {
17509                            session = openSession();
17510    
17511                            SQLQuery q = session.createSQLQuery(sql);
17512    
17513                            if (getDB().isSupportsInlineDistinct()) {
17514                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17515                            }
17516                            else {
17517                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17518                            }
17519    
17520                            QueryPos qPos = QueryPos.getInstance(q);
17521    
17522                            qPos.add(groupId);
17523    
17524                            qPos.add(userId);
17525    
17526                            if (bindDisplayDate) {
17527                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17528                            }
17529    
17530                            qPos.add(status);
17531    
17532                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17533                    }
17534                    catch (Exception e) {
17535                            throw processException(e);
17536                    }
17537                    finally {
17538                            closeSession(session);
17539                    }
17540            }
17541    
17542            /**
17543             * 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;.
17544             *
17545             * @param entryId the primary key of the current blogs entry
17546             * @param groupId the group ID
17547             * @param userId the user ID
17548             * @param displayDate the display date
17549             * @param status the status
17550             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17551             * @return the previous, current, and next blogs entry
17552             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17553             * @throws SystemException if a system exception occurred
17554             */
17555            @Override
17556            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
17557                    long groupId, long userId, Date displayDate, int status,
17558                    OrderByComparator orderByComparator)
17559                    throws NoSuchEntryException, SystemException {
17560                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17561                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
17562                                    displayDate, status, orderByComparator);
17563                    }
17564    
17565                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17566    
17567                    Session session = null;
17568    
17569                    try {
17570                            session = openSession();
17571    
17572                            BlogsEntry[] array = new BlogsEntryImpl[3];
17573    
17574                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17575                                            groupId, userId, displayDate, status, orderByComparator,
17576                                            true);
17577    
17578                            array[1] = blogsEntry;
17579    
17580                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17581                                            groupId, userId, displayDate, status, orderByComparator,
17582                                            false);
17583    
17584                            return array;
17585                    }
17586                    catch (Exception e) {
17587                            throw processException(e);
17588                    }
17589                    finally {
17590                            closeSession(session);
17591                    }
17592            }
17593    
17594            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
17595                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17596                    int status, OrderByComparator orderByComparator, boolean previous) {
17597                    StringBundler query = null;
17598    
17599                    if (orderByComparator != null) {
17600                            query = new StringBundler(6 +
17601                                            (orderByComparator.getOrderByFields().length * 6));
17602                    }
17603                    else {
17604                            query = new StringBundler(3);
17605                    }
17606    
17607                    if (getDB().isSupportsInlineDistinct()) {
17608                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17609                    }
17610                    else {
17611                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17612                    }
17613    
17614                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17615    
17616                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17617    
17618                    boolean bindDisplayDate = false;
17619    
17620                    if (displayDate == null) {
17621                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17622                    }
17623                    else {
17624                            bindDisplayDate = true;
17625    
17626                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17627                    }
17628    
17629                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17630    
17631                    if (!getDB().isSupportsInlineDistinct()) {
17632                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17633                    }
17634    
17635                    if (orderByComparator != null) {
17636                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17637    
17638                            if (orderByConditionFields.length > 0) {
17639                                    query.append(WHERE_AND);
17640                            }
17641    
17642                            for (int i = 0; i < orderByConditionFields.length; i++) {
17643                                    if (getDB().isSupportsInlineDistinct()) {
17644                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17645                                    }
17646                                    else {
17647                                            query.append(_ORDER_BY_ENTITY_TABLE);
17648                                    }
17649    
17650                                    query.append(orderByConditionFields[i]);
17651    
17652                                    if ((i + 1) < orderByConditionFields.length) {
17653                                            if (orderByComparator.isAscending() ^ previous) {
17654                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17655                                            }
17656                                            else {
17657                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17658                                            }
17659                                    }
17660                                    else {
17661                                            if (orderByComparator.isAscending() ^ previous) {
17662                                                    query.append(WHERE_GREATER_THAN);
17663                                            }
17664                                            else {
17665                                                    query.append(WHERE_LESSER_THAN);
17666                                            }
17667                                    }
17668                            }
17669    
17670                            query.append(ORDER_BY_CLAUSE);
17671    
17672                            String[] orderByFields = orderByComparator.getOrderByFields();
17673    
17674                            for (int i = 0; i < orderByFields.length; i++) {
17675                                    if (getDB().isSupportsInlineDistinct()) {
17676                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17677                                    }
17678                                    else {
17679                                            query.append(_ORDER_BY_ENTITY_TABLE);
17680                                    }
17681    
17682                                    query.append(orderByFields[i]);
17683    
17684                                    if ((i + 1) < orderByFields.length) {
17685                                            if (orderByComparator.isAscending() ^ previous) {
17686                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17687                                            }
17688                                            else {
17689                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17690                                            }
17691                                    }
17692                                    else {
17693                                            if (orderByComparator.isAscending() ^ previous) {
17694                                                    query.append(ORDER_BY_ASC);
17695                                            }
17696                                            else {
17697                                                    query.append(ORDER_BY_DESC);
17698                                            }
17699                                    }
17700                            }
17701                    }
17702                    else {
17703                            if (getDB().isSupportsInlineDistinct()) {
17704                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17705                            }
17706                            else {
17707                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17708                            }
17709                    }
17710    
17711                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17712                                    BlogsEntry.class.getName(),
17713                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17714    
17715                    SQLQuery q = session.createSQLQuery(sql);
17716    
17717                    q.setFirstResult(0);
17718                    q.setMaxResults(2);
17719    
17720                    if (getDB().isSupportsInlineDistinct()) {
17721                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17722                    }
17723                    else {
17724                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17725                    }
17726    
17727                    QueryPos qPos = QueryPos.getInstance(q);
17728    
17729                    qPos.add(groupId);
17730    
17731                    qPos.add(userId);
17732    
17733                    if (bindDisplayDate) {
17734                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17735                    }
17736    
17737                    qPos.add(status);
17738    
17739                    if (orderByComparator != null) {
17740                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17741    
17742                            for (Object value : values) {
17743                                    qPos.add(value);
17744                            }
17745                    }
17746    
17747                    List<BlogsEntry> list = q.list();
17748    
17749                    if (list.size() == 2) {
17750                            return list.get(1);
17751                    }
17752                    else {
17753                            return null;
17754                    }
17755            }
17756    
17757            /**
17758             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
17759             *
17760             * @param groupId the group ID
17761             * @param userId the user ID
17762             * @param displayDate the display date
17763             * @param status the status
17764             * @throws SystemException if a system exception occurred
17765             */
17766            @Override
17767            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
17768                    int status) throws SystemException {
17769                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
17770                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17771                            remove(blogsEntry);
17772                    }
17773            }
17774    
17775            /**
17776             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17777             *
17778             * @param groupId the group ID
17779             * @param userId the user ID
17780             * @param displayDate the display date
17781             * @param status the status
17782             * @return the number of matching blogs entries
17783             * @throws SystemException if a system exception occurred
17784             */
17785            @Override
17786            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17787                    int status) throws SystemException {
17788                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
17789    
17790                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17791    
17792                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17793                                    this);
17794    
17795                    if (count == null) {
17796                            StringBundler query = new StringBundler(5);
17797    
17798                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17799    
17800                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17801    
17802                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17803    
17804                            boolean bindDisplayDate = false;
17805    
17806                            if (displayDate == null) {
17807                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17808                            }
17809                            else {
17810                                    bindDisplayDate = true;
17811    
17812                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17813                            }
17814    
17815                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17816    
17817                            String sql = query.toString();
17818    
17819                            Session session = null;
17820    
17821                            try {
17822                                    session = openSession();
17823    
17824                                    Query q = session.createQuery(sql);
17825    
17826                                    QueryPos qPos = QueryPos.getInstance(q);
17827    
17828                                    qPos.add(groupId);
17829    
17830                                    qPos.add(userId);
17831    
17832                                    if (bindDisplayDate) {
17833                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17834                                    }
17835    
17836                                    qPos.add(status);
17837    
17838                                    count = (Long)q.uniqueResult();
17839    
17840                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17841                            }
17842                            catch (Exception e) {
17843                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17844    
17845                                    throw processException(e);
17846                            }
17847                            finally {
17848                                    closeSession(session);
17849                            }
17850                    }
17851    
17852                    return count.intValue();
17853            }
17854    
17855            /**
17856             * 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;.
17857             *
17858             * @param groupId the group ID
17859             * @param userId the user ID
17860             * @param displayDate the display date
17861             * @param status the status
17862             * @return the number of matching blogs entries that the user has permission to view
17863             * @throws SystemException if a system exception occurred
17864             */
17865            @Override
17866            public int filterCountByG_U_LtD_S(long groupId, long userId,
17867                    Date displayDate, int status) throws SystemException {
17868                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17869                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17870                    }
17871    
17872                    StringBundler query = new StringBundler(5);
17873    
17874                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17875    
17876                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17877    
17878                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17879    
17880                    boolean bindDisplayDate = false;
17881    
17882                    if (displayDate == null) {
17883                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17884                    }
17885                    else {
17886                            bindDisplayDate = true;
17887    
17888                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17889                    }
17890    
17891                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17892    
17893                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17894                                    BlogsEntry.class.getName(),
17895                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17896    
17897                    Session session = null;
17898    
17899                    try {
17900                            session = openSession();
17901    
17902                            SQLQuery q = session.createSQLQuery(sql);
17903    
17904                            q.addScalar(COUNT_COLUMN_NAME,
17905                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17906    
17907                            QueryPos qPos = QueryPos.getInstance(q);
17908    
17909                            qPos.add(groupId);
17910    
17911                            qPos.add(userId);
17912    
17913                            if (bindDisplayDate) {
17914                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17915                            }
17916    
17917                            qPos.add(status);
17918    
17919                            Long count = (Long)q.uniqueResult();
17920    
17921                            return count.intValue();
17922                    }
17923                    catch (Exception e) {
17924                            throw processException(e);
17925                    }
17926                    finally {
17927                            closeSession(session);
17928                    }
17929            }
17930    
17931            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17932            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17933            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
17934            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17935            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17936    
17937            public BlogsEntryPersistenceImpl() {
17938                    setModelClass(BlogsEntry.class);
17939            }
17940    
17941            /**
17942             * Caches the blogs entry in the entity cache if it is enabled.
17943             *
17944             * @param blogsEntry the blogs entry
17945             */
17946            @Override
17947            public void cacheResult(BlogsEntry blogsEntry) {
17948                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17949                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
17950    
17951                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
17952                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
17953                            blogsEntry);
17954    
17955                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
17956                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
17957                            blogsEntry);
17958    
17959                    blogsEntry.resetOriginalValues();
17960            }
17961    
17962            /**
17963             * Caches the blogs entries in the entity cache if it is enabled.
17964             *
17965             * @param blogsEntries the blogs entries
17966             */
17967            @Override
17968            public void cacheResult(List<BlogsEntry> blogsEntries) {
17969                    for (BlogsEntry blogsEntry : blogsEntries) {
17970                            if (EntityCacheUtil.getResult(
17971                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17972                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
17973                                    cacheResult(blogsEntry);
17974                            }
17975                            else {
17976                                    blogsEntry.resetOriginalValues();
17977                            }
17978                    }
17979            }
17980    
17981            /**
17982             * Clears the cache for all blogs entries.
17983             *
17984             * <p>
17985             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17986             * </p>
17987             */
17988            @Override
17989            public void clearCache() {
17990                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
17991                            CacheRegistryUtil.clear(BlogsEntryImpl.class.getName());
17992                    }
17993    
17994                    EntityCacheUtil.clearCache(BlogsEntryImpl.class.getName());
17995    
17996                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
17997                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17998                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17999            }
18000    
18001            /**
18002             * Clears the cache for the blogs entry.
18003             *
18004             * <p>
18005             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
18006             * </p>
18007             */
18008            @Override
18009            public void clearCache(BlogsEntry blogsEntry) {
18010                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18011                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18012    
18013                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18014                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18015    
18016                    clearUniqueFindersCache(blogsEntry);
18017            }
18018    
18019            @Override
18020            public void clearCache(List<BlogsEntry> blogsEntries) {
18021                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18022                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18023    
18024                    for (BlogsEntry blogsEntry : blogsEntries) {
18025                            EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18026                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18027    
18028                            clearUniqueFindersCache(blogsEntry);
18029                    }
18030            }
18031    
18032            protected void cacheUniqueFindersCache(BlogsEntry blogsEntry) {
18033                    if (blogsEntry.isNew()) {
18034                            Object[] args = new Object[] {
18035                                            blogsEntry.getUuid(), blogsEntry.getGroupId()
18036                                    };
18037    
18038                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18039                                    Long.valueOf(1));
18040                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18041                                    blogsEntry);
18042    
18043                            args = new Object[] {
18044                                            blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
18045                                    };
18046    
18047                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18048                                    Long.valueOf(1));
18049                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18050                                    blogsEntry);
18051                    }
18052                    else {
18053                            BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18054    
18055                            if ((blogsEntryModelImpl.getColumnBitmask() &
18056                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18057                                    Object[] args = new Object[] {
18058                                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
18059                                            };
18060    
18061                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18062                                            Long.valueOf(1));
18063                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18064                                            blogsEntry);
18065                            }
18066    
18067                            if ((blogsEntryModelImpl.getColumnBitmask() &
18068                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18069                                    Object[] args = new Object[] {
18070                                                    blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
18071                                            };
18072    
18073                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18074                                            Long.valueOf(1));
18075                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18076                                            blogsEntry);
18077                            }
18078                    }
18079            }
18080    
18081            protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
18082                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18083    
18084                    Object[] args = new Object[] {
18085                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
18086                            };
18087    
18088                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18089                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18090    
18091                    if ((blogsEntryModelImpl.getColumnBitmask() &
18092                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18093                            args = new Object[] {
18094                                            blogsEntryModelImpl.getOriginalUuid(),
18095                                            blogsEntryModelImpl.getOriginalGroupId()
18096                                    };
18097    
18098                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18099                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18100                    }
18101    
18102                    args = new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() };
18103    
18104                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18105                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18106    
18107                    if ((blogsEntryModelImpl.getColumnBitmask() &
18108                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18109                            args = new Object[] {
18110                                            blogsEntryModelImpl.getOriginalGroupId(),
18111                                            blogsEntryModelImpl.getOriginalUrlTitle()
18112                                    };
18113    
18114                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18115                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18116                    }
18117            }
18118    
18119            /**
18120             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18121             *
18122             * @param entryId the primary key for the new blogs entry
18123             * @return the new blogs entry
18124             */
18125            @Override
18126            public BlogsEntry create(long entryId) {
18127                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18128    
18129                    blogsEntry.setNew(true);
18130                    blogsEntry.setPrimaryKey(entryId);
18131    
18132                    String uuid = PortalUUIDUtil.generate();
18133    
18134                    blogsEntry.setUuid(uuid);
18135    
18136                    return blogsEntry;
18137            }
18138    
18139            /**
18140             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18141             *
18142             * @param entryId the primary key of the blogs entry
18143             * @return the blogs entry that was removed
18144             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18145             * @throws SystemException if a system exception occurred
18146             */
18147            @Override
18148            public BlogsEntry remove(long entryId)
18149                    throws NoSuchEntryException, SystemException {
18150                    return remove((Serializable)entryId);
18151            }
18152    
18153            /**
18154             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18155             *
18156             * @param primaryKey the primary key of the blogs entry
18157             * @return the blogs entry that was removed
18158             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18159             * @throws SystemException if a system exception occurred
18160             */
18161            @Override
18162            public BlogsEntry remove(Serializable primaryKey)
18163                    throws NoSuchEntryException, SystemException {
18164                    Session session = null;
18165    
18166                    try {
18167                            session = openSession();
18168    
18169                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18170                                            primaryKey);
18171    
18172                            if (blogsEntry == null) {
18173                                    if (_log.isWarnEnabled()) {
18174                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18175                                    }
18176    
18177                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18178                                            primaryKey);
18179                            }
18180    
18181                            return remove(blogsEntry);
18182                    }
18183                    catch (NoSuchEntryException nsee) {
18184                            throw nsee;
18185                    }
18186                    catch (Exception e) {
18187                            throw processException(e);
18188                    }
18189                    finally {
18190                            closeSession(session);
18191                    }
18192            }
18193    
18194            @Override
18195            protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
18196                    throws SystemException {
18197                    blogsEntry = toUnwrappedModel(blogsEntry);
18198    
18199                    Session session = null;
18200    
18201                    try {
18202                            session = openSession();
18203    
18204                            if (!session.contains(blogsEntry)) {
18205                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18206                                                    blogsEntry.getPrimaryKeyObj());
18207                            }
18208    
18209                            if (blogsEntry != null) {
18210                                    session.delete(blogsEntry);
18211                            }
18212                    }
18213                    catch (Exception e) {
18214                            throw processException(e);
18215                    }
18216                    finally {
18217                            closeSession(session);
18218                    }
18219    
18220                    if (blogsEntry != null) {
18221                            clearCache(blogsEntry);
18222                    }
18223    
18224                    return blogsEntry;
18225            }
18226    
18227            @Override
18228            public BlogsEntry updateImpl(
18229                    com.liferay.portlet.blogs.model.BlogsEntry blogsEntry)
18230                    throws SystemException {
18231                    blogsEntry = toUnwrappedModel(blogsEntry);
18232    
18233                    boolean isNew = blogsEntry.isNew();
18234    
18235                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18236    
18237                    if (Validator.isNull(blogsEntry.getUuid())) {
18238                            String uuid = PortalUUIDUtil.generate();
18239    
18240                            blogsEntry.setUuid(uuid);
18241                    }
18242    
18243                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
18244    
18245                    if (userId > 0) {
18246                            long companyId = blogsEntry.getCompanyId();
18247    
18248                            long groupId = blogsEntry.getGroupId();
18249    
18250                            long entryId = 0;
18251    
18252                            if (!isNew) {
18253                                    entryId = blogsEntry.getPrimaryKey();
18254                            }
18255    
18256                            try {
18257                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
18258                                                    userId,
18259                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18260                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
18261                                                    blogsEntry.getTitle(), null));
18262    
18263                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
18264                                                    groupId, userId,
18265                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18266                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
18267                                                    blogsEntry.getContent(), null));
18268                            }
18269                            catch (SanitizerException se) {
18270                                    throw new SystemException(se);
18271                            }
18272                    }
18273    
18274                    Session session = null;
18275    
18276                    try {
18277                            session = openSession();
18278    
18279                            if (blogsEntry.isNew()) {
18280                                    session.save(blogsEntry);
18281    
18282                                    blogsEntry.setNew(false);
18283                            }
18284                            else {
18285                                    session.merge(blogsEntry);
18286                            }
18287                    }
18288                    catch (Exception e) {
18289                            throw processException(e);
18290                    }
18291                    finally {
18292                            closeSession(session);
18293                    }
18294    
18295                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18296    
18297                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
18298                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18299                    }
18300    
18301                    else {
18302                            if ((blogsEntryModelImpl.getColumnBitmask() &
18303                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
18304                                    Object[] args = new Object[] {
18305                                                    blogsEntryModelImpl.getOriginalUuid()
18306                                            };
18307    
18308                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18309                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18310                                            args);
18311    
18312                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
18313    
18314                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18315                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18316                                            args);
18317                            }
18318    
18319                            if ((blogsEntryModelImpl.getColumnBitmask() &
18320                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
18321                                    Object[] args = new Object[] {
18322                                                    blogsEntryModelImpl.getOriginalUuid(),
18323                                                    blogsEntryModelImpl.getOriginalCompanyId()
18324                                            };
18325    
18326                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18327                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18328                                            args);
18329    
18330                                    args = new Object[] {
18331                                                    blogsEntryModelImpl.getUuid(),
18332                                                    blogsEntryModelImpl.getCompanyId()
18333                                            };
18334    
18335                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18336                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18337                                            args);
18338                            }
18339    
18340                            if ((blogsEntryModelImpl.getColumnBitmask() &
18341                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
18342                                    Object[] args = new Object[] {
18343                                                    blogsEntryModelImpl.getOriginalGroupId()
18344                                            };
18345    
18346                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18347                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18348                                            args);
18349    
18350                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
18351    
18352                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18353                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18354                                            args);
18355                            }
18356    
18357                            if ((blogsEntryModelImpl.getColumnBitmask() &
18358                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
18359                                    Object[] args = new Object[] {
18360                                                    blogsEntryModelImpl.getOriginalCompanyId()
18361                                            };
18362    
18363                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
18364                                            args);
18365                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18366                                            args);
18367    
18368                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
18369    
18370                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
18371                                            args);
18372                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18373                                            args);
18374                            }
18375    
18376                            if ((blogsEntryModelImpl.getColumnBitmask() &
18377                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
18378                                    Object[] args = new Object[] {
18379                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18380                                                    blogsEntryModelImpl.getOriginalUserId()
18381                                            };
18382    
18383                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18384                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18385                                            args);
18386    
18387                                    args = new Object[] {
18388                                                    blogsEntryModelImpl.getCompanyId(),
18389                                                    blogsEntryModelImpl.getUserId()
18390                                            };
18391    
18392                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18393                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18394                                            args);
18395                            }
18396    
18397                            if ((blogsEntryModelImpl.getColumnBitmask() &
18398                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18399                                    Object[] args = new Object[] {
18400                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18401                                                    blogsEntryModelImpl.getOriginalStatus()
18402                                            };
18403    
18404                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18405                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18406                                            args);
18407    
18408                                    args = new Object[] {
18409                                                    blogsEntryModelImpl.getCompanyId(),
18410                                                    blogsEntryModelImpl.getStatus()
18411                                            };
18412    
18413                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18414                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18415                                            args);
18416                            }
18417    
18418                            if ((blogsEntryModelImpl.getColumnBitmask() &
18419                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18420                                    Object[] args = new Object[] {
18421                                                    blogsEntryModelImpl.getOriginalGroupId(),
18422                                                    blogsEntryModelImpl.getOriginalStatus()
18423                                            };
18424    
18425                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18426                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18427                                            args);
18428    
18429                                    args = new Object[] {
18430                                                    blogsEntryModelImpl.getGroupId(),
18431                                                    blogsEntryModelImpl.getStatus()
18432                                            };
18433    
18434                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18435                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18436                                            args);
18437                            }
18438    
18439                            if ((blogsEntryModelImpl.getColumnBitmask() &
18440                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18441                                    Object[] args = new Object[] {
18442                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18443                                                    blogsEntryModelImpl.getOriginalUserId(),
18444                                                    blogsEntryModelImpl.getOriginalStatus()
18445                                            };
18446    
18447                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18448                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18449                                            args);
18450    
18451                                    args = new Object[] {
18452                                                    blogsEntryModelImpl.getCompanyId(),
18453                                                    blogsEntryModelImpl.getUserId(),
18454                                                    blogsEntryModelImpl.getStatus()
18455                                            };
18456    
18457                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18458                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18459                                            args);
18460                            }
18461    
18462                            if ((blogsEntryModelImpl.getColumnBitmask() &
18463                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18464                                    Object[] args = new Object[] {
18465                                                    blogsEntryModelImpl.getOriginalGroupId(),
18466                                                    blogsEntryModelImpl.getOriginalUserId(),
18467                                                    blogsEntryModelImpl.getOriginalStatus()
18468                                            };
18469    
18470                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18471                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18472                                            args);
18473    
18474                                    args = new Object[] {
18475                                                    blogsEntryModelImpl.getGroupId(),
18476                                                    blogsEntryModelImpl.getUserId(),
18477                                                    blogsEntryModelImpl.getStatus()
18478                                            };
18479    
18480                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18481                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18482                                            args);
18483                            }
18484                    }
18485    
18486                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18487                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18488    
18489                    clearUniqueFindersCache(blogsEntry);
18490                    cacheUniqueFindersCache(blogsEntry);
18491    
18492                    return blogsEntry;
18493            }
18494    
18495            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18496                    if (blogsEntry instanceof BlogsEntryImpl) {
18497                            return blogsEntry;
18498                    }
18499    
18500                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18501    
18502                    blogsEntryImpl.setNew(blogsEntry.isNew());
18503                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18504    
18505                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
18506                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18507                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18508                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18509                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
18510                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
18511                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18512                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18513                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
18514                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18515                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
18516                    blogsEntryImpl.setContent(blogsEntry.getContent());
18517                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18518                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18519                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18520                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18521                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18522                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18523                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18524                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
18525                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18526                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18527                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18528    
18529                    return blogsEntryImpl;
18530            }
18531    
18532            /**
18533             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
18534             *
18535             * @param primaryKey the primary key of the blogs entry
18536             * @return the blogs entry
18537             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18538             * @throws SystemException if a system exception occurred
18539             */
18540            @Override
18541            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18542                    throws NoSuchEntryException, SystemException {
18543                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18544    
18545                    if (blogsEntry == null) {
18546                            if (_log.isWarnEnabled()) {
18547                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18548                            }
18549    
18550                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18551                                    primaryKey);
18552                    }
18553    
18554                    return blogsEntry;
18555            }
18556    
18557            /**
18558             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
18559             *
18560             * @param entryId the primary key of the blogs entry
18561             * @return the blogs entry
18562             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18563             * @throws SystemException if a system exception occurred
18564             */
18565            @Override
18566            public BlogsEntry findByPrimaryKey(long entryId)
18567                    throws NoSuchEntryException, SystemException {
18568                    return findByPrimaryKey((Serializable)entryId);
18569            }
18570    
18571            /**
18572             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18573             *
18574             * @param primaryKey the primary key of the blogs entry
18575             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18576             * @throws SystemException if a system exception occurred
18577             */
18578            @Override
18579            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey)
18580                    throws SystemException {
18581                    BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18582                                    BlogsEntryImpl.class, primaryKey);
18583    
18584                    if (blogsEntry == _nullBlogsEntry) {
18585                            return null;
18586                    }
18587    
18588                    if (blogsEntry == null) {
18589                            Session session = null;
18590    
18591                            try {
18592                                    session = openSession();
18593    
18594                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18595                                                    primaryKey);
18596    
18597                                    if (blogsEntry != null) {
18598                                            cacheResult(blogsEntry);
18599                                    }
18600                                    else {
18601                                            EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18602                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18603                                    }
18604                            }
18605                            catch (Exception e) {
18606                                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18607                                            BlogsEntryImpl.class, primaryKey);
18608    
18609                                    throw processException(e);
18610                            }
18611                            finally {
18612                                    closeSession(session);
18613                            }
18614                    }
18615    
18616                    return blogsEntry;
18617            }
18618    
18619            /**
18620             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18621             *
18622             * @param entryId the primary key of the blogs entry
18623             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18624             * @throws SystemException if a system exception occurred
18625             */
18626            @Override
18627            public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
18628                    return fetchByPrimaryKey((Serializable)entryId);
18629            }
18630    
18631            /**
18632             * Returns all the blogs entries.
18633             *
18634             * @return the blogs entries
18635             * @throws SystemException if a system exception occurred
18636             */
18637            @Override
18638            public List<BlogsEntry> findAll() throws SystemException {
18639                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18640            }
18641    
18642            /**
18643             * Returns a range of all the blogs entries.
18644             *
18645             * <p>
18646             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
18647             * </p>
18648             *
18649             * @param start the lower bound of the range of blogs entries
18650             * @param end the upper bound of the range of blogs entries (not inclusive)
18651             * @return the range of blogs entries
18652             * @throws SystemException if a system exception occurred
18653             */
18654            @Override
18655            public List<BlogsEntry> findAll(int start, int end)
18656                    throws SystemException {
18657                    return findAll(start, end, null);
18658            }
18659    
18660            /**
18661             * Returns an ordered range of all the blogs entries.
18662             *
18663             * <p>
18664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
18665             * </p>
18666             *
18667             * @param start the lower bound of the range of blogs entries
18668             * @param end the upper bound of the range of blogs entries (not inclusive)
18669             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18670             * @return the ordered range of blogs entries
18671             * @throws SystemException if a system exception occurred
18672             */
18673            @Override
18674            public List<BlogsEntry> findAll(int start, int end,
18675                    OrderByComparator orderByComparator) throws SystemException {
18676                    boolean pagination = true;
18677                    FinderPath finderPath = null;
18678                    Object[] finderArgs = null;
18679    
18680                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18681                                    (orderByComparator == null)) {
18682                            pagination = false;
18683                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
18684                            finderArgs = FINDER_ARGS_EMPTY;
18685                    }
18686                    else {
18687                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
18688                            finderArgs = new Object[] { start, end, orderByComparator };
18689                    }
18690    
18691                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
18692                                    finderArgs, this);
18693    
18694                    if (list == null) {
18695                            StringBundler query = null;
18696                            String sql = null;
18697    
18698                            if (orderByComparator != null) {
18699                                    query = new StringBundler(2 +
18700                                                    (orderByComparator.getOrderByFields().length * 3));
18701    
18702                                    query.append(_SQL_SELECT_BLOGSENTRY);
18703    
18704                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18705                                            orderByComparator);
18706    
18707                                    sql = query.toString();
18708                            }
18709                            else {
18710                                    sql = _SQL_SELECT_BLOGSENTRY;
18711    
18712                                    if (pagination) {
18713                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
18714                                    }
18715                            }
18716    
18717                            Session session = null;
18718    
18719                            try {
18720                                    session = openSession();
18721    
18722                                    Query q = session.createQuery(sql);
18723    
18724                                    if (!pagination) {
18725                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18726                                                            start, end, false);
18727    
18728                                            Collections.sort(list);
18729    
18730                                            list = new UnmodifiableList<BlogsEntry>(list);
18731                                    }
18732                                    else {
18733                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18734                                                            start, end);
18735                                    }
18736    
18737                                    cacheResult(list);
18738    
18739                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18740                            }
18741                            catch (Exception e) {
18742                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18743    
18744                                    throw processException(e);
18745                            }
18746                            finally {
18747                                    closeSession(session);
18748                            }
18749                    }
18750    
18751                    return list;
18752            }
18753    
18754            /**
18755             * Removes all the blogs entries from the database.
18756             *
18757             * @throws SystemException if a system exception occurred
18758             */
18759            @Override
18760            public void removeAll() throws SystemException {
18761                    for (BlogsEntry blogsEntry : findAll()) {
18762                            remove(blogsEntry);
18763                    }
18764            }
18765    
18766            /**
18767             * Returns the number of blogs entries.
18768             *
18769             * @return the number of blogs entries
18770             * @throws SystemException if a system exception occurred
18771             */
18772            @Override
18773            public int countAll() throws SystemException {
18774                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18775                                    FINDER_ARGS_EMPTY, this);
18776    
18777                    if (count == null) {
18778                            Session session = null;
18779    
18780                            try {
18781                                    session = openSession();
18782    
18783                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
18784    
18785                                    count = (Long)q.uniqueResult();
18786    
18787                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18788                                            FINDER_ARGS_EMPTY, count);
18789                            }
18790                            catch (Exception e) {
18791                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
18792                                            FINDER_ARGS_EMPTY);
18793    
18794                                    throw processException(e);
18795                            }
18796                            finally {
18797                                    closeSession(session);
18798                            }
18799                    }
18800    
18801                    return count.intValue();
18802            }
18803    
18804            @Override
18805            protected Set<String> getBadColumnNames() {
18806                    return _badColumnNames;
18807            }
18808    
18809            /**
18810             * Initializes the blogs entry persistence.
18811             */
18812            public void afterPropertiesSet() {
18813                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
18814                                            com.liferay.portal.util.PropsUtil.get(
18815                                                    "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
18816    
18817                    if (listenerClassNames.length > 0) {
18818                            try {
18819                                    List<ModelListener<BlogsEntry>> listenersList = new ArrayList<ModelListener<BlogsEntry>>();
18820    
18821                                    for (String listenerClassName : listenerClassNames) {
18822                                            listenersList.add((ModelListener<BlogsEntry>)InstanceFactory.newInstance(
18823                                                            getClassLoader(), listenerClassName));
18824                                    }
18825    
18826                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
18827                            }
18828                            catch (Exception e) {
18829                                    _log.error(e);
18830                            }
18831                    }
18832            }
18833    
18834            public void destroy() {
18835                    EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
18836                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18837                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18838                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18839            }
18840    
18841            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
18842            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
18843            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
18844            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
18845            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
18846            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
18847            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
18848                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
18849            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
18850                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
18851            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
18852            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
18853            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
18854            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
18855            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
18856            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
18857            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
18858            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18859            private static Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
18860            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
18861                                    "uuid"
18862                            });
18863            private static BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
18864                            @Override
18865                            public Object clone() {
18866                                    return this;
18867                            }
18868    
18869                            @Override
18870                            public CacheModel<BlogsEntry> toCacheModel() {
18871                                    return _nullBlogsEntryCacheModel;
18872                            }
18873                    };
18874    
18875            private static CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
18876                            @Override
18877                            public BlogsEntry toEntityModel() {
18878                                    return _nullBlogsEntry;
18879                            }
18880                    };
18881    }