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                                                    !Validator.equals(displayDate,
3425                                                            blogsEntry.getDisplayDate())) {
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                                                    !Validator.equals(displayDate,
5278                                                            blogsEntry.getDisplayDate())) {
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 (!Validator.equals(displayDate, blogsEntry.getDisplayDate()) ||
8042                                                    (status != blogsEntry.getStatus())) {
8043                                            list = null;
8044    
8045                                            break;
8046                                    }
8047                            }
8048                    }
8049    
8050                    if (list == null) {
8051                            StringBundler query = null;
8052    
8053                            if (orderByComparator != null) {
8054                                    query = new StringBundler(4 +
8055                                                    (orderByComparator.getOrderByFields().length * 3));
8056                            }
8057                            else {
8058                                    query = new StringBundler(4);
8059                            }
8060    
8061                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8062    
8063                            boolean bindDisplayDate = false;
8064    
8065                            if (displayDate == null) {
8066                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8067                            }
8068                            else {
8069                                    bindDisplayDate = true;
8070    
8071                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8072                            }
8073    
8074                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8075    
8076                            if (orderByComparator != null) {
8077                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8078                                            orderByComparator);
8079                            }
8080                            else
8081                             if (pagination) {
8082                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8083                            }
8084    
8085                            String sql = query.toString();
8086    
8087                            Session session = null;
8088    
8089                            try {
8090                                    session = openSession();
8091    
8092                                    Query q = session.createQuery(sql);
8093    
8094                                    QueryPos qPos = QueryPos.getInstance(q);
8095    
8096                                    if (bindDisplayDate) {
8097                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8098                                    }
8099    
8100                                    qPos.add(status);
8101    
8102                                    if (!pagination) {
8103                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8104                                                            start, end, false);
8105    
8106                                            Collections.sort(list);
8107    
8108                                            list = new UnmodifiableList<BlogsEntry>(list);
8109                                    }
8110                                    else {
8111                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8112                                                            start, end);
8113                                    }
8114    
8115                                    cacheResult(list);
8116    
8117                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8118                            }
8119                            catch (Exception e) {
8120                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8121    
8122                                    throw processException(e);
8123                            }
8124                            finally {
8125                                    closeSession(session);
8126                            }
8127                    }
8128    
8129                    return list;
8130            }
8131    
8132            /**
8133             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8134             *
8135             * @param displayDate the display date
8136             * @param status the status
8137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8138             * @return the first matching blogs entry
8139             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8140             * @throws SystemException if a system exception occurred
8141             */
8142            @Override
8143            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8144                    OrderByComparator orderByComparator)
8145                    throws NoSuchEntryException, SystemException {
8146                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8147                                    orderByComparator);
8148    
8149                    if (blogsEntry != null) {
8150                            return blogsEntry;
8151                    }
8152    
8153                    StringBundler msg = new StringBundler(6);
8154    
8155                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8156    
8157                    msg.append("displayDate=");
8158                    msg.append(displayDate);
8159    
8160                    msg.append(", status=");
8161                    msg.append(status);
8162    
8163                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8164    
8165                    throw new NoSuchEntryException(msg.toString());
8166            }
8167    
8168            /**
8169             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8170             *
8171             * @param displayDate the display date
8172             * @param status the status
8173             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8174             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8175             * @throws SystemException if a system exception occurred
8176             */
8177            @Override
8178            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8179                    OrderByComparator orderByComparator) throws SystemException {
8180                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8181                                    orderByComparator);
8182    
8183                    if (!list.isEmpty()) {
8184                            return list.get(0);
8185                    }
8186    
8187                    return null;
8188            }
8189    
8190            /**
8191             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8192             *
8193             * @param displayDate the display date
8194             * @param status the status
8195             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8196             * @return the last matching blogs entry
8197             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8198             * @throws SystemException if a system exception occurred
8199             */
8200            @Override
8201            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8202                    OrderByComparator orderByComparator)
8203                    throws NoSuchEntryException, SystemException {
8204                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8205                                    orderByComparator);
8206    
8207                    if (blogsEntry != null) {
8208                            return blogsEntry;
8209                    }
8210    
8211                    StringBundler msg = new StringBundler(6);
8212    
8213                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8214    
8215                    msg.append("displayDate=");
8216                    msg.append(displayDate);
8217    
8218                    msg.append(", status=");
8219                    msg.append(status);
8220    
8221                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8222    
8223                    throw new NoSuchEntryException(msg.toString());
8224            }
8225    
8226            /**
8227             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8228             *
8229             * @param displayDate the display date
8230             * @param status the status
8231             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8232             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8233             * @throws SystemException if a system exception occurred
8234             */
8235            @Override
8236            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8237                    OrderByComparator orderByComparator) throws SystemException {
8238                    int count = countByLtD_S(displayDate, status);
8239    
8240                    if (count == 0) {
8241                            return null;
8242                    }
8243    
8244                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8245                                    count, orderByComparator);
8246    
8247                    if (!list.isEmpty()) {
8248                            return list.get(0);
8249                    }
8250    
8251                    return null;
8252            }
8253    
8254            /**
8255             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8256             *
8257             * @param entryId the primary key of the current blogs entry
8258             * @param displayDate the display date
8259             * @param status the status
8260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8261             * @return the previous, current, and next blogs entry
8262             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8263             * @throws SystemException if a system exception occurred
8264             */
8265            @Override
8266            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8267                    int status, OrderByComparator orderByComparator)
8268                    throws NoSuchEntryException, SystemException {
8269                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8270    
8271                    Session session = null;
8272    
8273                    try {
8274                            session = openSession();
8275    
8276                            BlogsEntry[] array = new BlogsEntryImpl[3];
8277    
8278                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8279                                            status, orderByComparator, true);
8280    
8281                            array[1] = blogsEntry;
8282    
8283                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8284                                            status, orderByComparator, false);
8285    
8286                            return array;
8287                    }
8288                    catch (Exception e) {
8289                            throw processException(e);
8290                    }
8291                    finally {
8292                            closeSession(session);
8293                    }
8294            }
8295    
8296            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8297                    BlogsEntry blogsEntry, Date displayDate, int status,
8298                    OrderByComparator orderByComparator, boolean previous) {
8299                    StringBundler query = null;
8300    
8301                    if (orderByComparator != null) {
8302                            query = new StringBundler(6 +
8303                                            (orderByComparator.getOrderByFields().length * 6));
8304                    }
8305                    else {
8306                            query = new StringBundler(3);
8307                    }
8308    
8309                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8310    
8311                    boolean bindDisplayDate = false;
8312    
8313                    if (displayDate == null) {
8314                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8315                    }
8316                    else {
8317                            bindDisplayDate = true;
8318    
8319                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8320                    }
8321    
8322                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8323    
8324                    if (orderByComparator != null) {
8325                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8326    
8327                            if (orderByConditionFields.length > 0) {
8328                                    query.append(WHERE_AND);
8329                            }
8330    
8331                            for (int i = 0; i < orderByConditionFields.length; i++) {
8332                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8333                                    query.append(orderByConditionFields[i]);
8334    
8335                                    if ((i + 1) < orderByConditionFields.length) {
8336                                            if (orderByComparator.isAscending() ^ previous) {
8337                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8338                                            }
8339                                            else {
8340                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8341                                            }
8342                                    }
8343                                    else {
8344                                            if (orderByComparator.isAscending() ^ previous) {
8345                                                    query.append(WHERE_GREATER_THAN);
8346                                            }
8347                                            else {
8348                                                    query.append(WHERE_LESSER_THAN);
8349                                            }
8350                                    }
8351                            }
8352    
8353                            query.append(ORDER_BY_CLAUSE);
8354    
8355                            String[] orderByFields = orderByComparator.getOrderByFields();
8356    
8357                            for (int i = 0; i < orderByFields.length; i++) {
8358                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8359                                    query.append(orderByFields[i]);
8360    
8361                                    if ((i + 1) < orderByFields.length) {
8362                                            if (orderByComparator.isAscending() ^ previous) {
8363                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8364                                            }
8365                                            else {
8366                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8367                                            }
8368                                    }
8369                                    else {
8370                                            if (orderByComparator.isAscending() ^ previous) {
8371                                                    query.append(ORDER_BY_ASC);
8372                                            }
8373                                            else {
8374                                                    query.append(ORDER_BY_DESC);
8375                                            }
8376                                    }
8377                            }
8378                    }
8379                    else {
8380                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8381                    }
8382    
8383                    String sql = query.toString();
8384    
8385                    Query q = session.createQuery(sql);
8386    
8387                    q.setFirstResult(0);
8388                    q.setMaxResults(2);
8389    
8390                    QueryPos qPos = QueryPos.getInstance(q);
8391    
8392                    if (bindDisplayDate) {
8393                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8394                    }
8395    
8396                    qPos.add(status);
8397    
8398                    if (orderByComparator != null) {
8399                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8400    
8401                            for (Object value : values) {
8402                                    qPos.add(value);
8403                            }
8404                    }
8405    
8406                    List<BlogsEntry> list = q.list();
8407    
8408                    if (list.size() == 2) {
8409                            return list.get(1);
8410                    }
8411                    else {
8412                            return null;
8413                    }
8414            }
8415    
8416            /**
8417             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8418             *
8419             * @param displayDate the display date
8420             * @param status the status
8421             * @throws SystemException if a system exception occurred
8422             */
8423            @Override
8424            public void removeByLtD_S(Date displayDate, int status)
8425                    throws SystemException {
8426                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8427                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8428                            remove(blogsEntry);
8429                    }
8430            }
8431    
8432            /**
8433             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8434             *
8435             * @param displayDate the display date
8436             * @param status the status
8437             * @return the number of matching blogs entries
8438             * @throws SystemException if a system exception occurred
8439             */
8440            @Override
8441            public int countByLtD_S(Date displayDate, int status)
8442                    throws SystemException {
8443                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8444    
8445                    Object[] finderArgs = new Object[] { displayDate, status };
8446    
8447                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8448                                    this);
8449    
8450                    if (count == null) {
8451                            StringBundler query = new StringBundler(3);
8452    
8453                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8454    
8455                            boolean bindDisplayDate = false;
8456    
8457                            if (displayDate == null) {
8458                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8459                            }
8460                            else {
8461                                    bindDisplayDate = true;
8462    
8463                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8464                            }
8465    
8466                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8467    
8468                            String sql = query.toString();
8469    
8470                            Session session = null;
8471    
8472                            try {
8473                                    session = openSession();
8474    
8475                                    Query q = session.createQuery(sql);
8476    
8477                                    QueryPos qPos = QueryPos.getInstance(q);
8478    
8479                                    if (bindDisplayDate) {
8480                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
8481                                    }
8482    
8483                                    qPos.add(status);
8484    
8485                                    count = (Long)q.uniqueResult();
8486    
8487                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8488                            }
8489                            catch (Exception e) {
8490                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8491    
8492                                    throw processException(e);
8493                            }
8494                            finally {
8495                                    closeSession(session);
8496                            }
8497                    }
8498    
8499                    return count.intValue();
8500            }
8501    
8502            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
8503            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8504            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8505            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8506                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8507                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
8508                            new String[] {
8509                                    Long.class.getName(), Long.class.getName(),
8510                                    Integer.class.getName(),
8511                                    
8512                            Integer.class.getName(), Integer.class.getName(),
8513                                    OrderByComparator.class.getName()
8514                            });
8515            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
8516                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8517                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8518                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
8519                            new String[] {
8520                                    Long.class.getName(), Long.class.getName(),
8521                                    Integer.class.getName()
8522                            });
8523    
8524            /**
8525             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8526             *
8527             * @param companyId the company ID
8528             * @param userId the user ID
8529             * @param status the status
8530             * @return the matching blogs entries
8531             * @throws SystemException if a system exception occurred
8532             */
8533            @Override
8534            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8535                    int status) throws SystemException {
8536                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
8537                            QueryUtil.ALL_POS, null);
8538            }
8539    
8540            /**
8541             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8542             *
8543             * <p>
8544             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8545             * </p>
8546             *
8547             * @param companyId the company ID
8548             * @param userId the user ID
8549             * @param status the status
8550             * @param start the lower bound of the range of blogs entries
8551             * @param end the upper bound of the range of blogs entries (not inclusive)
8552             * @return the range of matching blogs entries
8553             * @throws SystemException if a system exception occurred
8554             */
8555            @Override
8556            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8557                    int status, int start, int end) throws SystemException {
8558                    return findByC_U_NotS(companyId, userId, status, start, end, null);
8559            }
8560    
8561            /**
8562             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8563             *
8564             * <p>
8565             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8566             * </p>
8567             *
8568             * @param companyId the company ID
8569             * @param userId the user ID
8570             * @param status the status
8571             * @param start the lower bound of the range of blogs entries
8572             * @param end the upper bound of the range of blogs entries (not inclusive)
8573             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8574             * @return the ordered range of matching blogs entries
8575             * @throws SystemException if a system exception occurred
8576             */
8577            @Override
8578            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
8579                    int status, int start, int end, OrderByComparator orderByComparator)
8580                    throws SystemException {
8581                    boolean pagination = true;
8582                    FinderPath finderPath = null;
8583                    Object[] finderArgs = null;
8584    
8585                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
8586                    finderArgs = new Object[] {
8587                                    companyId, userId, status,
8588                                    
8589                                    start, end, orderByComparator
8590                            };
8591    
8592                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8593                                    finderArgs, this);
8594    
8595                    if ((list != null) && !list.isEmpty()) {
8596                            for (BlogsEntry blogsEntry : list) {
8597                                    if ((companyId != blogsEntry.getCompanyId()) ||
8598                                                    (userId != blogsEntry.getUserId()) ||
8599                                                    (status != blogsEntry.getStatus())) {
8600                                            list = null;
8601    
8602                                            break;
8603                                    }
8604                            }
8605                    }
8606    
8607                    if (list == null) {
8608                            StringBundler query = null;
8609    
8610                            if (orderByComparator != null) {
8611                                    query = new StringBundler(5 +
8612                                                    (orderByComparator.getOrderByFields().length * 3));
8613                            }
8614                            else {
8615                                    query = new StringBundler(5);
8616                            }
8617    
8618                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8619    
8620                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8621    
8622                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8623    
8624                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8625    
8626                            if (orderByComparator != null) {
8627                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8628                                            orderByComparator);
8629                            }
8630                            else
8631                             if (pagination) {
8632                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8633                            }
8634    
8635                            String sql = query.toString();
8636    
8637                            Session session = null;
8638    
8639                            try {
8640                                    session = openSession();
8641    
8642                                    Query q = session.createQuery(sql);
8643    
8644                                    QueryPos qPos = QueryPos.getInstance(q);
8645    
8646                                    qPos.add(companyId);
8647    
8648                                    qPos.add(userId);
8649    
8650                                    qPos.add(status);
8651    
8652                                    if (!pagination) {
8653                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8654                                                            start, end, false);
8655    
8656                                            Collections.sort(list);
8657    
8658                                            list = new UnmodifiableList<BlogsEntry>(list);
8659                                    }
8660                                    else {
8661                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8662                                                            start, end);
8663                                    }
8664    
8665                                    cacheResult(list);
8666    
8667                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8668                            }
8669                            catch (Exception e) {
8670                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8671    
8672                                    throw processException(e);
8673                            }
8674                            finally {
8675                                    closeSession(session);
8676                            }
8677                    }
8678    
8679                    return list;
8680            }
8681    
8682            /**
8683             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8684             *
8685             * @param companyId the company ID
8686             * @param userId the user ID
8687             * @param status the status
8688             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8689             * @return the first matching blogs entry
8690             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8691             * @throws SystemException if a system exception occurred
8692             */
8693            @Override
8694            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
8695                    int status, OrderByComparator orderByComparator)
8696                    throws NoSuchEntryException, SystemException {
8697                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
8698                                    status, orderByComparator);
8699    
8700                    if (blogsEntry != null) {
8701                            return blogsEntry;
8702                    }
8703    
8704                    StringBundler msg = new StringBundler(8);
8705    
8706                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8707    
8708                    msg.append("companyId=");
8709                    msg.append(companyId);
8710    
8711                    msg.append(", userId=");
8712                    msg.append(userId);
8713    
8714                    msg.append(", status=");
8715                    msg.append(status);
8716    
8717                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8718    
8719                    throw new NoSuchEntryException(msg.toString());
8720            }
8721    
8722            /**
8723             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8724             *
8725             * @param companyId the company ID
8726             * @param userId the user ID
8727             * @param status the status
8728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8729             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8730             * @throws SystemException if a system exception occurred
8731             */
8732            @Override
8733            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
8734                    int status, OrderByComparator orderByComparator)
8735                    throws SystemException {
8736                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
8737                                    orderByComparator);
8738    
8739                    if (!list.isEmpty()) {
8740                            return list.get(0);
8741                    }
8742    
8743                    return null;
8744            }
8745    
8746            /**
8747             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8748             *
8749             * @param companyId the company ID
8750             * @param userId the user ID
8751             * @param status the status
8752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8753             * @return the last matching blogs entry
8754             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8755             * @throws SystemException if a system exception occurred
8756             */
8757            @Override
8758            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
8759                    int status, OrderByComparator orderByComparator)
8760                    throws NoSuchEntryException, SystemException {
8761                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
8762                                    orderByComparator);
8763    
8764                    if (blogsEntry != null) {
8765                            return blogsEntry;
8766                    }
8767    
8768                    StringBundler msg = new StringBundler(8);
8769    
8770                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8771    
8772                    msg.append("companyId=");
8773                    msg.append(companyId);
8774    
8775                    msg.append(", userId=");
8776                    msg.append(userId);
8777    
8778                    msg.append(", status=");
8779                    msg.append(status);
8780    
8781                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8782    
8783                    throw new NoSuchEntryException(msg.toString());
8784            }
8785    
8786            /**
8787             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8788             *
8789             * @param companyId the company ID
8790             * @param userId the user ID
8791             * @param status the status
8792             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8793             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8794             * @throws SystemException if a system exception occurred
8795             */
8796            @Override
8797            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
8798                    int status, OrderByComparator orderByComparator)
8799                    throws SystemException {
8800                    int count = countByC_U_NotS(companyId, userId, status);
8801    
8802                    if (count == 0) {
8803                            return null;
8804                    }
8805    
8806                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
8807                                    count - 1, count, orderByComparator);
8808    
8809                    if (!list.isEmpty()) {
8810                            return list.get(0);
8811                    }
8812    
8813                    return null;
8814            }
8815    
8816            /**
8817             * 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;.
8818             *
8819             * @param entryId the primary key of the current blogs entry
8820             * @param companyId the company ID
8821             * @param userId the user ID
8822             * @param status the status
8823             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8824             * @return the previous, current, and next blogs entry
8825             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8826             * @throws SystemException if a system exception occurred
8827             */
8828            @Override
8829            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
8830                    long companyId, long userId, int status,
8831                    OrderByComparator orderByComparator)
8832                    throws NoSuchEntryException, SystemException {
8833                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8834    
8835                    Session session = null;
8836    
8837                    try {
8838                            session = openSession();
8839    
8840                            BlogsEntry[] array = new BlogsEntryImpl[3];
8841    
8842                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8843                                            companyId, userId, status, orderByComparator, true);
8844    
8845                            array[1] = blogsEntry;
8846    
8847                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
8848                                            companyId, userId, status, orderByComparator, false);
8849    
8850                            return array;
8851                    }
8852                    catch (Exception e) {
8853                            throw processException(e);
8854                    }
8855                    finally {
8856                            closeSession(session);
8857                    }
8858            }
8859    
8860            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
8861                    BlogsEntry blogsEntry, long companyId, long userId, int status,
8862                    OrderByComparator orderByComparator, boolean previous) {
8863                    StringBundler query = null;
8864    
8865                    if (orderByComparator != null) {
8866                            query = new StringBundler(6 +
8867                                            (orderByComparator.getOrderByFields().length * 6));
8868                    }
8869                    else {
8870                            query = new StringBundler(3);
8871                    }
8872    
8873                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8874    
8875                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
8876    
8877                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
8878    
8879                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
8880    
8881                    if (orderByComparator != null) {
8882                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8883    
8884                            if (orderByConditionFields.length > 0) {
8885                                    query.append(WHERE_AND);
8886                            }
8887    
8888                            for (int i = 0; i < orderByConditionFields.length; i++) {
8889                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8890                                    query.append(orderByConditionFields[i]);
8891    
8892                                    if ((i + 1) < orderByConditionFields.length) {
8893                                            if (orderByComparator.isAscending() ^ previous) {
8894                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8895                                            }
8896                                            else {
8897                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8898                                            }
8899                                    }
8900                                    else {
8901                                            if (orderByComparator.isAscending() ^ previous) {
8902                                                    query.append(WHERE_GREATER_THAN);
8903                                            }
8904                                            else {
8905                                                    query.append(WHERE_LESSER_THAN);
8906                                            }
8907                                    }
8908                            }
8909    
8910                            query.append(ORDER_BY_CLAUSE);
8911    
8912                            String[] orderByFields = orderByComparator.getOrderByFields();
8913    
8914                            for (int i = 0; i < orderByFields.length; i++) {
8915                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8916                                    query.append(orderByFields[i]);
8917    
8918                                    if ((i + 1) < orderByFields.length) {
8919                                            if (orderByComparator.isAscending() ^ previous) {
8920                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8921                                            }
8922                                            else {
8923                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8924                                            }
8925                                    }
8926                                    else {
8927                                            if (orderByComparator.isAscending() ^ previous) {
8928                                                    query.append(ORDER_BY_ASC);
8929                                            }
8930                                            else {
8931                                                    query.append(ORDER_BY_DESC);
8932                                            }
8933                                    }
8934                            }
8935                    }
8936                    else {
8937                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8938                    }
8939    
8940                    String sql = query.toString();
8941    
8942                    Query q = session.createQuery(sql);
8943    
8944                    q.setFirstResult(0);
8945                    q.setMaxResults(2);
8946    
8947                    QueryPos qPos = QueryPos.getInstance(q);
8948    
8949                    qPos.add(companyId);
8950    
8951                    qPos.add(userId);
8952    
8953                    qPos.add(status);
8954    
8955                    if (orderByComparator != null) {
8956                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8957    
8958                            for (Object value : values) {
8959                                    qPos.add(value);
8960                            }
8961                    }
8962    
8963                    List<BlogsEntry> list = q.list();
8964    
8965                    if (list.size() == 2) {
8966                            return list.get(1);
8967                    }
8968                    else {
8969                            return null;
8970                    }
8971            }
8972    
8973            /**
8974             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
8975             *
8976             * @param companyId the company ID
8977             * @param userId the user ID
8978             * @param status the status
8979             * @throws SystemException if a system exception occurred
8980             */
8981            @Override
8982            public void removeByC_U_NotS(long companyId, long userId, int status)
8983                    throws SystemException {
8984                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
8985                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8986                            remove(blogsEntry);
8987                    }
8988            }
8989    
8990            /**
8991             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
8992             *
8993             * @param companyId the company ID
8994             * @param userId the user ID
8995             * @param status the status
8996             * @return the number of matching blogs entries
8997             * @throws SystemException if a system exception occurred
8998             */
8999            @Override
9000            public int countByC_U_NotS(long companyId, long userId, int status)
9001                    throws SystemException {
9002                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
9003    
9004                    Object[] finderArgs = new Object[] { companyId, userId, status };
9005    
9006                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9007                                    this);
9008    
9009                    if (count == null) {
9010                            StringBundler query = new StringBundler(4);
9011    
9012                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9013    
9014                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
9015    
9016                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
9017    
9018                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
9019    
9020                            String sql = query.toString();
9021    
9022                            Session session = null;
9023    
9024                            try {
9025                                    session = openSession();
9026    
9027                                    Query q = session.createQuery(sql);
9028    
9029                                    QueryPos qPos = QueryPos.getInstance(q);
9030    
9031                                    qPos.add(companyId);
9032    
9033                                    qPos.add(userId);
9034    
9035                                    qPos.add(status);
9036    
9037                                    count = (Long)q.uniqueResult();
9038    
9039                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9040                            }
9041                            catch (Exception e) {
9042                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9043    
9044                                    throw processException(e);
9045                            }
9046                            finally {
9047                                    closeSession(session);
9048                            }
9049                    }
9050    
9051                    return count.intValue();
9052            }
9053    
9054            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9055            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
9056            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
9057            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9058                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9059                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
9060                            new String[] {
9061                                    Long.class.getName(), Long.class.getName(),
9062                                    Integer.class.getName(),
9063                                    
9064                            Integer.class.getName(), Integer.class.getName(),
9065                                    OrderByComparator.class.getName()
9066                            });
9067            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9068                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9069                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
9070                            new String[] {
9071                                    Long.class.getName(), Long.class.getName(),
9072                                    Integer.class.getName()
9073                            },
9074                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
9075                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9076                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9077                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9078                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9079            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9080                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9081                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
9082                            new String[] {
9083                                    Long.class.getName(), Long.class.getName(),
9084                                    Integer.class.getName()
9085                            });
9086    
9087            /**
9088             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9089             *
9090             * @param companyId the company ID
9091             * @param userId the user ID
9092             * @param status the status
9093             * @return the matching blogs entries
9094             * @throws SystemException if a system exception occurred
9095             */
9096            @Override
9097            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status)
9098                    throws SystemException {
9099                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
9100                            QueryUtil.ALL_POS, null);
9101            }
9102    
9103            /**
9104             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9105             *
9106             * <p>
9107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9108             * </p>
9109             *
9110             * @param companyId the company ID
9111             * @param userId the user ID
9112             * @param status the status
9113             * @param start the lower bound of the range of blogs entries
9114             * @param end the upper bound of the range of blogs entries (not inclusive)
9115             * @return the range of matching blogs entries
9116             * @throws SystemException if a system exception occurred
9117             */
9118            @Override
9119            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
9120                    int status, int start, int end) throws SystemException {
9121                    return findByC_U_S(companyId, userId, status, start, end, null);
9122            }
9123    
9124            /**
9125             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9126             *
9127             * <p>
9128             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9129             * </p>
9130             *
9131             * @param companyId the company ID
9132             * @param userId the user ID
9133             * @param status the status
9134             * @param start the lower bound of the range of blogs entries
9135             * @param end the upper bound of the range of blogs entries (not inclusive)
9136             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9137             * @return the ordered range of matching blogs entries
9138             * @throws SystemException if a system exception occurred
9139             */
9140            @Override
9141            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
9142                    int status, int start, int end, OrderByComparator orderByComparator)
9143                    throws SystemException {
9144                    boolean pagination = true;
9145                    FinderPath finderPath = null;
9146                    Object[] finderArgs = null;
9147    
9148                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9149                                    (orderByComparator == null)) {
9150                            pagination = false;
9151                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
9152                            finderArgs = new Object[] { companyId, userId, status };
9153                    }
9154                    else {
9155                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
9156                            finderArgs = new Object[] {
9157                                            companyId, userId, status,
9158                                            
9159                                            start, end, orderByComparator
9160                                    };
9161                    }
9162    
9163                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9164                                    finderArgs, this);
9165    
9166                    if ((list != null) && !list.isEmpty()) {
9167                            for (BlogsEntry blogsEntry : list) {
9168                                    if ((companyId != blogsEntry.getCompanyId()) ||
9169                                                    (userId != blogsEntry.getUserId()) ||
9170                                                    (status != blogsEntry.getStatus())) {
9171                                            list = null;
9172    
9173                                            break;
9174                                    }
9175                            }
9176                    }
9177    
9178                    if (list == null) {
9179                            StringBundler query = null;
9180    
9181                            if (orderByComparator != null) {
9182                                    query = new StringBundler(5 +
9183                                                    (orderByComparator.getOrderByFields().length * 3));
9184                            }
9185                            else {
9186                                    query = new StringBundler(5);
9187                            }
9188    
9189                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9190    
9191                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9192    
9193                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9194    
9195                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9196    
9197                            if (orderByComparator != null) {
9198                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9199                                            orderByComparator);
9200                            }
9201                            else
9202                             if (pagination) {
9203                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9204                            }
9205    
9206                            String sql = query.toString();
9207    
9208                            Session session = null;
9209    
9210                            try {
9211                                    session = openSession();
9212    
9213                                    Query q = session.createQuery(sql);
9214    
9215                                    QueryPos qPos = QueryPos.getInstance(q);
9216    
9217                                    qPos.add(companyId);
9218    
9219                                    qPos.add(userId);
9220    
9221                                    qPos.add(status);
9222    
9223                                    if (!pagination) {
9224                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9225                                                            start, end, false);
9226    
9227                                            Collections.sort(list);
9228    
9229                                            list = new UnmodifiableList<BlogsEntry>(list);
9230                                    }
9231                                    else {
9232                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9233                                                            start, end);
9234                                    }
9235    
9236                                    cacheResult(list);
9237    
9238                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9239                            }
9240                            catch (Exception e) {
9241                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9242    
9243                                    throw processException(e);
9244                            }
9245                            finally {
9246                                    closeSession(session);
9247                            }
9248                    }
9249    
9250                    return list;
9251            }
9252    
9253            /**
9254             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9255             *
9256             * @param companyId the company ID
9257             * @param userId the user ID
9258             * @param status the status
9259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9260             * @return the first matching blogs entry
9261             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9262             * @throws SystemException if a system exception occurred
9263             */
9264            @Override
9265            public BlogsEntry findByC_U_S_First(long companyId, long userId,
9266                    int status, OrderByComparator orderByComparator)
9267                    throws NoSuchEntryException, SystemException {
9268                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
9269                                    orderByComparator);
9270    
9271                    if (blogsEntry != null) {
9272                            return blogsEntry;
9273                    }
9274    
9275                    StringBundler msg = new StringBundler(8);
9276    
9277                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9278    
9279                    msg.append("companyId=");
9280                    msg.append(companyId);
9281    
9282                    msg.append(", userId=");
9283                    msg.append(userId);
9284    
9285                    msg.append(", status=");
9286                    msg.append(status);
9287    
9288                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9289    
9290                    throw new NoSuchEntryException(msg.toString());
9291            }
9292    
9293            /**
9294             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9295             *
9296             * @param companyId the company ID
9297             * @param userId the user ID
9298             * @param status the status
9299             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9300             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9301             * @throws SystemException if a system exception occurred
9302             */
9303            @Override
9304            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
9305                    int status, OrderByComparator orderByComparator)
9306                    throws SystemException {
9307                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
9308                                    orderByComparator);
9309    
9310                    if (!list.isEmpty()) {
9311                            return list.get(0);
9312                    }
9313    
9314                    return null;
9315            }
9316    
9317            /**
9318             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9319             *
9320             * @param companyId the company ID
9321             * @param userId the user ID
9322             * @param status the status
9323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9324             * @return the last matching blogs entry
9325             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9326             * @throws SystemException if a system exception occurred
9327             */
9328            @Override
9329            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
9330                    OrderByComparator orderByComparator)
9331                    throws NoSuchEntryException, SystemException {
9332                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
9333                                    orderByComparator);
9334    
9335                    if (blogsEntry != null) {
9336                            return blogsEntry;
9337                    }
9338    
9339                    StringBundler msg = new StringBundler(8);
9340    
9341                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9342    
9343                    msg.append("companyId=");
9344                    msg.append(companyId);
9345    
9346                    msg.append(", userId=");
9347                    msg.append(userId);
9348    
9349                    msg.append(", status=");
9350                    msg.append(status);
9351    
9352                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9353    
9354                    throw new NoSuchEntryException(msg.toString());
9355            }
9356    
9357            /**
9358             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9359             *
9360             * @param companyId the company ID
9361             * @param userId the user ID
9362             * @param status the status
9363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9364             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9365             * @throws SystemException if a system exception occurred
9366             */
9367            @Override
9368            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
9369                    int status, OrderByComparator orderByComparator)
9370                    throws SystemException {
9371                    int count = countByC_U_S(companyId, userId, status);
9372    
9373                    if (count == 0) {
9374                            return null;
9375                    }
9376    
9377                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
9378                                    count - 1, count, orderByComparator);
9379    
9380                    if (!list.isEmpty()) {
9381                            return list.get(0);
9382                    }
9383    
9384                    return null;
9385            }
9386    
9387            /**
9388             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
9389             *
9390             * @param entryId the primary key of the current blogs entry
9391             * @param companyId the company ID
9392             * @param userId the user ID
9393             * @param status the status
9394             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9395             * @return the previous, current, and next blogs entry
9396             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9397             * @throws SystemException if a system exception occurred
9398             */
9399            @Override
9400            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
9401                    long userId, int status, OrderByComparator orderByComparator)
9402                    throws NoSuchEntryException, SystemException {
9403                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9404    
9405                    Session session = null;
9406    
9407                    try {
9408                            session = openSession();
9409    
9410                            BlogsEntry[] array = new BlogsEntryImpl[3];
9411    
9412                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9413                                            userId, status, orderByComparator, true);
9414    
9415                            array[1] = blogsEntry;
9416    
9417                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
9418                                            userId, status, orderByComparator, false);
9419    
9420                            return array;
9421                    }
9422                    catch (Exception e) {
9423                            throw processException(e);
9424                    }
9425                    finally {
9426                            closeSession(session);
9427                    }
9428            }
9429    
9430            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
9431                    BlogsEntry blogsEntry, long companyId, long userId, int status,
9432                    OrderByComparator orderByComparator, boolean previous) {
9433                    StringBundler query = null;
9434    
9435                    if (orderByComparator != null) {
9436                            query = new StringBundler(6 +
9437                                            (orderByComparator.getOrderByFields().length * 6));
9438                    }
9439                    else {
9440                            query = new StringBundler(3);
9441                    }
9442    
9443                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9444    
9445                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9446    
9447                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9448    
9449                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9450    
9451                    if (orderByComparator != null) {
9452                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9453    
9454                            if (orderByConditionFields.length > 0) {
9455                                    query.append(WHERE_AND);
9456                            }
9457    
9458                            for (int i = 0; i < orderByConditionFields.length; i++) {
9459                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9460                                    query.append(orderByConditionFields[i]);
9461    
9462                                    if ((i + 1) < orderByConditionFields.length) {
9463                                            if (orderByComparator.isAscending() ^ previous) {
9464                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9465                                            }
9466                                            else {
9467                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9468                                            }
9469                                    }
9470                                    else {
9471                                            if (orderByComparator.isAscending() ^ previous) {
9472                                                    query.append(WHERE_GREATER_THAN);
9473                                            }
9474                                            else {
9475                                                    query.append(WHERE_LESSER_THAN);
9476                                            }
9477                                    }
9478                            }
9479    
9480                            query.append(ORDER_BY_CLAUSE);
9481    
9482                            String[] orderByFields = orderByComparator.getOrderByFields();
9483    
9484                            for (int i = 0; i < orderByFields.length; i++) {
9485                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9486                                    query.append(orderByFields[i]);
9487    
9488                                    if ((i + 1) < orderByFields.length) {
9489                                            if (orderByComparator.isAscending() ^ previous) {
9490                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9491                                            }
9492                                            else {
9493                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9494                                            }
9495                                    }
9496                                    else {
9497                                            if (orderByComparator.isAscending() ^ previous) {
9498                                                    query.append(ORDER_BY_ASC);
9499                                            }
9500                                            else {
9501                                                    query.append(ORDER_BY_DESC);
9502                                            }
9503                                    }
9504                            }
9505                    }
9506                    else {
9507                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9508                    }
9509    
9510                    String sql = query.toString();
9511    
9512                    Query q = session.createQuery(sql);
9513    
9514                    q.setFirstResult(0);
9515                    q.setMaxResults(2);
9516    
9517                    QueryPos qPos = QueryPos.getInstance(q);
9518    
9519                    qPos.add(companyId);
9520    
9521                    qPos.add(userId);
9522    
9523                    qPos.add(status);
9524    
9525                    if (orderByComparator != null) {
9526                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9527    
9528                            for (Object value : values) {
9529                                    qPos.add(value);
9530                            }
9531                    }
9532    
9533                    List<BlogsEntry> list = q.list();
9534    
9535                    if (list.size() == 2) {
9536                            return list.get(1);
9537                    }
9538                    else {
9539                            return null;
9540                    }
9541            }
9542    
9543            /**
9544             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
9545             *
9546             * @param companyId the company ID
9547             * @param userId the user ID
9548             * @param status the status
9549             * @throws SystemException if a system exception occurred
9550             */
9551            @Override
9552            public void removeByC_U_S(long companyId, long userId, int status)
9553                    throws SystemException {
9554                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
9555                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9556                            remove(blogsEntry);
9557                    }
9558            }
9559    
9560            /**
9561             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
9562             *
9563             * @param companyId the company ID
9564             * @param userId the user ID
9565             * @param status the status
9566             * @return the number of matching blogs entries
9567             * @throws SystemException if a system exception occurred
9568             */
9569            @Override
9570            public int countByC_U_S(long companyId, long userId, int status)
9571                    throws SystemException {
9572                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
9573    
9574                    Object[] finderArgs = new Object[] { companyId, userId, status };
9575    
9576                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9577                                    this);
9578    
9579                    if (count == null) {
9580                            StringBundler query = new StringBundler(4);
9581    
9582                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9583    
9584                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
9585    
9586                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
9587    
9588                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
9589    
9590                            String sql = query.toString();
9591    
9592                            Session session = null;
9593    
9594                            try {
9595                                    session = openSession();
9596    
9597                                    Query q = session.createQuery(sql);
9598    
9599                                    QueryPos qPos = QueryPos.getInstance(q);
9600    
9601                                    qPos.add(companyId);
9602    
9603                                    qPos.add(userId);
9604    
9605                                    qPos.add(status);
9606    
9607                                    count = (Long)q.uniqueResult();
9608    
9609                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9610                            }
9611                            catch (Exception e) {
9612                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9613    
9614                                    throw processException(e);
9615                            }
9616                            finally {
9617                                    closeSession(session);
9618                            }
9619                    }
9620    
9621                    return count.intValue();
9622            }
9623    
9624            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
9625            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
9626            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
9627            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
9628                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9629                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9630                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
9631                            new String[] {
9632                                    Long.class.getName(), Date.class.getName(),
9633                                    Integer.class.getName(),
9634                                    
9635                            Integer.class.getName(), Integer.class.getName(),
9636                                    OrderByComparator.class.getName()
9637                            });
9638            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
9639                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9640                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9641                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
9642                            new String[] {
9643                                    Long.class.getName(), Date.class.getName(),
9644                                    Integer.class.getName()
9645                            });
9646    
9647            /**
9648             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9649             *
9650             * @param companyId the company ID
9651             * @param displayDate the display date
9652             * @param status the status
9653             * @return the matching blogs entries
9654             * @throws SystemException if a system exception occurred
9655             */
9656            @Override
9657            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9658                    int status) throws SystemException {
9659                    return findByC_LtD_NotS(companyId, displayDate, status,
9660                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9661            }
9662    
9663            /**
9664             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9665             *
9666             * <p>
9667             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9668             * </p>
9669             *
9670             * @param companyId the company ID
9671             * @param displayDate the display date
9672             * @param status the status
9673             * @param start the lower bound of the range of blogs entries
9674             * @param end the upper bound of the range of blogs entries (not inclusive)
9675             * @return the range of matching blogs entries
9676             * @throws SystemException if a system exception occurred
9677             */
9678            @Override
9679            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9680                    int status, int start, int end) throws SystemException {
9681                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
9682            }
9683    
9684            /**
9685             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9686             *
9687             * <p>
9688             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9689             * </p>
9690             *
9691             * @param companyId the company ID
9692             * @param displayDate the display date
9693             * @param status the status
9694             * @param start the lower bound of the range of blogs entries
9695             * @param end the upper bound of the range of blogs entries (not inclusive)
9696             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9697             * @return the ordered range of matching blogs entries
9698             * @throws SystemException if a system exception occurred
9699             */
9700            @Override
9701            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
9702                    int status, int start, int end, OrderByComparator orderByComparator)
9703                    throws SystemException {
9704                    boolean pagination = true;
9705                    FinderPath finderPath = null;
9706                    Object[] finderArgs = null;
9707    
9708                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
9709                    finderArgs = new Object[] {
9710                                    companyId, displayDate, status,
9711                                    
9712                                    start, end, orderByComparator
9713                            };
9714    
9715                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9716                                    finderArgs, this);
9717    
9718                    if ((list != null) && !list.isEmpty()) {
9719                            for (BlogsEntry blogsEntry : list) {
9720                                    if ((companyId != blogsEntry.getCompanyId()) ||
9721                                                    !Validator.equals(displayDate,
9722                                                            blogsEntry.getDisplayDate()) ||
9723                                                    (status != blogsEntry.getStatus())) {
9724                                            list = null;
9725    
9726                                            break;
9727                                    }
9728                            }
9729                    }
9730    
9731                    if (list == null) {
9732                            StringBundler query = null;
9733    
9734                            if (orderByComparator != null) {
9735                                    query = new StringBundler(5 +
9736                                                    (orderByComparator.getOrderByFields().length * 3));
9737                            }
9738                            else {
9739                                    query = new StringBundler(5);
9740                            }
9741    
9742                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9743    
9744                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
9745    
9746                            boolean bindDisplayDate = false;
9747    
9748                            if (displayDate == null) {
9749                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
9750                            }
9751                            else {
9752                                    bindDisplayDate = true;
9753    
9754                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
9755                            }
9756    
9757                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
9758    
9759                            if (orderByComparator != null) {
9760                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9761                                            orderByComparator);
9762                            }
9763                            else
9764                             if (pagination) {
9765                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9766                            }
9767    
9768                            String sql = query.toString();
9769    
9770                            Session session = null;
9771    
9772                            try {
9773                                    session = openSession();
9774    
9775                                    Query q = session.createQuery(sql);
9776    
9777                                    QueryPos qPos = QueryPos.getInstance(q);
9778    
9779                                    qPos.add(companyId);
9780    
9781                                    if (bindDisplayDate) {
9782                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
9783                                    }
9784    
9785                                    qPos.add(status);
9786    
9787                                    if (!pagination) {
9788                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9789                                                            start, end, false);
9790    
9791                                            Collections.sort(list);
9792    
9793                                            list = new UnmodifiableList<BlogsEntry>(list);
9794                                    }
9795                                    else {
9796                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9797                                                            start, end);
9798                                    }
9799    
9800                                    cacheResult(list);
9801    
9802                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9803                            }
9804                            catch (Exception e) {
9805                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9806    
9807                                    throw processException(e);
9808                            }
9809                            finally {
9810                                    closeSession(session);
9811                            }
9812                    }
9813    
9814                    return list;
9815            }
9816    
9817            /**
9818             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9819             *
9820             * @param companyId the company ID
9821             * @param displayDate the display date
9822             * @param status the status
9823             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9824             * @return the first matching blogs entry
9825             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9826             * @throws SystemException if a system exception occurred
9827             */
9828            @Override
9829            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
9830                    int status, OrderByComparator orderByComparator)
9831                    throws NoSuchEntryException, SystemException {
9832                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
9833                                    status, orderByComparator);
9834    
9835                    if (blogsEntry != null) {
9836                            return blogsEntry;
9837                    }
9838    
9839                    StringBundler msg = new StringBundler(8);
9840    
9841                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9842    
9843                    msg.append("companyId=");
9844                    msg.append(companyId);
9845    
9846                    msg.append(", displayDate=");
9847                    msg.append(displayDate);
9848    
9849                    msg.append(", status=");
9850                    msg.append(status);
9851    
9852                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9853    
9854                    throw new NoSuchEntryException(msg.toString());
9855            }
9856    
9857            /**
9858             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9859             *
9860             * @param companyId the company ID
9861             * @param displayDate the display date
9862             * @param status the status
9863             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9864             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9865             * @throws SystemException if a system exception occurred
9866             */
9867            @Override
9868            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
9869                    int status, OrderByComparator orderByComparator)
9870                    throws SystemException {
9871                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9872                                    status, 0, 1, orderByComparator);
9873    
9874                    if (!list.isEmpty()) {
9875                            return list.get(0);
9876                    }
9877    
9878                    return null;
9879            }
9880    
9881            /**
9882             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9883             *
9884             * @param companyId the company ID
9885             * @param displayDate the display date
9886             * @param status the status
9887             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9888             * @return the last matching blogs entry
9889             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9890             * @throws SystemException if a system exception occurred
9891             */
9892            @Override
9893            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
9894                    int status, OrderByComparator orderByComparator)
9895                    throws NoSuchEntryException, SystemException {
9896                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
9897                                    status, orderByComparator);
9898    
9899                    if (blogsEntry != null) {
9900                            return blogsEntry;
9901                    }
9902    
9903                    StringBundler msg = new StringBundler(8);
9904    
9905                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9906    
9907                    msg.append("companyId=");
9908                    msg.append(companyId);
9909    
9910                    msg.append(", displayDate=");
9911                    msg.append(displayDate);
9912    
9913                    msg.append(", status=");
9914                    msg.append(status);
9915    
9916                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9917    
9918                    throw new NoSuchEntryException(msg.toString());
9919            }
9920    
9921            /**
9922             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
9923             *
9924             * @param companyId the company ID
9925             * @param displayDate the display date
9926             * @param status the status
9927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9928             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9929             * @throws SystemException if a system exception occurred
9930             */
9931            @Override
9932            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
9933                    int status, OrderByComparator orderByComparator)
9934                    throws SystemException {
9935                    int count = countByC_LtD_NotS(companyId, displayDate, status);
9936    
9937                    if (count == 0) {
9938                            return null;
9939                    }
9940    
9941                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
9942                                    status, count - 1, count, orderByComparator);
9943    
9944                    if (!list.isEmpty()) {
9945                            return list.get(0);
9946                    }
9947    
9948                    return null;
9949            }
9950    
9951            /**
9952             * 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;.
9953             *
9954             * @param entryId the primary key of the current blogs entry
9955             * @param companyId the company ID
9956             * @param displayDate the display date
9957             * @param status the status
9958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9959             * @return the previous, current, and next blogs entry
9960             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9961             * @throws SystemException if a system exception occurred
9962             */
9963            @Override
9964            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
9965                    long companyId, Date displayDate, int status,
9966                    OrderByComparator orderByComparator)
9967                    throws NoSuchEntryException, SystemException {
9968                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9969    
9970                    Session session = null;
9971    
9972                    try {
9973                            session = openSession();
9974    
9975                            BlogsEntry[] array = new BlogsEntryImpl[3];
9976    
9977                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9978                                            companyId, displayDate, status, orderByComparator, true);
9979    
9980                            array[1] = blogsEntry;
9981    
9982                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
9983                                            companyId, displayDate, status, orderByComparator, false);
9984    
9985                            return array;
9986                    }
9987                    catch (Exception e) {
9988                            throw processException(e);
9989                    }
9990                    finally {
9991                            closeSession(session);
9992                    }
9993            }
9994    
9995            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
9996                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
9997                    OrderByComparator orderByComparator, boolean previous) {
9998                    StringBundler query = null;
9999    
10000                    if (orderByComparator != null) {
10001                            query = new StringBundler(6 +
10002                                            (orderByComparator.getOrderByFields().length * 6));
10003                    }
10004                    else {
10005                            query = new StringBundler(3);
10006                    }
10007    
10008                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10009    
10010                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
10011    
10012                    boolean bindDisplayDate = false;
10013    
10014                    if (displayDate == null) {
10015                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
10016                    }
10017                    else {
10018                            bindDisplayDate = true;
10019    
10020                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
10021                    }
10022    
10023                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
10024    
10025                    if (orderByComparator != null) {
10026                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10027    
10028                            if (orderByConditionFields.length > 0) {
10029                                    query.append(WHERE_AND);
10030                            }
10031    
10032                            for (int i = 0; i < orderByConditionFields.length; i++) {
10033                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10034                                    query.append(orderByConditionFields[i]);
10035    
10036                                    if ((i + 1) < orderByConditionFields.length) {
10037                                            if (orderByComparator.isAscending() ^ previous) {
10038                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10039                                            }
10040                                            else {
10041                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10042                                            }
10043                                    }
10044                                    else {
10045                                            if (orderByComparator.isAscending() ^ previous) {
10046                                                    query.append(WHERE_GREATER_THAN);
10047                                            }
10048                                            else {
10049                                                    query.append(WHERE_LESSER_THAN);
10050                                            }
10051                                    }
10052                            }
10053    
10054                            query.append(ORDER_BY_CLAUSE);
10055    
10056                            String[] orderByFields = orderByComparator.getOrderByFields();
10057    
10058                            for (int i = 0; i < orderByFields.length; i++) {
10059                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10060                                    query.append(orderByFields[i]);
10061    
10062                                    if ((i + 1) < orderByFields.length) {
10063                                            if (orderByComparator.isAscending() ^ previous) {
10064                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10065                                            }
10066                                            else {
10067                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10068                                            }
10069                                    }
10070                                    else {
10071                                            if (orderByComparator.isAscending() ^ previous) {
10072                                                    query.append(ORDER_BY_ASC);
10073                                            }
10074                                            else {
10075                                                    query.append(ORDER_BY_DESC);
10076                                            }
10077                                    }
10078                            }
10079                    }
10080                    else {
10081                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10082                    }
10083    
10084                    String sql = query.toString();
10085    
10086                    Query q = session.createQuery(sql);
10087    
10088                    q.setFirstResult(0);
10089                    q.setMaxResults(2);
10090    
10091                    QueryPos qPos = QueryPos.getInstance(q);
10092    
10093                    qPos.add(companyId);
10094    
10095                    if (bindDisplayDate) {
10096                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10097                    }
10098    
10099                    qPos.add(status);
10100    
10101                    if (orderByComparator != null) {
10102                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10103    
10104                            for (Object value : values) {
10105                                    qPos.add(value);
10106                            }
10107                    }
10108    
10109                    List<BlogsEntry> list = q.list();
10110    
10111                    if (list.size() == 2) {
10112                            return list.get(1);
10113                    }
10114                    else {
10115                            return null;
10116                    }
10117            }
10118    
10119            /**
10120             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
10121             *
10122             * @param companyId the company ID
10123             * @param displayDate the display date
10124             * @param status the status
10125             * @throws SystemException if a system exception occurred
10126             */
10127            @Override
10128            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status)
10129                    throws SystemException {
10130                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
10131                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10132                            remove(blogsEntry);
10133                    }
10134            }
10135    
10136            /**
10137             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
10138             *
10139             * @param companyId the company ID
10140             * @param displayDate the display date
10141             * @param status the status
10142             * @return the number of matching blogs entries
10143             * @throws SystemException if a system exception occurred
10144             */
10145            @Override
10146            public int countByC_LtD_NotS(long companyId, Date displayDate, int status)
10147                    throws SystemException {
10148                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
10149    
10150                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
10151    
10152                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10153                                    this);
10154    
10155                    if (count == null) {
10156                            StringBundler query = new StringBundler(4);
10157    
10158                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10159    
10160                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
10161    
10162                            boolean bindDisplayDate = false;
10163    
10164                            if (displayDate == null) {
10165                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
10166                            }
10167                            else {
10168                                    bindDisplayDate = true;
10169    
10170                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
10171                            }
10172    
10173                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
10174    
10175                            String sql = query.toString();
10176    
10177                            Session session = null;
10178    
10179                            try {
10180                                    session = openSession();
10181    
10182                                    Query q = session.createQuery(sql);
10183    
10184                                    QueryPos qPos = QueryPos.getInstance(q);
10185    
10186                                    qPos.add(companyId);
10187    
10188                                    if (bindDisplayDate) {
10189                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10190                                    }
10191    
10192                                    qPos.add(status);
10193    
10194                                    count = (Long)q.uniqueResult();
10195    
10196                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10197                            }
10198                            catch (Exception e) {
10199                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10200    
10201                                    throw processException(e);
10202                            }
10203                            finally {
10204                                    closeSession(session);
10205                            }
10206                    }
10207    
10208                    return count.intValue();
10209            }
10210    
10211            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
10212            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
10213            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
10214            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
10215            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10216                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10217                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
10218                            new String[] {
10219                                    Long.class.getName(), Date.class.getName(),
10220                                    Integer.class.getName(),
10221                                    
10222                            Integer.class.getName(), Integer.class.getName(),
10223                                    OrderByComparator.class.getName()
10224                            });
10225            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10226                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10227                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
10228                            new String[] {
10229                                    Long.class.getName(), Date.class.getName(),
10230                                    Integer.class.getName()
10231                            });
10232    
10233            /**
10234             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10235             *
10236             * @param companyId the company ID
10237             * @param displayDate the display date
10238             * @param status the status
10239             * @return the matching blogs entries
10240             * @throws SystemException if a system exception occurred
10241             */
10242            @Override
10243            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10244                    int status) throws SystemException {
10245                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
10246                            QueryUtil.ALL_POS, null);
10247            }
10248    
10249            /**
10250             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10251             *
10252             * <p>
10253             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10254             * </p>
10255             *
10256             * @param companyId the company ID
10257             * @param displayDate the display date
10258             * @param status the status
10259             * @param start the lower bound of the range of blogs entries
10260             * @param end the upper bound of the range of blogs entries (not inclusive)
10261             * @return the range of matching blogs entries
10262             * @throws SystemException if a system exception occurred
10263             */
10264            @Override
10265            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10266                    int status, int start, int end) throws SystemException {
10267                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
10268            }
10269    
10270            /**
10271             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10272             *
10273             * <p>
10274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10275             * </p>
10276             *
10277             * @param companyId the company ID
10278             * @param displayDate the display date
10279             * @param status the status
10280             * @param start the lower bound of the range of blogs entries
10281             * @param end the upper bound of the range of blogs entries (not inclusive)
10282             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10283             * @return the ordered range of matching blogs entries
10284             * @throws SystemException if a system exception occurred
10285             */
10286            @Override
10287            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
10288                    int status, int start, int end, OrderByComparator orderByComparator)
10289                    throws SystemException {
10290                    boolean pagination = true;
10291                    FinderPath finderPath = null;
10292                    Object[] finderArgs = null;
10293    
10294                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
10295                    finderArgs = new Object[] {
10296                                    companyId, displayDate, status,
10297                                    
10298                                    start, end, orderByComparator
10299                            };
10300    
10301                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10302                                    finderArgs, this);
10303    
10304                    if ((list != null) && !list.isEmpty()) {
10305                            for (BlogsEntry blogsEntry : list) {
10306                                    if ((companyId != blogsEntry.getCompanyId()) ||
10307                                                    !Validator.equals(displayDate,
10308                                                            blogsEntry.getDisplayDate()) ||
10309                                                    (status != blogsEntry.getStatus())) {
10310                                            list = null;
10311    
10312                                            break;
10313                                    }
10314                            }
10315                    }
10316    
10317                    if (list == null) {
10318                            StringBundler query = null;
10319    
10320                            if (orderByComparator != null) {
10321                                    query = new StringBundler(5 +
10322                                                    (orderByComparator.getOrderByFields().length * 3));
10323                            }
10324                            else {
10325                                    query = new StringBundler(5);
10326                            }
10327    
10328                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10329    
10330                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10331    
10332                            boolean bindDisplayDate = false;
10333    
10334                            if (displayDate == null) {
10335                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10336                            }
10337                            else {
10338                                    bindDisplayDate = true;
10339    
10340                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10341                            }
10342    
10343                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10344    
10345                            if (orderByComparator != null) {
10346                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10347                                            orderByComparator);
10348                            }
10349                            else
10350                             if (pagination) {
10351                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10352                            }
10353    
10354                            String sql = query.toString();
10355    
10356                            Session session = null;
10357    
10358                            try {
10359                                    session = openSession();
10360    
10361                                    Query q = session.createQuery(sql);
10362    
10363                                    QueryPos qPos = QueryPos.getInstance(q);
10364    
10365                                    qPos.add(companyId);
10366    
10367                                    if (bindDisplayDate) {
10368                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10369                                    }
10370    
10371                                    qPos.add(status);
10372    
10373                                    if (!pagination) {
10374                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10375                                                            start, end, false);
10376    
10377                                            Collections.sort(list);
10378    
10379                                            list = new UnmodifiableList<BlogsEntry>(list);
10380                                    }
10381                                    else {
10382                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10383                                                            start, end);
10384                                    }
10385    
10386                                    cacheResult(list);
10387    
10388                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10389                            }
10390                            catch (Exception e) {
10391                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10392    
10393                                    throw processException(e);
10394                            }
10395                            finally {
10396                                    closeSession(session);
10397                            }
10398                    }
10399    
10400                    return list;
10401            }
10402    
10403            /**
10404             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10405             *
10406             * @param companyId the company ID
10407             * @param displayDate the display date
10408             * @param status the status
10409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10410             * @return the first matching blogs entry
10411             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10412             * @throws SystemException if a system exception occurred
10413             */
10414            @Override
10415            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
10416                    int status, OrderByComparator orderByComparator)
10417                    throws NoSuchEntryException, SystemException {
10418                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
10419                                    status, orderByComparator);
10420    
10421                    if (blogsEntry != null) {
10422                            return blogsEntry;
10423                    }
10424    
10425                    StringBundler msg = new StringBundler(8);
10426    
10427                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10428    
10429                    msg.append("companyId=");
10430                    msg.append(companyId);
10431    
10432                    msg.append(", displayDate=");
10433                    msg.append(displayDate);
10434    
10435                    msg.append(", status=");
10436                    msg.append(status);
10437    
10438                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10439    
10440                    throw new NoSuchEntryException(msg.toString());
10441            }
10442    
10443            /**
10444             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10445             *
10446             * @param companyId the company ID
10447             * @param displayDate the display date
10448             * @param status the status
10449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10450             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10451             * @throws SystemException if a system exception occurred
10452             */
10453            @Override
10454            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
10455                    int status, OrderByComparator orderByComparator)
10456                    throws SystemException {
10457                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10458                                    0, 1, orderByComparator);
10459    
10460                    if (!list.isEmpty()) {
10461                            return list.get(0);
10462                    }
10463    
10464                    return null;
10465            }
10466    
10467            /**
10468             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10469             *
10470             * @param companyId the company ID
10471             * @param displayDate the display date
10472             * @param status the status
10473             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10474             * @return the last matching blogs entry
10475             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10476             * @throws SystemException if a system exception occurred
10477             */
10478            @Override
10479            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
10480                    int status, OrderByComparator orderByComparator)
10481                    throws NoSuchEntryException, SystemException {
10482                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
10483                                    status, orderByComparator);
10484    
10485                    if (blogsEntry != null) {
10486                            return blogsEntry;
10487                    }
10488    
10489                    StringBundler msg = new StringBundler(8);
10490    
10491                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10492    
10493                    msg.append("companyId=");
10494                    msg.append(companyId);
10495    
10496                    msg.append(", displayDate=");
10497                    msg.append(displayDate);
10498    
10499                    msg.append(", status=");
10500                    msg.append(status);
10501    
10502                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10503    
10504                    throw new NoSuchEntryException(msg.toString());
10505            }
10506    
10507            /**
10508             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10509             *
10510             * @param companyId the company ID
10511             * @param displayDate the display date
10512             * @param status the status
10513             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10514             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10515             * @throws SystemException if a system exception occurred
10516             */
10517            @Override
10518            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
10519                    int status, OrderByComparator orderByComparator)
10520                    throws SystemException {
10521                    int count = countByC_LtD_S(companyId, displayDate, status);
10522    
10523                    if (count == 0) {
10524                            return null;
10525                    }
10526    
10527                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
10528                                    count - 1, count, orderByComparator);
10529    
10530                    if (!list.isEmpty()) {
10531                            return list.get(0);
10532                    }
10533    
10534                    return null;
10535            }
10536    
10537            /**
10538             * 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;.
10539             *
10540             * @param entryId the primary key of the current blogs entry
10541             * @param companyId the company ID
10542             * @param displayDate the display date
10543             * @param status the status
10544             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10545             * @return the previous, current, and next blogs entry
10546             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10547             * @throws SystemException if a system exception occurred
10548             */
10549            @Override
10550            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
10551                    Date displayDate, int status, OrderByComparator orderByComparator)
10552                    throws NoSuchEntryException, SystemException {
10553                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10554    
10555                    Session session = null;
10556    
10557                    try {
10558                            session = openSession();
10559    
10560                            BlogsEntry[] array = new BlogsEntryImpl[3];
10561    
10562                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10563                                            displayDate, status, orderByComparator, true);
10564    
10565                            array[1] = blogsEntry;
10566    
10567                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
10568                                            displayDate, status, orderByComparator, false);
10569    
10570                            return array;
10571                    }
10572                    catch (Exception e) {
10573                            throw processException(e);
10574                    }
10575                    finally {
10576                            closeSession(session);
10577                    }
10578            }
10579    
10580            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
10581                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
10582                    OrderByComparator orderByComparator, boolean previous) {
10583                    StringBundler query = null;
10584    
10585                    if (orderByComparator != null) {
10586                            query = new StringBundler(6 +
10587                                            (orderByComparator.getOrderByFields().length * 6));
10588                    }
10589                    else {
10590                            query = new StringBundler(3);
10591                    }
10592    
10593                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10594    
10595                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10596    
10597                    boolean bindDisplayDate = false;
10598    
10599                    if (displayDate == null) {
10600                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10601                    }
10602                    else {
10603                            bindDisplayDate = true;
10604    
10605                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10606                    }
10607    
10608                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10609    
10610                    if (orderByComparator != null) {
10611                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10612    
10613                            if (orderByConditionFields.length > 0) {
10614                                    query.append(WHERE_AND);
10615                            }
10616    
10617                            for (int i = 0; i < orderByConditionFields.length; i++) {
10618                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10619                                    query.append(orderByConditionFields[i]);
10620    
10621                                    if ((i + 1) < orderByConditionFields.length) {
10622                                            if (orderByComparator.isAscending() ^ previous) {
10623                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10624                                            }
10625                                            else {
10626                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10627                                            }
10628                                    }
10629                                    else {
10630                                            if (orderByComparator.isAscending() ^ previous) {
10631                                                    query.append(WHERE_GREATER_THAN);
10632                                            }
10633                                            else {
10634                                                    query.append(WHERE_LESSER_THAN);
10635                                            }
10636                                    }
10637                            }
10638    
10639                            query.append(ORDER_BY_CLAUSE);
10640    
10641                            String[] orderByFields = orderByComparator.getOrderByFields();
10642    
10643                            for (int i = 0; i < orderByFields.length; i++) {
10644                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10645                                    query.append(orderByFields[i]);
10646    
10647                                    if ((i + 1) < orderByFields.length) {
10648                                            if (orderByComparator.isAscending() ^ previous) {
10649                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10650                                            }
10651                                            else {
10652                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10653                                            }
10654                                    }
10655                                    else {
10656                                            if (orderByComparator.isAscending() ^ previous) {
10657                                                    query.append(ORDER_BY_ASC);
10658                                            }
10659                                            else {
10660                                                    query.append(ORDER_BY_DESC);
10661                                            }
10662                                    }
10663                            }
10664                    }
10665                    else {
10666                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10667                    }
10668    
10669                    String sql = query.toString();
10670    
10671                    Query q = session.createQuery(sql);
10672    
10673                    q.setFirstResult(0);
10674                    q.setMaxResults(2);
10675    
10676                    QueryPos qPos = QueryPos.getInstance(q);
10677    
10678                    qPos.add(companyId);
10679    
10680                    if (bindDisplayDate) {
10681                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10682                    }
10683    
10684                    qPos.add(status);
10685    
10686                    if (orderByComparator != null) {
10687                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10688    
10689                            for (Object value : values) {
10690                                    qPos.add(value);
10691                            }
10692                    }
10693    
10694                    List<BlogsEntry> list = q.list();
10695    
10696                    if (list.size() == 2) {
10697                            return list.get(1);
10698                    }
10699                    else {
10700                            return null;
10701                    }
10702            }
10703    
10704            /**
10705             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
10706             *
10707             * @param companyId the company ID
10708             * @param displayDate the display date
10709             * @param status the status
10710             * @throws SystemException if a system exception occurred
10711             */
10712            @Override
10713            public void removeByC_LtD_S(long companyId, Date displayDate, int status)
10714                    throws SystemException {
10715                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
10716                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10717                            remove(blogsEntry);
10718                    }
10719            }
10720    
10721            /**
10722             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
10723             *
10724             * @param companyId the company ID
10725             * @param displayDate the display date
10726             * @param status the status
10727             * @return the number of matching blogs entries
10728             * @throws SystemException if a system exception occurred
10729             */
10730            @Override
10731            public int countByC_LtD_S(long companyId, Date displayDate, int status)
10732                    throws SystemException {
10733                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
10734    
10735                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
10736    
10737                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10738                                    this);
10739    
10740                    if (count == null) {
10741                            StringBundler query = new StringBundler(4);
10742    
10743                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10744    
10745                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
10746    
10747                            boolean bindDisplayDate = false;
10748    
10749                            if (displayDate == null) {
10750                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
10751                            }
10752                            else {
10753                                    bindDisplayDate = true;
10754    
10755                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
10756                            }
10757    
10758                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
10759    
10760                            String sql = query.toString();
10761    
10762                            Session session = null;
10763    
10764                            try {
10765                                    session = openSession();
10766    
10767                                    Query q = session.createQuery(sql);
10768    
10769                                    QueryPos qPos = QueryPos.getInstance(q);
10770    
10771                                    qPos.add(companyId);
10772    
10773                                    if (bindDisplayDate) {
10774                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10775                                    }
10776    
10777                                    qPos.add(status);
10778    
10779                                    count = (Long)q.uniqueResult();
10780    
10781                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10782                            }
10783                            catch (Exception e) {
10784                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10785    
10786                                    throw processException(e);
10787                            }
10788                            finally {
10789                                    closeSession(session);
10790                            }
10791                    }
10792    
10793                    return count.intValue();
10794            }
10795    
10796            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
10797            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
10798            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
10799            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
10800            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10801                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10802                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
10803                            new String[] {
10804                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
10805                                    
10806                            Integer.class.getName(), Integer.class.getName(),
10807                                    OrderByComparator.class.getName()
10808                            });
10809            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10810                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10811                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
10812                            new String[] {
10813                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
10814                            });
10815    
10816            /**
10817             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10818             *
10819             * @param groupId the group ID
10820             * @param userId the user ID
10821             * @param displayDate the display date
10822             * @return the matching blogs entries
10823             * @throws SystemException if a system exception occurred
10824             */
10825            @Override
10826            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10827                    Date displayDate) throws SystemException {
10828                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
10829                            QueryUtil.ALL_POS, null);
10830            }
10831    
10832            /**
10833             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10834             *
10835             * <p>
10836             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10837             * </p>
10838             *
10839             * @param groupId the group ID
10840             * @param userId the user ID
10841             * @param displayDate the display date
10842             * @param start the lower bound of the range of blogs entries
10843             * @param end the upper bound of the range of blogs entries (not inclusive)
10844             * @return the range of matching blogs entries
10845             * @throws SystemException if a system exception occurred
10846             */
10847            @Override
10848            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10849                    Date displayDate, int start, int end) throws SystemException {
10850                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
10851            }
10852    
10853            /**
10854             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10855             *
10856             * <p>
10857             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10858             * </p>
10859             *
10860             * @param groupId the group ID
10861             * @param userId the user ID
10862             * @param displayDate the display date
10863             * @param start the lower bound of the range of blogs entries
10864             * @param end the upper bound of the range of blogs entries (not inclusive)
10865             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10866             * @return the ordered range of matching blogs entries
10867             * @throws SystemException if a system exception occurred
10868             */
10869            @Override
10870            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
10871                    Date displayDate, int start, int end,
10872                    OrderByComparator orderByComparator) throws SystemException {
10873                    boolean pagination = true;
10874                    FinderPath finderPath = null;
10875                    Object[] finderArgs = null;
10876    
10877                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
10878                    finderArgs = new Object[] {
10879                                    groupId, userId, displayDate,
10880                                    
10881                                    start, end, orderByComparator
10882                            };
10883    
10884                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10885                                    finderArgs, this);
10886    
10887                    if ((list != null) && !list.isEmpty()) {
10888                            for (BlogsEntry blogsEntry : list) {
10889                                    if ((groupId != blogsEntry.getGroupId()) ||
10890                                                    (userId != blogsEntry.getUserId()) ||
10891                                                    !Validator.equals(displayDate,
10892                                                            blogsEntry.getDisplayDate())) {
10893                                            list = null;
10894    
10895                                            break;
10896                                    }
10897                            }
10898                    }
10899    
10900                    if (list == null) {
10901                            StringBundler query = null;
10902    
10903                            if (orderByComparator != null) {
10904                                    query = new StringBundler(5 +
10905                                                    (orderByComparator.getOrderByFields().length * 3));
10906                            }
10907                            else {
10908                                    query = new StringBundler(5);
10909                            }
10910    
10911                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10912    
10913                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
10914    
10915                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
10916    
10917                            boolean bindDisplayDate = false;
10918    
10919                            if (displayDate == null) {
10920                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
10921                            }
10922                            else {
10923                                    bindDisplayDate = true;
10924    
10925                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
10926                            }
10927    
10928                            if (orderByComparator != null) {
10929                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10930                                            orderByComparator);
10931                            }
10932                            else
10933                             if (pagination) {
10934                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10935                            }
10936    
10937                            String sql = query.toString();
10938    
10939                            Session session = null;
10940    
10941                            try {
10942                                    session = openSession();
10943    
10944                                    Query q = session.createQuery(sql);
10945    
10946                                    QueryPos qPos = QueryPos.getInstance(q);
10947    
10948                                    qPos.add(groupId);
10949    
10950                                    qPos.add(userId);
10951    
10952                                    if (bindDisplayDate) {
10953                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
10954                                    }
10955    
10956                                    if (!pagination) {
10957                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10958                                                            start, end, false);
10959    
10960                                            Collections.sort(list);
10961    
10962                                            list = new UnmodifiableList<BlogsEntry>(list);
10963                                    }
10964                                    else {
10965                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10966                                                            start, end);
10967                                    }
10968    
10969                                    cacheResult(list);
10970    
10971                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10972                            }
10973                            catch (Exception e) {
10974                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10975    
10976                                    throw processException(e);
10977                            }
10978                            finally {
10979                                    closeSession(session);
10980                            }
10981                    }
10982    
10983                    return list;
10984            }
10985    
10986            /**
10987             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
10988             *
10989             * @param groupId the group ID
10990             * @param userId the user ID
10991             * @param displayDate the display date
10992             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10993             * @return the first matching blogs entry
10994             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10995             * @throws SystemException if a system exception occurred
10996             */
10997            @Override
10998            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
10999                    Date displayDate, OrderByComparator orderByComparator)
11000                    throws NoSuchEntryException, SystemException {
11001                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
11002                                    displayDate, orderByComparator);
11003    
11004                    if (blogsEntry != null) {
11005                            return blogsEntry;
11006                    }
11007    
11008                    StringBundler msg = new StringBundler(8);
11009    
11010                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11011    
11012                    msg.append("groupId=");
11013                    msg.append(groupId);
11014    
11015                    msg.append(", userId=");
11016                    msg.append(userId);
11017    
11018                    msg.append(", displayDate=");
11019                    msg.append(displayDate);
11020    
11021                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11022    
11023                    throw new NoSuchEntryException(msg.toString());
11024            }
11025    
11026            /**
11027             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11028             *
11029             * @param groupId the group ID
11030             * @param userId the user ID
11031             * @param displayDate the display date
11032             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11033             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11034             * @throws SystemException if a system exception occurred
11035             */
11036            @Override
11037            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
11038                    Date displayDate, OrderByComparator orderByComparator)
11039                    throws SystemException {
11040                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
11041                                    1, orderByComparator);
11042    
11043                    if (!list.isEmpty()) {
11044                            return list.get(0);
11045                    }
11046    
11047                    return null;
11048            }
11049    
11050            /**
11051             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11052             *
11053             * @param groupId the group ID
11054             * @param userId the user ID
11055             * @param displayDate the display date
11056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11057             * @return the last matching blogs entry
11058             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11059             * @throws SystemException if a system exception occurred
11060             */
11061            @Override
11062            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
11063                    Date displayDate, OrderByComparator orderByComparator)
11064                    throws NoSuchEntryException, SystemException {
11065                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
11066                                    displayDate, orderByComparator);
11067    
11068                    if (blogsEntry != null) {
11069                            return blogsEntry;
11070                    }
11071    
11072                    StringBundler msg = new StringBundler(8);
11073    
11074                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11075    
11076                    msg.append("groupId=");
11077                    msg.append(groupId);
11078    
11079                    msg.append(", userId=");
11080                    msg.append(userId);
11081    
11082                    msg.append(", displayDate=");
11083                    msg.append(displayDate);
11084    
11085                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11086    
11087                    throw new NoSuchEntryException(msg.toString());
11088            }
11089    
11090            /**
11091             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11092             *
11093             * @param groupId the group ID
11094             * @param userId the user ID
11095             * @param displayDate the display date
11096             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11097             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11098             * @throws SystemException if a system exception occurred
11099             */
11100            @Override
11101            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
11102                    Date displayDate, OrderByComparator orderByComparator)
11103                    throws SystemException {
11104                    int count = countByG_U_LtD(groupId, userId, displayDate);
11105    
11106                    if (count == 0) {
11107                            return null;
11108                    }
11109    
11110                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
11111                                    count - 1, count, orderByComparator);
11112    
11113                    if (!list.isEmpty()) {
11114                            return list.get(0);
11115                    }
11116    
11117                    return null;
11118            }
11119    
11120            /**
11121             * 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;.
11122             *
11123             * @param entryId the primary key of the current blogs entry
11124             * @param groupId the group ID
11125             * @param userId the user ID
11126             * @param displayDate the display date
11127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11128             * @return the previous, current, and next blogs entry
11129             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11130             * @throws SystemException if a system exception occurred
11131             */
11132            @Override
11133            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
11134                    long userId, Date displayDate, OrderByComparator orderByComparator)
11135                    throws NoSuchEntryException, SystemException {
11136                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11137    
11138                    Session session = null;
11139    
11140                    try {
11141                            session = openSession();
11142    
11143                            BlogsEntry[] array = new BlogsEntryImpl[3];
11144    
11145                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
11146                                            userId, displayDate, orderByComparator, true);
11147    
11148                            array[1] = blogsEntry;
11149    
11150                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
11151                                            userId, displayDate, orderByComparator, false);
11152    
11153                            return array;
11154                    }
11155                    catch (Exception e) {
11156                            throw processException(e);
11157                    }
11158                    finally {
11159                            closeSession(session);
11160                    }
11161            }
11162    
11163            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
11164                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
11165                    OrderByComparator orderByComparator, boolean previous) {
11166                    StringBundler query = null;
11167    
11168                    if (orderByComparator != null) {
11169                            query = new StringBundler(6 +
11170                                            (orderByComparator.getOrderByFields().length * 6));
11171                    }
11172                    else {
11173                            query = new StringBundler(3);
11174                    }
11175    
11176                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11177    
11178                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11179    
11180                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11181    
11182                    boolean bindDisplayDate = false;
11183    
11184                    if (displayDate == null) {
11185                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11186                    }
11187                    else {
11188                            bindDisplayDate = true;
11189    
11190                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11191                    }
11192    
11193                    if (orderByComparator != null) {
11194                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11195    
11196                            if (orderByConditionFields.length > 0) {
11197                                    query.append(WHERE_AND);
11198                            }
11199    
11200                            for (int i = 0; i < orderByConditionFields.length; i++) {
11201                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11202                                    query.append(orderByConditionFields[i]);
11203    
11204                                    if ((i + 1) < orderByConditionFields.length) {
11205                                            if (orderByComparator.isAscending() ^ previous) {
11206                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11207                                            }
11208                                            else {
11209                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11210                                            }
11211                                    }
11212                                    else {
11213                                            if (orderByComparator.isAscending() ^ previous) {
11214                                                    query.append(WHERE_GREATER_THAN);
11215                                            }
11216                                            else {
11217                                                    query.append(WHERE_LESSER_THAN);
11218                                            }
11219                                    }
11220                            }
11221    
11222                            query.append(ORDER_BY_CLAUSE);
11223    
11224                            String[] orderByFields = orderByComparator.getOrderByFields();
11225    
11226                            for (int i = 0; i < orderByFields.length; i++) {
11227                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11228                                    query.append(orderByFields[i]);
11229    
11230                                    if ((i + 1) < orderByFields.length) {
11231                                            if (orderByComparator.isAscending() ^ previous) {
11232                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11233                                            }
11234                                            else {
11235                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11236                                            }
11237                                    }
11238                                    else {
11239                                            if (orderByComparator.isAscending() ^ previous) {
11240                                                    query.append(ORDER_BY_ASC);
11241                                            }
11242                                            else {
11243                                                    query.append(ORDER_BY_DESC);
11244                                            }
11245                                    }
11246                            }
11247                    }
11248                    else {
11249                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11250                    }
11251    
11252                    String sql = query.toString();
11253    
11254                    Query q = session.createQuery(sql);
11255    
11256                    q.setFirstResult(0);
11257                    q.setMaxResults(2);
11258    
11259                    QueryPos qPos = QueryPos.getInstance(q);
11260    
11261                    qPos.add(groupId);
11262    
11263                    qPos.add(userId);
11264    
11265                    if (bindDisplayDate) {
11266                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11267                    }
11268    
11269                    if (orderByComparator != null) {
11270                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11271    
11272                            for (Object value : values) {
11273                                    qPos.add(value);
11274                            }
11275                    }
11276    
11277                    List<BlogsEntry> list = q.list();
11278    
11279                    if (list.size() == 2) {
11280                            return list.get(1);
11281                    }
11282                    else {
11283                            return null;
11284                    }
11285            }
11286    
11287            /**
11288             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11289             *
11290             * @param groupId the group ID
11291             * @param userId the user ID
11292             * @param displayDate the display date
11293             * @return the matching blogs entries that the user has permission to view
11294             * @throws SystemException if a system exception occurred
11295             */
11296            @Override
11297            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11298                    Date displayDate) throws SystemException {
11299                    return filterFindByG_U_LtD(groupId, userId, displayDate,
11300                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11301            }
11302    
11303            /**
11304             * 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;.
11305             *
11306             * <p>
11307             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11308             * </p>
11309             *
11310             * @param groupId the group ID
11311             * @param userId the user ID
11312             * @param displayDate the display date
11313             * @param start the lower bound of the range of blogs entries
11314             * @param end the upper bound of the range of blogs entries (not inclusive)
11315             * @return the range of matching blogs entries that the user has permission to view
11316             * @throws SystemException if a system exception occurred
11317             */
11318            @Override
11319            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11320                    Date displayDate, int start, int end) throws SystemException {
11321                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
11322                            null);
11323            }
11324    
11325            /**
11326             * 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;.
11327             *
11328             * <p>
11329             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11330             * </p>
11331             *
11332             * @param groupId the group ID
11333             * @param userId the user ID
11334             * @param displayDate the display date
11335             * @param start the lower bound of the range of blogs entries
11336             * @param end the upper bound of the range of blogs entries (not inclusive)
11337             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11338             * @return the ordered range of matching blogs entries that the user has permission to view
11339             * @throws SystemException if a system exception occurred
11340             */
11341            @Override
11342            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
11343                    Date displayDate, int start, int end,
11344                    OrderByComparator orderByComparator) throws SystemException {
11345                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11346                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
11347                                    orderByComparator);
11348                    }
11349    
11350                    StringBundler query = null;
11351    
11352                    if (orderByComparator != null) {
11353                            query = new StringBundler(5 +
11354                                            (orderByComparator.getOrderByFields().length * 3));
11355                    }
11356                    else {
11357                            query = new StringBundler(5);
11358                    }
11359    
11360                    if (getDB().isSupportsInlineDistinct()) {
11361                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11362                    }
11363                    else {
11364                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11365                    }
11366    
11367                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11368    
11369                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11370    
11371                    boolean bindDisplayDate = false;
11372    
11373                    if (displayDate == null) {
11374                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11375                    }
11376                    else {
11377                            bindDisplayDate = true;
11378    
11379                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11380                    }
11381    
11382                    if (!getDB().isSupportsInlineDistinct()) {
11383                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11384                    }
11385    
11386                    if (orderByComparator != null) {
11387                            if (getDB().isSupportsInlineDistinct()) {
11388                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11389                                            orderByComparator, true);
11390                            }
11391                            else {
11392                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11393                                            orderByComparator, true);
11394                            }
11395                    }
11396                    else {
11397                            if (getDB().isSupportsInlineDistinct()) {
11398                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11399                            }
11400                            else {
11401                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11402                            }
11403                    }
11404    
11405                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11406                                    BlogsEntry.class.getName(),
11407                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11408    
11409                    Session session = null;
11410    
11411                    try {
11412                            session = openSession();
11413    
11414                            SQLQuery q = session.createSQLQuery(sql);
11415    
11416                            if (getDB().isSupportsInlineDistinct()) {
11417                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11418                            }
11419                            else {
11420                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11421                            }
11422    
11423                            QueryPos qPos = QueryPos.getInstance(q);
11424    
11425                            qPos.add(groupId);
11426    
11427                            qPos.add(userId);
11428    
11429                            if (bindDisplayDate) {
11430                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11431                            }
11432    
11433                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11434                    }
11435                    catch (Exception e) {
11436                            throw processException(e);
11437                    }
11438                    finally {
11439                            closeSession(session);
11440                    }
11441            }
11442    
11443            /**
11444             * 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;.
11445             *
11446             * @param entryId the primary key of the current blogs entry
11447             * @param groupId the group ID
11448             * @param userId the user ID
11449             * @param displayDate the display date
11450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11451             * @return the previous, current, and next blogs entry
11452             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11453             * @throws SystemException if a system exception occurred
11454             */
11455            @Override
11456            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
11457                    long groupId, long userId, Date displayDate,
11458                    OrderByComparator orderByComparator)
11459                    throws NoSuchEntryException, SystemException {
11460                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11461                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
11462                                    displayDate, orderByComparator);
11463                    }
11464    
11465                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11466    
11467                    Session session = null;
11468    
11469                    try {
11470                            session = openSession();
11471    
11472                            BlogsEntry[] array = new BlogsEntryImpl[3];
11473    
11474                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11475                                            groupId, userId, displayDate, orderByComparator, true);
11476    
11477                            array[1] = blogsEntry;
11478    
11479                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
11480                                            groupId, userId, displayDate, orderByComparator, false);
11481    
11482                            return array;
11483                    }
11484                    catch (Exception e) {
11485                            throw processException(e);
11486                    }
11487                    finally {
11488                            closeSession(session);
11489                    }
11490            }
11491    
11492            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
11493                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
11494                    OrderByComparator orderByComparator, boolean previous) {
11495                    StringBundler query = null;
11496    
11497                    if (orderByComparator != null) {
11498                            query = new StringBundler(6 +
11499                                            (orderByComparator.getOrderByFields().length * 6));
11500                    }
11501                    else {
11502                            query = new StringBundler(3);
11503                    }
11504    
11505                    if (getDB().isSupportsInlineDistinct()) {
11506                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11507                    }
11508                    else {
11509                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11510                    }
11511    
11512                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11513    
11514                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11515    
11516                    boolean bindDisplayDate = false;
11517    
11518                    if (displayDate == null) {
11519                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11520                    }
11521                    else {
11522                            bindDisplayDate = true;
11523    
11524                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11525                    }
11526    
11527                    if (!getDB().isSupportsInlineDistinct()) {
11528                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11529                    }
11530    
11531                    if (orderByComparator != null) {
11532                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11533    
11534                            if (orderByConditionFields.length > 0) {
11535                                    query.append(WHERE_AND);
11536                            }
11537    
11538                            for (int i = 0; i < orderByConditionFields.length; i++) {
11539                                    if (getDB().isSupportsInlineDistinct()) {
11540                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11541                                    }
11542                                    else {
11543                                            query.append(_ORDER_BY_ENTITY_TABLE);
11544                                    }
11545    
11546                                    query.append(orderByConditionFields[i]);
11547    
11548                                    if ((i + 1) < orderByConditionFields.length) {
11549                                            if (orderByComparator.isAscending() ^ previous) {
11550                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11551                                            }
11552                                            else {
11553                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11554                                            }
11555                                    }
11556                                    else {
11557                                            if (orderByComparator.isAscending() ^ previous) {
11558                                                    query.append(WHERE_GREATER_THAN);
11559                                            }
11560                                            else {
11561                                                    query.append(WHERE_LESSER_THAN);
11562                                            }
11563                                    }
11564                            }
11565    
11566                            query.append(ORDER_BY_CLAUSE);
11567    
11568                            String[] orderByFields = orderByComparator.getOrderByFields();
11569    
11570                            for (int i = 0; i < orderByFields.length; i++) {
11571                                    if (getDB().isSupportsInlineDistinct()) {
11572                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11573                                    }
11574                                    else {
11575                                            query.append(_ORDER_BY_ENTITY_TABLE);
11576                                    }
11577    
11578                                    query.append(orderByFields[i]);
11579    
11580                                    if ((i + 1) < orderByFields.length) {
11581                                            if (orderByComparator.isAscending() ^ previous) {
11582                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11583                                            }
11584                                            else {
11585                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11586                                            }
11587                                    }
11588                                    else {
11589                                            if (orderByComparator.isAscending() ^ previous) {
11590                                                    query.append(ORDER_BY_ASC);
11591                                            }
11592                                            else {
11593                                                    query.append(ORDER_BY_DESC);
11594                                            }
11595                                    }
11596                            }
11597                    }
11598                    else {
11599                            if (getDB().isSupportsInlineDistinct()) {
11600                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11601                            }
11602                            else {
11603                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11604                            }
11605                    }
11606    
11607                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11608                                    BlogsEntry.class.getName(),
11609                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11610    
11611                    SQLQuery q = session.createSQLQuery(sql);
11612    
11613                    q.setFirstResult(0);
11614                    q.setMaxResults(2);
11615    
11616                    if (getDB().isSupportsInlineDistinct()) {
11617                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11618                    }
11619                    else {
11620                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11621                    }
11622    
11623                    QueryPos qPos = QueryPos.getInstance(q);
11624    
11625                    qPos.add(groupId);
11626    
11627                    qPos.add(userId);
11628    
11629                    if (bindDisplayDate) {
11630                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11631                    }
11632    
11633                    if (orderByComparator != null) {
11634                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11635    
11636                            for (Object value : values) {
11637                                    qPos.add(value);
11638                            }
11639                    }
11640    
11641                    List<BlogsEntry> list = q.list();
11642    
11643                    if (list.size() == 2) {
11644                            return list.get(1);
11645                    }
11646                    else {
11647                            return null;
11648                    }
11649            }
11650    
11651            /**
11652             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
11653             *
11654             * @param groupId the group ID
11655             * @param userId the user ID
11656             * @param displayDate the display date
11657             * @throws SystemException if a system exception occurred
11658             */
11659            @Override
11660            public void removeByG_U_LtD(long groupId, long userId, Date displayDate)
11661                    throws SystemException {
11662                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
11663                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11664                            remove(blogsEntry);
11665                    }
11666            }
11667    
11668            /**
11669             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11670             *
11671             * @param groupId the group ID
11672             * @param userId the user ID
11673             * @param displayDate the display date
11674             * @return the number of matching blogs entries
11675             * @throws SystemException if a system exception occurred
11676             */
11677            @Override
11678            public int countByG_U_LtD(long groupId, long userId, Date displayDate)
11679                    throws SystemException {
11680                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
11681    
11682                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
11683    
11684                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11685                                    this);
11686    
11687                    if (count == null) {
11688                            StringBundler query = new StringBundler(4);
11689    
11690                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11691    
11692                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11693    
11694                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11695    
11696                            boolean bindDisplayDate = false;
11697    
11698                            if (displayDate == null) {
11699                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11700                            }
11701                            else {
11702                                    bindDisplayDate = true;
11703    
11704                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11705                            }
11706    
11707                            String sql = query.toString();
11708    
11709                            Session session = null;
11710    
11711                            try {
11712                                    session = openSession();
11713    
11714                                    Query q = session.createQuery(sql);
11715    
11716                                    QueryPos qPos = QueryPos.getInstance(q);
11717    
11718                                    qPos.add(groupId);
11719    
11720                                    qPos.add(userId);
11721    
11722                                    if (bindDisplayDate) {
11723                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
11724                                    }
11725    
11726                                    count = (Long)q.uniqueResult();
11727    
11728                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11729                            }
11730                            catch (Exception e) {
11731                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11732    
11733                                    throw processException(e);
11734                            }
11735                            finally {
11736                                    closeSession(session);
11737                            }
11738                    }
11739    
11740                    return count.intValue();
11741            }
11742    
11743            /**
11744             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
11745             *
11746             * @param groupId the group ID
11747             * @param userId the user ID
11748             * @param displayDate the display date
11749             * @return the number of matching blogs entries that the user has permission to view
11750             * @throws SystemException if a system exception occurred
11751             */
11752            @Override
11753            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate)
11754                    throws SystemException {
11755                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11756                            return countByG_U_LtD(groupId, userId, displayDate);
11757                    }
11758    
11759                    StringBundler query = new StringBundler(4);
11760    
11761                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11762    
11763                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
11764    
11765                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
11766    
11767                    boolean bindDisplayDate = false;
11768    
11769                    if (displayDate == null) {
11770                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
11771                    }
11772                    else {
11773                            bindDisplayDate = true;
11774    
11775                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
11776                    }
11777    
11778                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11779                                    BlogsEntry.class.getName(),
11780                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11781    
11782                    Session session = null;
11783    
11784                    try {
11785                            session = openSession();
11786    
11787                            SQLQuery q = session.createSQLQuery(sql);
11788    
11789                            q.addScalar(COUNT_COLUMN_NAME,
11790                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11791    
11792                            QueryPos qPos = QueryPos.getInstance(q);
11793    
11794                            qPos.add(groupId);
11795    
11796                            qPos.add(userId);
11797    
11798                            if (bindDisplayDate) {
11799                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
11800                            }
11801    
11802                            Long count = (Long)q.uniqueResult();
11803    
11804                            return count.intValue();
11805                    }
11806                    catch (Exception e) {
11807                            throw processException(e);
11808                    }
11809                    finally {
11810                            closeSession(session);
11811                    }
11812            }
11813    
11814            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11815            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
11816            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
11817            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
11818            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11819                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11820                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
11821                            new String[] {
11822                                    Long.class.getName(), Long.class.getName(),
11823                                    Integer.class.getName(),
11824                                    
11825                            Integer.class.getName(), Integer.class.getName(),
11826                                    OrderByComparator.class.getName()
11827                            });
11828            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
11829                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11830                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11831                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
11832                            new String[] {
11833                                    Long.class.getName(), Long.class.getName(),
11834                                    Integer.class.getName()
11835                            });
11836    
11837            /**
11838             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11839             *
11840             * @param groupId the group ID
11841             * @param userId the user ID
11842             * @param status the status
11843             * @return the matching blogs entries
11844             * @throws SystemException if a system exception occurred
11845             */
11846            @Override
11847            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status)
11848                    throws SystemException {
11849                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11850                            QueryUtil.ALL_POS, null);
11851            }
11852    
11853            /**
11854             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11855             *
11856             * <p>
11857             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.
11858             * </p>
11859             *
11860             * @param groupId the group ID
11861             * @param userId the user ID
11862             * @param status the status
11863             * @param start the lower bound of the range of blogs entries
11864             * @param end the upper bound of the range of blogs entries (not inclusive)
11865             * @return the range of matching blogs entries
11866             * @throws SystemException if a system exception occurred
11867             */
11868            @Override
11869            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11870                    int status, int start, int end) throws SystemException {
11871                    return findByG_U_NotS(groupId, userId, status, start, end, null);
11872            }
11873    
11874            /**
11875             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11876             *
11877             * <p>
11878             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11879             * </p>
11880             *
11881             * @param groupId the group ID
11882             * @param userId the user ID
11883             * @param status the status
11884             * @param start the lower bound of the range of blogs entries
11885             * @param end the upper bound of the range of blogs entries (not inclusive)
11886             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11887             * @return the ordered range of matching blogs entries
11888             * @throws SystemException if a system exception occurred
11889             */
11890            @Override
11891            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11892                    int status, int start, int end, OrderByComparator orderByComparator)
11893                    throws SystemException {
11894                    boolean pagination = true;
11895                    FinderPath finderPath = null;
11896                    Object[] finderArgs = null;
11897    
11898                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
11899                    finderArgs = new Object[] {
11900                                    groupId, userId, status,
11901                                    
11902                                    start, end, orderByComparator
11903                            };
11904    
11905                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11906                                    finderArgs, this);
11907    
11908                    if ((list != null) && !list.isEmpty()) {
11909                            for (BlogsEntry blogsEntry : list) {
11910                                    if ((groupId != blogsEntry.getGroupId()) ||
11911                                                    (userId != blogsEntry.getUserId()) ||
11912                                                    (status != blogsEntry.getStatus())) {
11913                                            list = null;
11914    
11915                                            break;
11916                                    }
11917                            }
11918                    }
11919    
11920                    if (list == null) {
11921                            StringBundler query = null;
11922    
11923                            if (orderByComparator != null) {
11924                                    query = new StringBundler(5 +
11925                                                    (orderByComparator.getOrderByFields().length * 3));
11926                            }
11927                            else {
11928                                    query = new StringBundler(5);
11929                            }
11930    
11931                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11932    
11933                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11934    
11935                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11936    
11937                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11938    
11939                            if (orderByComparator != null) {
11940                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11941                                            orderByComparator);
11942                            }
11943                            else
11944                             if (pagination) {
11945                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11946                            }
11947    
11948                            String sql = query.toString();
11949    
11950                            Session session = null;
11951    
11952                            try {
11953                                    session = openSession();
11954    
11955                                    Query q = session.createQuery(sql);
11956    
11957                                    QueryPos qPos = QueryPos.getInstance(q);
11958    
11959                                    qPos.add(groupId);
11960    
11961                                    qPos.add(userId);
11962    
11963                                    qPos.add(status);
11964    
11965                                    if (!pagination) {
11966                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11967                                                            start, end, false);
11968    
11969                                            Collections.sort(list);
11970    
11971                                            list = new UnmodifiableList<BlogsEntry>(list);
11972                                    }
11973                                    else {
11974                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11975                                                            start, end);
11976                                    }
11977    
11978                                    cacheResult(list);
11979    
11980                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11981                            }
11982                            catch (Exception e) {
11983                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11984    
11985                                    throw processException(e);
11986                            }
11987                            finally {
11988                                    closeSession(session);
11989                            }
11990                    }
11991    
11992                    return list;
11993            }
11994    
11995            /**
11996             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11997             *
11998             * @param groupId the group ID
11999             * @param userId the user ID
12000             * @param status the status
12001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12002             * @return the first matching blogs entry
12003             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12004             * @throws SystemException if a system exception occurred
12005             */
12006            @Override
12007            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
12008                    int status, OrderByComparator orderByComparator)
12009                    throws NoSuchEntryException, SystemException {
12010                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
12011                                    orderByComparator);
12012    
12013                    if (blogsEntry != null) {
12014                            return blogsEntry;
12015                    }
12016    
12017                    StringBundler msg = new StringBundler(8);
12018    
12019                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12020    
12021                    msg.append("groupId=");
12022                    msg.append(groupId);
12023    
12024                    msg.append(", userId=");
12025                    msg.append(userId);
12026    
12027                    msg.append(", status=");
12028                    msg.append(status);
12029    
12030                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12031    
12032                    throw new NoSuchEntryException(msg.toString());
12033            }
12034    
12035            /**
12036             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12037             *
12038             * @param groupId the group ID
12039             * @param userId the user ID
12040             * @param status the status
12041             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12042             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12043             * @throws SystemException if a system exception occurred
12044             */
12045            @Override
12046            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
12047                    int status, OrderByComparator orderByComparator)
12048                    throws SystemException {
12049                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
12050                                    orderByComparator);
12051    
12052                    if (!list.isEmpty()) {
12053                            return list.get(0);
12054                    }
12055    
12056                    return null;
12057            }
12058    
12059            /**
12060             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12061             *
12062             * @param groupId the group ID
12063             * @param userId the user ID
12064             * @param status the status
12065             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12066             * @return the last matching blogs entry
12067             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12068             * @throws SystemException if a system exception occurred
12069             */
12070            @Override
12071            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
12072                    int status, OrderByComparator orderByComparator)
12073                    throws NoSuchEntryException, SystemException {
12074                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
12075                                    orderByComparator);
12076    
12077                    if (blogsEntry != null) {
12078                            return blogsEntry;
12079                    }
12080    
12081                    StringBundler msg = new StringBundler(8);
12082    
12083                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12084    
12085                    msg.append("groupId=");
12086                    msg.append(groupId);
12087    
12088                    msg.append(", userId=");
12089                    msg.append(userId);
12090    
12091                    msg.append(", status=");
12092                    msg.append(status);
12093    
12094                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12095    
12096                    throw new NoSuchEntryException(msg.toString());
12097            }
12098    
12099            /**
12100             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12101             *
12102             * @param groupId the group ID
12103             * @param userId the user ID
12104             * @param status the status
12105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12106             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12107             * @throws SystemException if a system exception occurred
12108             */
12109            @Override
12110            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
12111                    int status, OrderByComparator orderByComparator)
12112                    throws SystemException {
12113                    int count = countByG_U_NotS(groupId, userId, status);
12114    
12115                    if (count == 0) {
12116                            return null;
12117                    }
12118    
12119                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
12120                                    count - 1, count, orderByComparator);
12121    
12122                    if (!list.isEmpty()) {
12123                            return list.get(0);
12124                    }
12125    
12126                    return null;
12127            }
12128    
12129            /**
12130             * 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;.
12131             *
12132             * @param entryId the primary key of the current blogs entry
12133             * @param groupId the group ID
12134             * @param userId the user ID
12135             * @param status the status
12136             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12137             * @return the previous, current, and next blogs entry
12138             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12139             * @throws SystemException if a system exception occurred
12140             */
12141            @Override
12142            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
12143                    long userId, int status, OrderByComparator orderByComparator)
12144                    throws NoSuchEntryException, SystemException {
12145                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12146    
12147                    Session session = null;
12148    
12149                    try {
12150                            session = openSession();
12151    
12152                            BlogsEntry[] array = new BlogsEntryImpl[3];
12153    
12154                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
12155                                            userId, status, orderByComparator, true);
12156    
12157                            array[1] = blogsEntry;
12158    
12159                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
12160                                            userId, status, orderByComparator, false);
12161    
12162                            return array;
12163                    }
12164                    catch (Exception e) {
12165                            throw processException(e);
12166                    }
12167                    finally {
12168                            closeSession(session);
12169                    }
12170            }
12171    
12172            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
12173                    BlogsEntry blogsEntry, long groupId, long userId, int status,
12174                    OrderByComparator orderByComparator, boolean previous) {
12175                    StringBundler query = null;
12176    
12177                    if (orderByComparator != null) {
12178                            query = new StringBundler(6 +
12179                                            (orderByComparator.getOrderByFields().length * 6));
12180                    }
12181                    else {
12182                            query = new StringBundler(3);
12183                    }
12184    
12185                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12186    
12187                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12188    
12189                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12190    
12191                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12192    
12193                    if (orderByComparator != null) {
12194                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12195    
12196                            if (orderByConditionFields.length > 0) {
12197                                    query.append(WHERE_AND);
12198                            }
12199    
12200                            for (int i = 0; i < orderByConditionFields.length; i++) {
12201                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12202                                    query.append(orderByConditionFields[i]);
12203    
12204                                    if ((i + 1) < orderByConditionFields.length) {
12205                                            if (orderByComparator.isAscending() ^ previous) {
12206                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12207                                            }
12208                                            else {
12209                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12210                                            }
12211                                    }
12212                                    else {
12213                                            if (orderByComparator.isAscending() ^ previous) {
12214                                                    query.append(WHERE_GREATER_THAN);
12215                                            }
12216                                            else {
12217                                                    query.append(WHERE_LESSER_THAN);
12218                                            }
12219                                    }
12220                            }
12221    
12222                            query.append(ORDER_BY_CLAUSE);
12223    
12224                            String[] orderByFields = orderByComparator.getOrderByFields();
12225    
12226                            for (int i = 0; i < orderByFields.length; i++) {
12227                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12228                                    query.append(orderByFields[i]);
12229    
12230                                    if ((i + 1) < orderByFields.length) {
12231                                            if (orderByComparator.isAscending() ^ previous) {
12232                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12233                                            }
12234                                            else {
12235                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12236                                            }
12237                                    }
12238                                    else {
12239                                            if (orderByComparator.isAscending() ^ previous) {
12240                                                    query.append(ORDER_BY_ASC);
12241                                            }
12242                                            else {
12243                                                    query.append(ORDER_BY_DESC);
12244                                            }
12245                                    }
12246                            }
12247                    }
12248                    else {
12249                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12250                    }
12251    
12252                    String sql = query.toString();
12253    
12254                    Query q = session.createQuery(sql);
12255    
12256                    q.setFirstResult(0);
12257                    q.setMaxResults(2);
12258    
12259                    QueryPos qPos = QueryPos.getInstance(q);
12260    
12261                    qPos.add(groupId);
12262    
12263                    qPos.add(userId);
12264    
12265                    qPos.add(status);
12266    
12267                    if (orderByComparator != null) {
12268                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12269    
12270                            for (Object value : values) {
12271                                    qPos.add(value);
12272                            }
12273                    }
12274    
12275                    List<BlogsEntry> list = q.list();
12276    
12277                    if (list.size() == 2) {
12278                            return list.get(1);
12279                    }
12280                    else {
12281                            return null;
12282                    }
12283            }
12284    
12285            /**
12286             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12287             *
12288             * @param groupId the group ID
12289             * @param userId the user ID
12290             * @param status the status
12291             * @return the matching blogs entries that the user has permission to view
12292             * @throws SystemException if a system exception occurred
12293             */
12294            @Override
12295            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12296                    int status) throws SystemException {
12297                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
12298                            QueryUtil.ALL_POS, null);
12299            }
12300    
12301            /**
12302             * 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;.
12303             *
12304             * <p>
12305             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12306             * </p>
12307             *
12308             * @param groupId the group ID
12309             * @param userId the user ID
12310             * @param status the status
12311             * @param start the lower bound of the range of blogs entries
12312             * @param end the upper bound of the range of blogs entries (not inclusive)
12313             * @return the range of matching blogs entries that the user has permission to view
12314             * @throws SystemException if a system exception occurred
12315             */
12316            @Override
12317            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12318                    int status, int start, int end) throws SystemException {
12319                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
12320            }
12321    
12322            /**
12323             * 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;.
12324             *
12325             * <p>
12326             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12327             * </p>
12328             *
12329             * @param groupId the group ID
12330             * @param userId the user ID
12331             * @param status the status
12332             * @param start the lower bound of the range of blogs entries
12333             * @param end the upper bound of the range of blogs entries (not inclusive)
12334             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12335             * @return the ordered range of matching blogs entries that the user has permission to view
12336             * @throws SystemException if a system exception occurred
12337             */
12338            @Override
12339            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
12340                    int status, int start, int end, OrderByComparator orderByComparator)
12341                    throws SystemException {
12342                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12343                            return findByG_U_NotS(groupId, userId, status, start, end,
12344                                    orderByComparator);
12345                    }
12346    
12347                    StringBundler query = null;
12348    
12349                    if (orderByComparator != null) {
12350                            query = new StringBundler(5 +
12351                                            (orderByComparator.getOrderByFields().length * 3));
12352                    }
12353                    else {
12354                            query = new StringBundler(5);
12355                    }
12356    
12357                    if (getDB().isSupportsInlineDistinct()) {
12358                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12359                    }
12360                    else {
12361                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12362                    }
12363    
12364                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12365    
12366                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12367    
12368                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12369    
12370                    if (!getDB().isSupportsInlineDistinct()) {
12371                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12372                    }
12373    
12374                    if (orderByComparator != null) {
12375                            if (getDB().isSupportsInlineDistinct()) {
12376                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12377                                            orderByComparator, true);
12378                            }
12379                            else {
12380                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12381                                            orderByComparator, true);
12382                            }
12383                    }
12384                    else {
12385                            if (getDB().isSupportsInlineDistinct()) {
12386                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12387                            }
12388                            else {
12389                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12390                            }
12391                    }
12392    
12393                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12394                                    BlogsEntry.class.getName(),
12395                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12396    
12397                    Session session = null;
12398    
12399                    try {
12400                            session = openSession();
12401    
12402                            SQLQuery q = session.createSQLQuery(sql);
12403    
12404                            if (getDB().isSupportsInlineDistinct()) {
12405                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12406                            }
12407                            else {
12408                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12409                            }
12410    
12411                            QueryPos qPos = QueryPos.getInstance(q);
12412    
12413                            qPos.add(groupId);
12414    
12415                            qPos.add(userId);
12416    
12417                            qPos.add(status);
12418    
12419                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12420                    }
12421                    catch (Exception e) {
12422                            throw processException(e);
12423                    }
12424                    finally {
12425                            closeSession(session);
12426                    }
12427            }
12428    
12429            /**
12430             * 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;.
12431             *
12432             * @param entryId the primary key of the current blogs entry
12433             * @param groupId the group ID
12434             * @param userId the user ID
12435             * @param status the status
12436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12437             * @return the previous, current, and next blogs entry
12438             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12439             * @throws SystemException if a system exception occurred
12440             */
12441            @Override
12442            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
12443                    long groupId, long userId, int status,
12444                    OrderByComparator orderByComparator)
12445                    throws NoSuchEntryException, SystemException {
12446                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12447                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
12448                                    orderByComparator);
12449                    }
12450    
12451                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12452    
12453                    Session session = null;
12454    
12455                    try {
12456                            session = openSession();
12457    
12458                            BlogsEntry[] array = new BlogsEntryImpl[3];
12459    
12460                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12461                                            groupId, userId, status, orderByComparator, true);
12462    
12463                            array[1] = blogsEntry;
12464    
12465                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
12466                                            groupId, userId, status, orderByComparator, false);
12467    
12468                            return array;
12469                    }
12470                    catch (Exception e) {
12471                            throw processException(e);
12472                    }
12473                    finally {
12474                            closeSession(session);
12475                    }
12476            }
12477    
12478            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
12479                    BlogsEntry blogsEntry, long groupId, long userId, int status,
12480                    OrderByComparator orderByComparator, boolean previous) {
12481                    StringBundler query = null;
12482    
12483                    if (orderByComparator != null) {
12484                            query = new StringBundler(6 +
12485                                            (orderByComparator.getOrderByFields().length * 6));
12486                    }
12487                    else {
12488                            query = new StringBundler(3);
12489                    }
12490    
12491                    if (getDB().isSupportsInlineDistinct()) {
12492                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12493                    }
12494                    else {
12495                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12496                    }
12497    
12498                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12499    
12500                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12501    
12502                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12503    
12504                    if (!getDB().isSupportsInlineDistinct()) {
12505                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12506                    }
12507    
12508                    if (orderByComparator != null) {
12509                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12510    
12511                            if (orderByConditionFields.length > 0) {
12512                                    query.append(WHERE_AND);
12513                            }
12514    
12515                            for (int i = 0; i < orderByConditionFields.length; i++) {
12516                                    if (getDB().isSupportsInlineDistinct()) {
12517                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12518                                    }
12519                                    else {
12520                                            query.append(_ORDER_BY_ENTITY_TABLE);
12521                                    }
12522    
12523                                    query.append(orderByConditionFields[i]);
12524    
12525                                    if ((i + 1) < orderByConditionFields.length) {
12526                                            if (orderByComparator.isAscending() ^ previous) {
12527                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12528                                            }
12529                                            else {
12530                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12531                                            }
12532                                    }
12533                                    else {
12534                                            if (orderByComparator.isAscending() ^ previous) {
12535                                                    query.append(WHERE_GREATER_THAN);
12536                                            }
12537                                            else {
12538                                                    query.append(WHERE_LESSER_THAN);
12539                                            }
12540                                    }
12541                            }
12542    
12543                            query.append(ORDER_BY_CLAUSE);
12544    
12545                            String[] orderByFields = orderByComparator.getOrderByFields();
12546    
12547                            for (int i = 0; i < orderByFields.length; i++) {
12548                                    if (getDB().isSupportsInlineDistinct()) {
12549                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12550                                    }
12551                                    else {
12552                                            query.append(_ORDER_BY_ENTITY_TABLE);
12553                                    }
12554    
12555                                    query.append(orderByFields[i]);
12556    
12557                                    if ((i + 1) < orderByFields.length) {
12558                                            if (orderByComparator.isAscending() ^ previous) {
12559                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12560                                            }
12561                                            else {
12562                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12563                                            }
12564                                    }
12565                                    else {
12566                                            if (orderByComparator.isAscending() ^ previous) {
12567                                                    query.append(ORDER_BY_ASC);
12568                                            }
12569                                            else {
12570                                                    query.append(ORDER_BY_DESC);
12571                                            }
12572                                    }
12573                            }
12574                    }
12575                    else {
12576                            if (getDB().isSupportsInlineDistinct()) {
12577                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12578                            }
12579                            else {
12580                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12581                            }
12582                    }
12583    
12584                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12585                                    BlogsEntry.class.getName(),
12586                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12587    
12588                    SQLQuery q = session.createSQLQuery(sql);
12589    
12590                    q.setFirstResult(0);
12591                    q.setMaxResults(2);
12592    
12593                    if (getDB().isSupportsInlineDistinct()) {
12594                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12595                    }
12596                    else {
12597                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12598                    }
12599    
12600                    QueryPos qPos = QueryPos.getInstance(q);
12601    
12602                    qPos.add(groupId);
12603    
12604                    qPos.add(userId);
12605    
12606                    qPos.add(status);
12607    
12608                    if (orderByComparator != null) {
12609                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12610    
12611                            for (Object value : values) {
12612                                    qPos.add(value);
12613                            }
12614                    }
12615    
12616                    List<BlogsEntry> list = q.list();
12617    
12618                    if (list.size() == 2) {
12619                            return list.get(1);
12620                    }
12621                    else {
12622                            return null;
12623                    }
12624            }
12625    
12626            /**
12627             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
12628             *
12629             * @param groupId the group ID
12630             * @param userId the user ID
12631             * @param status the status
12632             * @throws SystemException if a system exception occurred
12633             */
12634            @Override
12635            public void removeByG_U_NotS(long groupId, long userId, int status)
12636                    throws SystemException {
12637                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
12638                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12639                            remove(blogsEntry);
12640                    }
12641            }
12642    
12643            /**
12644             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12645             *
12646             * @param groupId the group ID
12647             * @param userId the user ID
12648             * @param status the status
12649             * @return the number of matching blogs entries
12650             * @throws SystemException if a system exception occurred
12651             */
12652            @Override
12653            public int countByG_U_NotS(long groupId, long userId, int status)
12654                    throws SystemException {
12655                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
12656    
12657                    Object[] finderArgs = new Object[] { groupId, userId, status };
12658    
12659                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12660                                    this);
12661    
12662                    if (count == null) {
12663                            StringBundler query = new StringBundler(4);
12664    
12665                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12666    
12667                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12668    
12669                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12670    
12671                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12672    
12673                            String sql = query.toString();
12674    
12675                            Session session = null;
12676    
12677                            try {
12678                                    session = openSession();
12679    
12680                                    Query q = session.createQuery(sql);
12681    
12682                                    QueryPos qPos = QueryPos.getInstance(q);
12683    
12684                                    qPos.add(groupId);
12685    
12686                                    qPos.add(userId);
12687    
12688                                    qPos.add(status);
12689    
12690                                    count = (Long)q.uniqueResult();
12691    
12692                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12693                            }
12694                            catch (Exception e) {
12695                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12696    
12697                                    throw processException(e);
12698                            }
12699                            finally {
12700                                    closeSession(session);
12701                            }
12702                    }
12703    
12704                    return count.intValue();
12705            }
12706    
12707            /**
12708             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12709             *
12710             * @param groupId the group ID
12711             * @param userId the user ID
12712             * @param status the status
12713             * @return the number of matching blogs entries that the user has permission to view
12714             * @throws SystemException if a system exception occurred
12715             */
12716            @Override
12717            public int filterCountByG_U_NotS(long groupId, long userId, int status)
12718                    throws SystemException {
12719                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12720                            return countByG_U_NotS(groupId, userId, status);
12721                    }
12722    
12723                    StringBundler query = new StringBundler(4);
12724    
12725                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12726    
12727                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12728    
12729                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12730    
12731                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12732    
12733                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12734                                    BlogsEntry.class.getName(),
12735                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12736    
12737                    Session session = null;
12738    
12739                    try {
12740                            session = openSession();
12741    
12742                            SQLQuery q = session.createSQLQuery(sql);
12743    
12744                            q.addScalar(COUNT_COLUMN_NAME,
12745                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12746    
12747                            QueryPos qPos = QueryPos.getInstance(q);
12748    
12749                            qPos.add(groupId);
12750    
12751                            qPos.add(userId);
12752    
12753                            qPos.add(status);
12754    
12755                            Long count = (Long)q.uniqueResult();
12756    
12757                            return count.intValue();
12758                    }
12759                    catch (Exception e) {
12760                            throw processException(e);
12761                    }
12762                    finally {
12763                            closeSession(session);
12764                    }
12765            }
12766    
12767            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12768            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
12769            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
12770            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12771                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12772                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
12773                            new String[] {
12774                                    Long.class.getName(), Long.class.getName(),
12775                                    Integer.class.getName(),
12776                                    
12777                            Integer.class.getName(), Integer.class.getName(),
12778                                    OrderByComparator.class.getName()
12779                            });
12780            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12781                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12782                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
12783                            new String[] {
12784                                    Long.class.getName(), Long.class.getName(),
12785                                    Integer.class.getName()
12786                            },
12787                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
12788                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
12789                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
12790                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
12791                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
12792            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12793                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12794                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
12795                            new String[] {
12796                                    Long.class.getName(), Long.class.getName(),
12797                                    Integer.class.getName()
12798                            });
12799    
12800            /**
12801             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12802             *
12803             * @param groupId the group ID
12804             * @param userId the user ID
12805             * @param status the status
12806             * @return the matching blogs entries
12807             * @throws SystemException if a system exception occurred
12808             */
12809            @Override
12810            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status)
12811                    throws SystemException {
12812                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
12813                            QueryUtil.ALL_POS, null);
12814            }
12815    
12816            /**
12817             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12818             *
12819             * <p>
12820             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12821             * </p>
12822             *
12823             * @param groupId the group ID
12824             * @param userId the user ID
12825             * @param status the status
12826             * @param start the lower bound of the range of blogs entries
12827             * @param end the upper bound of the range of blogs entries (not inclusive)
12828             * @return the range of matching blogs entries
12829             * @throws SystemException if a system exception occurred
12830             */
12831            @Override
12832            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12833                    int start, int end) throws SystemException {
12834                    return findByG_U_S(groupId, userId, status, start, end, null);
12835            }
12836    
12837            /**
12838             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
12839             *
12840             * <p>
12841             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12842             * </p>
12843             *
12844             * @param groupId the group ID
12845             * @param userId the user ID
12846             * @param status the status
12847             * @param start the lower bound of the range of blogs entries
12848             * @param end the upper bound of the range of blogs entries (not inclusive)
12849             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12850             * @return the ordered range of matching blogs entries
12851             * @throws SystemException if a system exception occurred
12852             */
12853            @Override
12854            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
12855                    int start, int end, OrderByComparator orderByComparator)
12856                    throws SystemException {
12857                    boolean pagination = true;
12858                    FinderPath finderPath = null;
12859                    Object[] finderArgs = null;
12860    
12861                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12862                                    (orderByComparator == null)) {
12863                            pagination = false;
12864                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
12865                            finderArgs = new Object[] { groupId, userId, status };
12866                    }
12867                    else {
12868                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
12869                            finderArgs = new Object[] {
12870                                            groupId, userId, status,
12871                                            
12872                                            start, end, orderByComparator
12873                                    };
12874                    }
12875    
12876                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
12877                                    finderArgs, this);
12878    
12879                    if ((list != null) && !list.isEmpty()) {
12880                            for (BlogsEntry blogsEntry : list) {
12881                                    if ((groupId != blogsEntry.getGroupId()) ||
12882                                                    (userId != blogsEntry.getUserId()) ||
12883                                                    (status != blogsEntry.getStatus())) {
12884                                            list = null;
12885    
12886                                            break;
12887                                    }
12888                            }
12889                    }
12890    
12891                    if (list == null) {
12892                            StringBundler query = null;
12893    
12894                            if (orderByComparator != null) {
12895                                    query = new StringBundler(5 +
12896                                                    (orderByComparator.getOrderByFields().length * 3));
12897                            }
12898                            else {
12899                                    query = new StringBundler(5);
12900                            }
12901    
12902                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12903    
12904                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
12905    
12906                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
12907    
12908                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
12909    
12910                            if (orderByComparator != null) {
12911                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12912                                            orderByComparator);
12913                            }
12914                            else
12915                             if (pagination) {
12916                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12917                            }
12918    
12919                            String sql = query.toString();
12920    
12921                            Session session = null;
12922    
12923                            try {
12924                                    session = openSession();
12925    
12926                                    Query q = session.createQuery(sql);
12927    
12928                                    QueryPos qPos = QueryPos.getInstance(q);
12929    
12930                                    qPos.add(groupId);
12931    
12932                                    qPos.add(userId);
12933    
12934                                    qPos.add(status);
12935    
12936                                    if (!pagination) {
12937                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12938                                                            start, end, false);
12939    
12940                                            Collections.sort(list);
12941    
12942                                            list = new UnmodifiableList<BlogsEntry>(list);
12943                                    }
12944                                    else {
12945                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12946                                                            start, end);
12947                                    }
12948    
12949                                    cacheResult(list);
12950    
12951                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12952                            }
12953                            catch (Exception e) {
12954                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12955    
12956                                    throw processException(e);
12957                            }
12958                            finally {
12959                                    closeSession(session);
12960                            }
12961                    }
12962    
12963                    return list;
12964            }
12965    
12966            /**
12967             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
12968             *
12969             * @param groupId the group ID
12970             * @param userId the user ID
12971             * @param status the status
12972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12973             * @return the first matching blogs entry
12974             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12975             * @throws SystemException if a system exception occurred
12976             */
12977            @Override
12978            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
12979                    OrderByComparator orderByComparator)
12980                    throws NoSuchEntryException, SystemException {
12981                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
12982                                    orderByComparator);
12983    
12984                    if (blogsEntry != null) {
12985                            return blogsEntry;
12986                    }
12987    
12988                    StringBundler msg = new StringBundler(8);
12989    
12990                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12991    
12992                    msg.append("groupId=");
12993                    msg.append(groupId);
12994    
12995                    msg.append(", userId=");
12996                    msg.append(userId);
12997    
12998                    msg.append(", status=");
12999                    msg.append(status);
13000    
13001                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13002    
13003                    throw new NoSuchEntryException(msg.toString());
13004            }
13005    
13006            /**
13007             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13008             *
13009             * @param groupId the group ID
13010             * @param userId the user ID
13011             * @param status the status
13012             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13013             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13014             * @throws SystemException if a system exception occurred
13015             */
13016            @Override
13017            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
13018                    OrderByComparator orderByComparator) throws SystemException {
13019                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
13020                                    orderByComparator);
13021    
13022                    if (!list.isEmpty()) {
13023                            return list.get(0);
13024                    }
13025    
13026                    return null;
13027            }
13028    
13029            /**
13030             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13031             *
13032             * @param groupId the group ID
13033             * @param userId the user ID
13034             * @param status the status
13035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13036             * @return the last matching blogs entry
13037             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13038             * @throws SystemException if a system exception occurred
13039             */
13040            @Override
13041            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
13042                    OrderByComparator orderByComparator)
13043                    throws NoSuchEntryException, SystemException {
13044                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
13045                                    orderByComparator);
13046    
13047                    if (blogsEntry != null) {
13048                            return blogsEntry;
13049                    }
13050    
13051                    StringBundler msg = new StringBundler(8);
13052    
13053                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13054    
13055                    msg.append("groupId=");
13056                    msg.append(groupId);
13057    
13058                    msg.append(", userId=");
13059                    msg.append(userId);
13060    
13061                    msg.append(", status=");
13062                    msg.append(status);
13063    
13064                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13065    
13066                    throw new NoSuchEntryException(msg.toString());
13067            }
13068    
13069            /**
13070             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13071             *
13072             * @param groupId the group ID
13073             * @param userId the user ID
13074             * @param status the status
13075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13076             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13077             * @throws SystemException if a system exception occurred
13078             */
13079            @Override
13080            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
13081                    OrderByComparator orderByComparator) throws SystemException {
13082                    int count = countByG_U_S(groupId, userId, status);
13083    
13084                    if (count == 0) {
13085                            return null;
13086                    }
13087    
13088                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
13089                                    count, orderByComparator);
13090    
13091                    if (!list.isEmpty()) {
13092                            return list.get(0);
13093                    }
13094    
13095                    return null;
13096            }
13097    
13098            /**
13099             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
13100             *
13101             * @param entryId the primary key of the current blogs entry
13102             * @param groupId the group ID
13103             * @param userId the user ID
13104             * @param status the status
13105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13106             * @return the previous, current, and next blogs entry
13107             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13108             * @throws SystemException if a system exception occurred
13109             */
13110            @Override
13111            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
13112                    long userId, int status, OrderByComparator orderByComparator)
13113                    throws NoSuchEntryException, SystemException {
13114                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13115    
13116                    Session session = null;
13117    
13118                    try {
13119                            session = openSession();
13120    
13121                            BlogsEntry[] array = new BlogsEntryImpl[3];
13122    
13123                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
13124                                            userId, status, orderByComparator, true);
13125    
13126                            array[1] = blogsEntry;
13127    
13128                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
13129                                            userId, status, orderByComparator, false);
13130    
13131                            return array;
13132                    }
13133                    catch (Exception e) {
13134                            throw processException(e);
13135                    }
13136                    finally {
13137                            closeSession(session);
13138                    }
13139            }
13140    
13141            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
13142                    BlogsEntry blogsEntry, long groupId, long userId, int status,
13143                    OrderByComparator orderByComparator, boolean previous) {
13144                    StringBundler query = null;
13145    
13146                    if (orderByComparator != null) {
13147                            query = new StringBundler(6 +
13148                                            (orderByComparator.getOrderByFields().length * 6));
13149                    }
13150                    else {
13151                            query = new StringBundler(3);
13152                    }
13153    
13154                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13155    
13156                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13157    
13158                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13159    
13160                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13161    
13162                    if (orderByComparator != null) {
13163                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13164    
13165                            if (orderByConditionFields.length > 0) {
13166                                    query.append(WHERE_AND);
13167                            }
13168    
13169                            for (int i = 0; i < orderByConditionFields.length; i++) {
13170                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13171                                    query.append(orderByConditionFields[i]);
13172    
13173                                    if ((i + 1) < orderByConditionFields.length) {
13174                                            if (orderByComparator.isAscending() ^ previous) {
13175                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13176                                            }
13177                                            else {
13178                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13179                                            }
13180                                    }
13181                                    else {
13182                                            if (orderByComparator.isAscending() ^ previous) {
13183                                                    query.append(WHERE_GREATER_THAN);
13184                                            }
13185                                            else {
13186                                                    query.append(WHERE_LESSER_THAN);
13187                                            }
13188                                    }
13189                            }
13190    
13191                            query.append(ORDER_BY_CLAUSE);
13192    
13193                            String[] orderByFields = orderByComparator.getOrderByFields();
13194    
13195                            for (int i = 0; i < orderByFields.length; i++) {
13196                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13197                                    query.append(orderByFields[i]);
13198    
13199                                    if ((i + 1) < orderByFields.length) {
13200                                            if (orderByComparator.isAscending() ^ previous) {
13201                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13202                                            }
13203                                            else {
13204                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13205                                            }
13206                                    }
13207                                    else {
13208                                            if (orderByComparator.isAscending() ^ previous) {
13209                                                    query.append(ORDER_BY_ASC);
13210                                            }
13211                                            else {
13212                                                    query.append(ORDER_BY_DESC);
13213                                            }
13214                                    }
13215                            }
13216                    }
13217                    else {
13218                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13219                    }
13220    
13221                    String sql = query.toString();
13222    
13223                    Query q = session.createQuery(sql);
13224    
13225                    q.setFirstResult(0);
13226                    q.setMaxResults(2);
13227    
13228                    QueryPos qPos = QueryPos.getInstance(q);
13229    
13230                    qPos.add(groupId);
13231    
13232                    qPos.add(userId);
13233    
13234                    qPos.add(status);
13235    
13236                    if (orderByComparator != null) {
13237                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13238    
13239                            for (Object value : values) {
13240                                    qPos.add(value);
13241                            }
13242                    }
13243    
13244                    List<BlogsEntry> list = q.list();
13245    
13246                    if (list.size() == 2) {
13247                            return list.get(1);
13248                    }
13249                    else {
13250                            return null;
13251                    }
13252            }
13253    
13254            /**
13255             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
13256             *
13257             * @param groupId the group ID
13258             * @param userId the user ID
13259             * @param status the status
13260             * @return the matching blogs entries that the user has permission to view
13261             * @throws SystemException if a system exception occurred
13262             */
13263            @Override
13264            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
13265                    int status) throws SystemException {
13266                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
13267                            QueryUtil.ALL_POS, null);
13268            }
13269    
13270            /**
13271             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
13272             *
13273             * <p>
13274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13275             * </p>
13276             *
13277             * @param groupId the group ID
13278             * @param userId the user ID
13279             * @param status the status
13280             * @param start the lower bound of the range of blogs entries
13281             * @param end the upper bound of the range of blogs entries (not inclusive)
13282             * @return the range of matching blogs entries that the user has permission to view
13283             * @throws SystemException if a system exception occurred
13284             */
13285            @Override
13286            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
13287                    int status, int start, int end) throws SystemException {
13288                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
13289            }
13290    
13291            /**
13292             * 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;.
13293             *
13294             * <p>
13295             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13296             * </p>
13297             *
13298             * @param groupId the group ID
13299             * @param userId the user ID
13300             * @param status the status
13301             * @param start the lower bound of the range of blogs entries
13302             * @param end the upper bound of the range of blogs entries (not inclusive)
13303             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13304             * @return the ordered range of matching blogs entries that the user has permission to view
13305             * @throws SystemException if a system exception occurred
13306             */
13307            @Override
13308            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
13309                    int status, int start, int end, OrderByComparator orderByComparator)
13310                    throws SystemException {
13311                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13312                            return findByG_U_S(groupId, userId, status, start, end,
13313                                    orderByComparator);
13314                    }
13315    
13316                    StringBundler query = null;
13317    
13318                    if (orderByComparator != null) {
13319                            query = new StringBundler(5 +
13320                                            (orderByComparator.getOrderByFields().length * 3));
13321                    }
13322                    else {
13323                            query = new StringBundler(5);
13324                    }
13325    
13326                    if (getDB().isSupportsInlineDistinct()) {
13327                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13328                    }
13329                    else {
13330                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13331                    }
13332    
13333                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13334    
13335                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13336    
13337                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13338    
13339                    if (!getDB().isSupportsInlineDistinct()) {
13340                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13341                    }
13342    
13343                    if (orderByComparator != null) {
13344                            if (getDB().isSupportsInlineDistinct()) {
13345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13346                                            orderByComparator, true);
13347                            }
13348                            else {
13349                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13350                                            orderByComparator, true);
13351                            }
13352                    }
13353                    else {
13354                            if (getDB().isSupportsInlineDistinct()) {
13355                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13356                            }
13357                            else {
13358                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13359                            }
13360                    }
13361    
13362                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13363                                    BlogsEntry.class.getName(),
13364                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13365    
13366                    Session session = null;
13367    
13368                    try {
13369                            session = openSession();
13370    
13371                            SQLQuery q = session.createSQLQuery(sql);
13372    
13373                            if (getDB().isSupportsInlineDistinct()) {
13374                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13375                            }
13376                            else {
13377                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13378                            }
13379    
13380                            QueryPos qPos = QueryPos.getInstance(q);
13381    
13382                            qPos.add(groupId);
13383    
13384                            qPos.add(userId);
13385    
13386                            qPos.add(status);
13387    
13388                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13389                    }
13390                    catch (Exception e) {
13391                            throw processException(e);
13392                    }
13393                    finally {
13394                            closeSession(session);
13395                    }
13396            }
13397    
13398            /**
13399             * 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;.
13400             *
13401             * @param entryId the primary key of the current blogs entry
13402             * @param groupId the group ID
13403             * @param userId the user ID
13404             * @param status the status
13405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13406             * @return the previous, current, and next blogs entry
13407             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13408             * @throws SystemException if a system exception occurred
13409             */
13410            @Override
13411            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
13412                    long groupId, long userId, int status,
13413                    OrderByComparator orderByComparator)
13414                    throws NoSuchEntryException, SystemException {
13415                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13416                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
13417                                    orderByComparator);
13418                    }
13419    
13420                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13421    
13422                    Session session = null;
13423    
13424                    try {
13425                            session = openSession();
13426    
13427                            BlogsEntry[] array = new BlogsEntryImpl[3];
13428    
13429                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13430                                            groupId, userId, status, orderByComparator, true);
13431    
13432                            array[1] = blogsEntry;
13433    
13434                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
13435                                            groupId, userId, status, orderByComparator, false);
13436    
13437                            return array;
13438                    }
13439                    catch (Exception e) {
13440                            throw processException(e);
13441                    }
13442                    finally {
13443                            closeSession(session);
13444                    }
13445            }
13446    
13447            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
13448                    BlogsEntry blogsEntry, long groupId, long userId, int status,
13449                    OrderByComparator orderByComparator, boolean previous) {
13450                    StringBundler query = null;
13451    
13452                    if (orderByComparator != null) {
13453                            query = new StringBundler(6 +
13454                                            (orderByComparator.getOrderByFields().length * 6));
13455                    }
13456                    else {
13457                            query = new StringBundler(3);
13458                    }
13459    
13460                    if (getDB().isSupportsInlineDistinct()) {
13461                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13462                    }
13463                    else {
13464                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13465                    }
13466    
13467                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13468    
13469                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13470    
13471                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13472    
13473                    if (!getDB().isSupportsInlineDistinct()) {
13474                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13475                    }
13476    
13477                    if (orderByComparator != null) {
13478                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13479    
13480                            if (orderByConditionFields.length > 0) {
13481                                    query.append(WHERE_AND);
13482                            }
13483    
13484                            for (int i = 0; i < orderByConditionFields.length; i++) {
13485                                    if (getDB().isSupportsInlineDistinct()) {
13486                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13487                                    }
13488                                    else {
13489                                            query.append(_ORDER_BY_ENTITY_TABLE);
13490                                    }
13491    
13492                                    query.append(orderByConditionFields[i]);
13493    
13494                                    if ((i + 1) < orderByConditionFields.length) {
13495                                            if (orderByComparator.isAscending() ^ previous) {
13496                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13497                                            }
13498                                            else {
13499                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13500                                            }
13501                                    }
13502                                    else {
13503                                            if (orderByComparator.isAscending() ^ previous) {
13504                                                    query.append(WHERE_GREATER_THAN);
13505                                            }
13506                                            else {
13507                                                    query.append(WHERE_LESSER_THAN);
13508                                            }
13509                                    }
13510                            }
13511    
13512                            query.append(ORDER_BY_CLAUSE);
13513    
13514                            String[] orderByFields = orderByComparator.getOrderByFields();
13515    
13516                            for (int i = 0; i < orderByFields.length; i++) {
13517                                    if (getDB().isSupportsInlineDistinct()) {
13518                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13519                                    }
13520                                    else {
13521                                            query.append(_ORDER_BY_ENTITY_TABLE);
13522                                    }
13523    
13524                                    query.append(orderByFields[i]);
13525    
13526                                    if ((i + 1) < orderByFields.length) {
13527                                            if (orderByComparator.isAscending() ^ previous) {
13528                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13529                                            }
13530                                            else {
13531                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13532                                            }
13533                                    }
13534                                    else {
13535                                            if (orderByComparator.isAscending() ^ previous) {
13536                                                    query.append(ORDER_BY_ASC);
13537                                            }
13538                                            else {
13539                                                    query.append(ORDER_BY_DESC);
13540                                            }
13541                                    }
13542                            }
13543                    }
13544                    else {
13545                            if (getDB().isSupportsInlineDistinct()) {
13546                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13547                            }
13548                            else {
13549                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13550                            }
13551                    }
13552    
13553                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13554                                    BlogsEntry.class.getName(),
13555                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13556    
13557                    SQLQuery q = session.createSQLQuery(sql);
13558    
13559                    q.setFirstResult(0);
13560                    q.setMaxResults(2);
13561    
13562                    if (getDB().isSupportsInlineDistinct()) {
13563                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13564                    }
13565                    else {
13566                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13567                    }
13568    
13569                    QueryPos qPos = QueryPos.getInstance(q);
13570    
13571                    qPos.add(groupId);
13572    
13573                    qPos.add(userId);
13574    
13575                    qPos.add(status);
13576    
13577                    if (orderByComparator != null) {
13578                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13579    
13580                            for (Object value : values) {
13581                                    qPos.add(value);
13582                            }
13583                    }
13584    
13585                    List<BlogsEntry> list = q.list();
13586    
13587                    if (list.size() == 2) {
13588                            return list.get(1);
13589                    }
13590                    else {
13591                            return null;
13592                    }
13593            }
13594    
13595            /**
13596             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
13597             *
13598             * @param groupId the group ID
13599             * @param userId the user ID
13600             * @param status the status
13601             * @throws SystemException if a system exception occurred
13602             */
13603            @Override
13604            public void removeByG_U_S(long groupId, long userId, int status)
13605                    throws SystemException {
13606                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
13607                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13608                            remove(blogsEntry);
13609                    }
13610            }
13611    
13612            /**
13613             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
13614             *
13615             * @param groupId the group ID
13616             * @param userId the user ID
13617             * @param status the status
13618             * @return the number of matching blogs entries
13619             * @throws SystemException if a system exception occurred
13620             */
13621            @Override
13622            public int countByG_U_S(long groupId, long userId, int status)
13623                    throws SystemException {
13624                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
13625    
13626                    Object[] finderArgs = new Object[] { groupId, userId, status };
13627    
13628                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13629                                    this);
13630    
13631                    if (count == null) {
13632                            StringBundler query = new StringBundler(4);
13633    
13634                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13635    
13636                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13637    
13638                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13639    
13640                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13641    
13642                            String sql = query.toString();
13643    
13644                            Session session = null;
13645    
13646                            try {
13647                                    session = openSession();
13648    
13649                                    Query q = session.createQuery(sql);
13650    
13651                                    QueryPos qPos = QueryPos.getInstance(q);
13652    
13653                                    qPos.add(groupId);
13654    
13655                                    qPos.add(userId);
13656    
13657                                    qPos.add(status);
13658    
13659                                    count = (Long)q.uniqueResult();
13660    
13661                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13662                            }
13663                            catch (Exception e) {
13664                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13665    
13666                                    throw processException(e);
13667                            }
13668                            finally {
13669                                    closeSession(session);
13670                            }
13671                    }
13672    
13673                    return count.intValue();
13674            }
13675    
13676            /**
13677             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
13678             *
13679             * @param groupId the group ID
13680             * @param userId the user ID
13681             * @param status the status
13682             * @return the number of matching blogs entries that the user has permission to view
13683             * @throws SystemException if a system exception occurred
13684             */
13685            @Override
13686            public int filterCountByG_U_S(long groupId, long userId, int status)
13687                    throws SystemException {
13688                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13689                            return countByG_U_S(groupId, userId, status);
13690                    }
13691    
13692                    StringBundler query = new StringBundler(4);
13693    
13694                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13695    
13696                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
13697    
13698                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
13699    
13700                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
13701    
13702                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13703                                    BlogsEntry.class.getName(),
13704                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13705    
13706                    Session session = null;
13707    
13708                    try {
13709                            session = openSession();
13710    
13711                            SQLQuery q = session.createSQLQuery(sql);
13712    
13713                            q.addScalar(COUNT_COLUMN_NAME,
13714                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13715    
13716                            QueryPos qPos = QueryPos.getInstance(q);
13717    
13718                            qPos.add(groupId);
13719    
13720                            qPos.add(userId);
13721    
13722                            qPos.add(status);
13723    
13724                            Long count = (Long)q.uniqueResult();
13725    
13726                            return count.intValue();
13727                    }
13728                    catch (Exception e) {
13729                            throw processException(e);
13730                    }
13731                    finally {
13732                            closeSession(session);
13733                    }
13734            }
13735    
13736            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13737            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
13738            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
13739            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
13740                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13741                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13742                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
13743                            new String[] {
13744                                    Long.class.getName(), Date.class.getName(),
13745                                    Integer.class.getName(),
13746                                    
13747                            Integer.class.getName(), Integer.class.getName(),
13748                                    OrderByComparator.class.getName()
13749                            });
13750            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
13751                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13752                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13753                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
13754                            new String[] {
13755                                    Long.class.getName(), Date.class.getName(),
13756                                    Integer.class.getName()
13757                            });
13758    
13759            /**
13760             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13761             *
13762             * @param groupId the group ID
13763             * @param displayDate the display date
13764             * @param status the status
13765             * @return the matching blogs entries
13766             * @throws SystemException if a system exception occurred
13767             */
13768            @Override
13769            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13770                    int status) throws SystemException {
13771                    return findByG_LtD_NotS(groupId, displayDate, status,
13772                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13773            }
13774    
13775            /**
13776             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13777             *
13778             * <p>
13779             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13780             * </p>
13781             *
13782             * @param groupId the group ID
13783             * @param displayDate the display date
13784             * @param status the status
13785             * @param start the lower bound of the range of blogs entries
13786             * @param end the upper bound of the range of blogs entries (not inclusive)
13787             * @return the range of matching blogs entries
13788             * @throws SystemException if a system exception occurred
13789             */
13790            @Override
13791            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13792                    int status, int start, int end) throws SystemException {
13793                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
13794            }
13795    
13796            /**
13797             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13798             *
13799             * <p>
13800             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13801             * </p>
13802             *
13803             * @param groupId the group ID
13804             * @param displayDate the display date
13805             * @param status the status
13806             * @param start the lower bound of the range of blogs entries
13807             * @param end the upper bound of the range of blogs entries (not inclusive)
13808             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13809             * @return the ordered range of matching blogs entries
13810             * @throws SystemException if a system exception occurred
13811             */
13812            @Override
13813            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13814                    int status, int start, int end, OrderByComparator orderByComparator)
13815                    throws SystemException {
13816                    boolean pagination = true;
13817                    FinderPath finderPath = null;
13818                    Object[] finderArgs = null;
13819    
13820                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
13821                    finderArgs = new Object[] {
13822                                    groupId, displayDate, status,
13823                                    
13824                                    start, end, orderByComparator
13825                            };
13826    
13827                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13828                                    finderArgs, this);
13829    
13830                    if ((list != null) && !list.isEmpty()) {
13831                            for (BlogsEntry blogsEntry : list) {
13832                                    if ((groupId != blogsEntry.getGroupId()) ||
13833                                                    !Validator.equals(displayDate,
13834                                                            blogsEntry.getDisplayDate()) ||
13835                                                    (status != blogsEntry.getStatus())) {
13836                                            list = null;
13837    
13838                                            break;
13839                                    }
13840                            }
13841                    }
13842    
13843                    if (list == null) {
13844                            StringBundler query = null;
13845    
13846                            if (orderByComparator != null) {
13847                                    query = new StringBundler(5 +
13848                                                    (orderByComparator.getOrderByFields().length * 3));
13849                            }
13850                            else {
13851                                    query = new StringBundler(5);
13852                            }
13853    
13854                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13855    
13856                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13857    
13858                            boolean bindDisplayDate = false;
13859    
13860                            if (displayDate == null) {
13861                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13862                            }
13863                            else {
13864                                    bindDisplayDate = true;
13865    
13866                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13867                            }
13868    
13869                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13870    
13871                            if (orderByComparator != null) {
13872                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13873                                            orderByComparator);
13874                            }
13875                            else
13876                             if (pagination) {
13877                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13878                            }
13879    
13880                            String sql = query.toString();
13881    
13882                            Session session = null;
13883    
13884                            try {
13885                                    session = openSession();
13886    
13887                                    Query q = session.createQuery(sql);
13888    
13889                                    QueryPos qPos = QueryPos.getInstance(q);
13890    
13891                                    qPos.add(groupId);
13892    
13893                                    if (bindDisplayDate) {
13894                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
13895                                    }
13896    
13897                                    qPos.add(status);
13898    
13899                                    if (!pagination) {
13900                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13901                                                            start, end, false);
13902    
13903                                            Collections.sort(list);
13904    
13905                                            list = new UnmodifiableList<BlogsEntry>(list);
13906                                    }
13907                                    else {
13908                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13909                                                            start, end);
13910                                    }
13911    
13912                                    cacheResult(list);
13913    
13914                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13915                            }
13916                            catch (Exception e) {
13917                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13918    
13919                                    throw processException(e);
13920                            }
13921                            finally {
13922                                    closeSession(session);
13923                            }
13924                    }
13925    
13926                    return list;
13927            }
13928    
13929            /**
13930             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13931             *
13932             * @param groupId the group ID
13933             * @param displayDate the display date
13934             * @param status the status
13935             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13936             * @return the first matching blogs entry
13937             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13938             * @throws SystemException if a system exception occurred
13939             */
13940            @Override
13941            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
13942                    int status, OrderByComparator orderByComparator)
13943                    throws NoSuchEntryException, SystemException {
13944                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
13945                                    status, orderByComparator);
13946    
13947                    if (blogsEntry != null) {
13948                            return blogsEntry;
13949                    }
13950    
13951                    StringBundler msg = new StringBundler(8);
13952    
13953                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13954    
13955                    msg.append("groupId=");
13956                    msg.append(groupId);
13957    
13958                    msg.append(", displayDate=");
13959                    msg.append(displayDate);
13960    
13961                    msg.append(", status=");
13962                    msg.append(status);
13963    
13964                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13965    
13966                    throw new NoSuchEntryException(msg.toString());
13967            }
13968    
13969            /**
13970             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13971             *
13972             * @param groupId the group ID
13973             * @param displayDate the display date
13974             * @param status the status
13975             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13976             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13977             * @throws SystemException if a system exception occurred
13978             */
13979            @Override
13980            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
13981                    int status, OrderByComparator orderByComparator)
13982                    throws SystemException {
13983                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13984                                    0, 1, orderByComparator);
13985    
13986                    if (!list.isEmpty()) {
13987                            return list.get(0);
13988                    }
13989    
13990                    return null;
13991            }
13992    
13993            /**
13994             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13995             *
13996             * @param groupId the group ID
13997             * @param displayDate the display date
13998             * @param status the status
13999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14000             * @return the last matching blogs entry
14001             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14002             * @throws SystemException if a system exception occurred
14003             */
14004            @Override
14005            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
14006                    int status, OrderByComparator orderByComparator)
14007                    throws NoSuchEntryException, SystemException {
14008                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
14009                                    status, orderByComparator);
14010    
14011                    if (blogsEntry != null) {
14012                            return blogsEntry;
14013                    }
14014    
14015                    StringBundler msg = new StringBundler(8);
14016    
14017                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14018    
14019                    msg.append("groupId=");
14020                    msg.append(groupId);
14021    
14022                    msg.append(", displayDate=");
14023                    msg.append(displayDate);
14024    
14025                    msg.append(", status=");
14026                    msg.append(status);
14027    
14028                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14029    
14030                    throw new NoSuchEntryException(msg.toString());
14031            }
14032    
14033            /**
14034             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14035             *
14036             * @param groupId the group ID
14037             * @param displayDate the display date
14038             * @param status the status
14039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14040             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14041             * @throws SystemException if a system exception occurred
14042             */
14043            @Override
14044            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
14045                    int status, OrderByComparator orderByComparator)
14046                    throws SystemException {
14047                    int count = countByG_LtD_NotS(groupId, displayDate, status);
14048    
14049                    if (count == 0) {
14050                            return null;
14051                    }
14052    
14053                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
14054                                    count - 1, count, orderByComparator);
14055    
14056                    if (!list.isEmpty()) {
14057                            return list.get(0);
14058                    }
14059    
14060                    return null;
14061            }
14062    
14063            /**
14064             * 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;.
14065             *
14066             * @param entryId the primary key of the current blogs entry
14067             * @param groupId the group ID
14068             * @param displayDate the display date
14069             * @param status the status
14070             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14071             * @return the previous, current, and next blogs entry
14072             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14073             * @throws SystemException if a system exception occurred
14074             */
14075            @Override
14076            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
14077                    long groupId, Date displayDate, int status,
14078                    OrderByComparator orderByComparator)
14079                    throws NoSuchEntryException, SystemException {
14080                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14081    
14082                    Session session = null;
14083    
14084                    try {
14085                            session = openSession();
14086    
14087                            BlogsEntry[] array = new BlogsEntryImpl[3];
14088    
14089                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14090                                            groupId, displayDate, status, orderByComparator, true);
14091    
14092                            array[1] = blogsEntry;
14093    
14094                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14095                                            groupId, displayDate, status, orderByComparator, false);
14096    
14097                            return array;
14098                    }
14099                    catch (Exception e) {
14100                            throw processException(e);
14101                    }
14102                    finally {
14103                            closeSession(session);
14104                    }
14105            }
14106    
14107            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
14108                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14109                    OrderByComparator orderByComparator, boolean previous) {
14110                    StringBundler query = null;
14111    
14112                    if (orderByComparator != null) {
14113                            query = new StringBundler(6 +
14114                                            (orderByComparator.getOrderByFields().length * 6));
14115                    }
14116                    else {
14117                            query = new StringBundler(3);
14118                    }
14119    
14120                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14121    
14122                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14123    
14124                    boolean bindDisplayDate = false;
14125    
14126                    if (displayDate == null) {
14127                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14128                    }
14129                    else {
14130                            bindDisplayDate = true;
14131    
14132                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14133                    }
14134    
14135                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14136    
14137                    if (orderByComparator != null) {
14138                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14139    
14140                            if (orderByConditionFields.length > 0) {
14141                                    query.append(WHERE_AND);
14142                            }
14143    
14144                            for (int i = 0; i < orderByConditionFields.length; i++) {
14145                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14146                                    query.append(orderByConditionFields[i]);
14147    
14148                                    if ((i + 1) < orderByConditionFields.length) {
14149                                            if (orderByComparator.isAscending() ^ previous) {
14150                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14151                                            }
14152                                            else {
14153                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14154                                            }
14155                                    }
14156                                    else {
14157                                            if (orderByComparator.isAscending() ^ previous) {
14158                                                    query.append(WHERE_GREATER_THAN);
14159                                            }
14160                                            else {
14161                                                    query.append(WHERE_LESSER_THAN);
14162                                            }
14163                                    }
14164                            }
14165    
14166                            query.append(ORDER_BY_CLAUSE);
14167    
14168                            String[] orderByFields = orderByComparator.getOrderByFields();
14169    
14170                            for (int i = 0; i < orderByFields.length; i++) {
14171                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14172                                    query.append(orderByFields[i]);
14173    
14174                                    if ((i + 1) < orderByFields.length) {
14175                                            if (orderByComparator.isAscending() ^ previous) {
14176                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14177                                            }
14178                                            else {
14179                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14180                                            }
14181                                    }
14182                                    else {
14183                                            if (orderByComparator.isAscending() ^ previous) {
14184                                                    query.append(ORDER_BY_ASC);
14185                                            }
14186                                            else {
14187                                                    query.append(ORDER_BY_DESC);
14188                                            }
14189                                    }
14190                            }
14191                    }
14192                    else {
14193                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14194                    }
14195    
14196                    String sql = query.toString();
14197    
14198                    Query q = session.createQuery(sql);
14199    
14200                    q.setFirstResult(0);
14201                    q.setMaxResults(2);
14202    
14203                    QueryPos qPos = QueryPos.getInstance(q);
14204    
14205                    qPos.add(groupId);
14206    
14207                    if (bindDisplayDate) {
14208                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14209                    }
14210    
14211                    qPos.add(status);
14212    
14213                    if (orderByComparator != null) {
14214                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14215    
14216                            for (Object value : values) {
14217                                    qPos.add(value);
14218                            }
14219                    }
14220    
14221                    List<BlogsEntry> list = q.list();
14222    
14223                    if (list.size() == 2) {
14224                            return list.get(1);
14225                    }
14226                    else {
14227                            return null;
14228                    }
14229            }
14230    
14231            /**
14232             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14233             *
14234             * @param groupId the group ID
14235             * @param displayDate the display date
14236             * @param status the status
14237             * @return the matching blogs entries that the user has permission to view
14238             * @throws SystemException if a system exception occurred
14239             */
14240            @Override
14241            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
14242                    Date displayDate, int status) throws SystemException {
14243                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
14244                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14245            }
14246    
14247            /**
14248             * 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;.
14249             *
14250             * <p>
14251             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14252             * </p>
14253             *
14254             * @param groupId the group ID
14255             * @param displayDate the display date
14256             * @param status the status
14257             * @param start the lower bound of the range of blogs entries
14258             * @param end the upper bound of the range of blogs entries (not inclusive)
14259             * @return the range of matching blogs entries that the user has permission to view
14260             * @throws SystemException if a system exception occurred
14261             */
14262            @Override
14263            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
14264                    Date displayDate, int status, int start, int end)
14265                    throws SystemException {
14266                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
14267                            null);
14268            }
14269    
14270            /**
14271             * 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;.
14272             *
14273             * <p>
14274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14275             * </p>
14276             *
14277             * @param groupId the group ID
14278             * @param displayDate the display date
14279             * @param status the status
14280             * @param start the lower bound of the range of blogs entries
14281             * @param end the upper bound of the range of blogs entries (not inclusive)
14282             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14283             * @return the ordered range of matching blogs entries that the user has permission to view
14284             * @throws SystemException if a system exception occurred
14285             */
14286            @Override
14287            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
14288                    Date displayDate, int status, int start, int end,
14289                    OrderByComparator orderByComparator) throws SystemException {
14290                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14291                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
14292                                    orderByComparator);
14293                    }
14294    
14295                    StringBundler query = null;
14296    
14297                    if (orderByComparator != null) {
14298                            query = new StringBundler(5 +
14299                                            (orderByComparator.getOrderByFields().length * 3));
14300                    }
14301                    else {
14302                            query = new StringBundler(5);
14303                    }
14304    
14305                    if (getDB().isSupportsInlineDistinct()) {
14306                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14307                    }
14308                    else {
14309                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14310                    }
14311    
14312                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14313    
14314                    boolean bindDisplayDate = false;
14315    
14316                    if (displayDate == null) {
14317                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14318                    }
14319                    else {
14320                            bindDisplayDate = true;
14321    
14322                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14323                    }
14324    
14325                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14326    
14327                    if (!getDB().isSupportsInlineDistinct()) {
14328                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14329                    }
14330    
14331                    if (orderByComparator != null) {
14332                            if (getDB().isSupportsInlineDistinct()) {
14333                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14334                                            orderByComparator, true);
14335                            }
14336                            else {
14337                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
14338                                            orderByComparator, true);
14339                            }
14340                    }
14341                    else {
14342                            if (getDB().isSupportsInlineDistinct()) {
14343                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14344                            }
14345                            else {
14346                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14347                            }
14348                    }
14349    
14350                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14351                                    BlogsEntry.class.getName(),
14352                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14353    
14354                    Session session = null;
14355    
14356                    try {
14357                            session = openSession();
14358    
14359                            SQLQuery q = session.createSQLQuery(sql);
14360    
14361                            if (getDB().isSupportsInlineDistinct()) {
14362                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14363                            }
14364                            else {
14365                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14366                            }
14367    
14368                            QueryPos qPos = QueryPos.getInstance(q);
14369    
14370                            qPos.add(groupId);
14371    
14372                            if (bindDisplayDate) {
14373                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14374                            }
14375    
14376                            qPos.add(status);
14377    
14378                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
14379                    }
14380                    catch (Exception e) {
14381                            throw processException(e);
14382                    }
14383                    finally {
14384                            closeSession(session);
14385                    }
14386            }
14387    
14388            /**
14389             * 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;.
14390             *
14391             * @param entryId the primary key of the current blogs entry
14392             * @param groupId the group ID
14393             * @param displayDate the display date
14394             * @param status the status
14395             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14396             * @return the previous, current, and next blogs entry
14397             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14398             * @throws SystemException if a system exception occurred
14399             */
14400            @Override
14401            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
14402                    long groupId, Date displayDate, int status,
14403                    OrderByComparator orderByComparator)
14404                    throws NoSuchEntryException, SystemException {
14405                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14406                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
14407                                    status, orderByComparator);
14408                    }
14409    
14410                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14411    
14412                    Session session = null;
14413    
14414                    try {
14415                            session = openSession();
14416    
14417                            BlogsEntry[] array = new BlogsEntryImpl[3];
14418    
14419                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14420                                            groupId, displayDate, status, orderByComparator, true);
14421    
14422                            array[1] = blogsEntry;
14423    
14424                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
14425                                            groupId, displayDate, status, orderByComparator, false);
14426    
14427                            return array;
14428                    }
14429                    catch (Exception e) {
14430                            throw processException(e);
14431                    }
14432                    finally {
14433                            closeSession(session);
14434                    }
14435            }
14436    
14437            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
14438                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
14439                    OrderByComparator orderByComparator, boolean previous) {
14440                    StringBundler query = null;
14441    
14442                    if (orderByComparator != null) {
14443                            query = new StringBundler(6 +
14444                                            (orderByComparator.getOrderByFields().length * 6));
14445                    }
14446                    else {
14447                            query = new StringBundler(3);
14448                    }
14449    
14450                    if (getDB().isSupportsInlineDistinct()) {
14451                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
14452                    }
14453                    else {
14454                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
14455                    }
14456    
14457                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14458    
14459                    boolean bindDisplayDate = false;
14460    
14461                    if (displayDate == null) {
14462                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14463                    }
14464                    else {
14465                            bindDisplayDate = true;
14466    
14467                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14468                    }
14469    
14470                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14471    
14472                    if (!getDB().isSupportsInlineDistinct()) {
14473                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
14474                    }
14475    
14476                    if (orderByComparator != null) {
14477                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14478    
14479                            if (orderByConditionFields.length > 0) {
14480                                    query.append(WHERE_AND);
14481                            }
14482    
14483                            for (int i = 0; i < orderByConditionFields.length; i++) {
14484                                    if (getDB().isSupportsInlineDistinct()) {
14485                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14486                                    }
14487                                    else {
14488                                            query.append(_ORDER_BY_ENTITY_TABLE);
14489                                    }
14490    
14491                                    query.append(orderByConditionFields[i]);
14492    
14493                                    if ((i + 1) < orderByConditionFields.length) {
14494                                            if (orderByComparator.isAscending() ^ previous) {
14495                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14496                                            }
14497                                            else {
14498                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14499                                            }
14500                                    }
14501                                    else {
14502                                            if (orderByComparator.isAscending() ^ previous) {
14503                                                    query.append(WHERE_GREATER_THAN);
14504                                            }
14505                                            else {
14506                                                    query.append(WHERE_LESSER_THAN);
14507                                            }
14508                                    }
14509                            }
14510    
14511                            query.append(ORDER_BY_CLAUSE);
14512    
14513                            String[] orderByFields = orderByComparator.getOrderByFields();
14514    
14515                            for (int i = 0; i < orderByFields.length; i++) {
14516                                    if (getDB().isSupportsInlineDistinct()) {
14517                                            query.append(_ORDER_BY_ENTITY_ALIAS);
14518                                    }
14519                                    else {
14520                                            query.append(_ORDER_BY_ENTITY_TABLE);
14521                                    }
14522    
14523                                    query.append(orderByFields[i]);
14524    
14525                                    if ((i + 1) < orderByFields.length) {
14526                                            if (orderByComparator.isAscending() ^ previous) {
14527                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14528                                            }
14529                                            else {
14530                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14531                                            }
14532                                    }
14533                                    else {
14534                                            if (orderByComparator.isAscending() ^ previous) {
14535                                                    query.append(ORDER_BY_ASC);
14536                                            }
14537                                            else {
14538                                                    query.append(ORDER_BY_DESC);
14539                                            }
14540                                    }
14541                            }
14542                    }
14543                    else {
14544                            if (getDB().isSupportsInlineDistinct()) {
14545                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14546                            }
14547                            else {
14548                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14549                            }
14550                    }
14551    
14552                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14553                                    BlogsEntry.class.getName(),
14554                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14555    
14556                    SQLQuery q = session.createSQLQuery(sql);
14557    
14558                    q.setFirstResult(0);
14559                    q.setMaxResults(2);
14560    
14561                    if (getDB().isSupportsInlineDistinct()) {
14562                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14563                    }
14564                    else {
14565                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14566                    }
14567    
14568                    QueryPos qPos = QueryPos.getInstance(q);
14569    
14570                    qPos.add(groupId);
14571    
14572                    if (bindDisplayDate) {
14573                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14574                    }
14575    
14576                    qPos.add(status);
14577    
14578                    if (orderByComparator != null) {
14579                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14580    
14581                            for (Object value : values) {
14582                                    qPos.add(value);
14583                            }
14584                    }
14585    
14586                    List<BlogsEntry> list = q.list();
14587    
14588                    if (list.size() == 2) {
14589                            return list.get(1);
14590                    }
14591                    else {
14592                            return null;
14593                    }
14594            }
14595    
14596            /**
14597             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
14598             *
14599             * @param groupId the group ID
14600             * @param displayDate the display date
14601             * @param status the status
14602             * @throws SystemException if a system exception occurred
14603             */
14604            @Override
14605            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status)
14606                    throws SystemException {
14607                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
14608                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14609                            remove(blogsEntry);
14610                    }
14611            }
14612    
14613            /**
14614             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14615             *
14616             * @param groupId the group ID
14617             * @param displayDate the display date
14618             * @param status the status
14619             * @return the number of matching blogs entries
14620             * @throws SystemException if a system exception occurred
14621             */
14622            @Override
14623            public int countByG_LtD_NotS(long groupId, Date displayDate, int status)
14624                    throws SystemException {
14625                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
14626    
14627                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
14628    
14629                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14630                                    this);
14631    
14632                    if (count == null) {
14633                            StringBundler query = new StringBundler(4);
14634    
14635                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14636    
14637                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14638    
14639                            boolean bindDisplayDate = false;
14640    
14641                            if (displayDate == null) {
14642                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14643                            }
14644                            else {
14645                                    bindDisplayDate = true;
14646    
14647                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14648                            }
14649    
14650                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14651    
14652                            String sql = query.toString();
14653    
14654                            Session session = null;
14655    
14656                            try {
14657                                    session = openSession();
14658    
14659                                    Query q = session.createQuery(sql);
14660    
14661                                    QueryPos qPos = QueryPos.getInstance(q);
14662    
14663                                    qPos.add(groupId);
14664    
14665                                    if (bindDisplayDate) {
14666                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14667                                    }
14668    
14669                                    qPos.add(status);
14670    
14671                                    count = (Long)q.uniqueResult();
14672    
14673                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14674                            }
14675                            catch (Exception e) {
14676                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14677    
14678                                    throw processException(e);
14679                            }
14680                            finally {
14681                                    closeSession(session);
14682                            }
14683                    }
14684    
14685                    return count.intValue();
14686            }
14687    
14688            /**
14689             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14690             *
14691             * @param groupId the group ID
14692             * @param displayDate the display date
14693             * @param status the status
14694             * @return the number of matching blogs entries that the user has permission to view
14695             * @throws SystemException if a system exception occurred
14696             */
14697            @Override
14698            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
14699                    int status) throws SystemException {
14700                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14701                            return countByG_LtD_NotS(groupId, displayDate, status);
14702                    }
14703    
14704                    StringBundler query = new StringBundler(4);
14705    
14706                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
14707    
14708                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14709    
14710                    boolean bindDisplayDate = false;
14711    
14712                    if (displayDate == null) {
14713                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14714                    }
14715                    else {
14716                            bindDisplayDate = true;
14717    
14718                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14719                    }
14720    
14721                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14722    
14723                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14724                                    BlogsEntry.class.getName(),
14725                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14726    
14727                    Session session = null;
14728    
14729                    try {
14730                            session = openSession();
14731    
14732                            SQLQuery q = session.createSQLQuery(sql);
14733    
14734                            q.addScalar(COUNT_COLUMN_NAME,
14735                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14736    
14737                            QueryPos qPos = QueryPos.getInstance(q);
14738    
14739                            qPos.add(groupId);
14740    
14741                            if (bindDisplayDate) {
14742                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
14743                            }
14744    
14745                            qPos.add(status);
14746    
14747                            Long count = (Long)q.uniqueResult();
14748    
14749                            return count.intValue();
14750                    }
14751                    catch (Exception e) {
14752                            throw processException(e);
14753                    }
14754                    finally {
14755                            closeSession(session);
14756                    }
14757            }
14758    
14759            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
14760            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
14761            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14762            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
14763            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14764                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14765                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
14766                            new String[] {
14767                                    Long.class.getName(), Date.class.getName(),
14768                                    Integer.class.getName(),
14769                                    
14770                            Integer.class.getName(), Integer.class.getName(),
14771                                    OrderByComparator.class.getName()
14772                            });
14773            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14774                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14775                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
14776                            new String[] {
14777                                    Long.class.getName(), Date.class.getName(),
14778                                    Integer.class.getName()
14779                            });
14780    
14781            /**
14782             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14783             *
14784             * @param groupId the group ID
14785             * @param displayDate the display date
14786             * @param status the status
14787             * @return the matching blogs entries
14788             * @throws SystemException if a system exception occurred
14789             */
14790            @Override
14791            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14792                    int status) throws SystemException {
14793                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
14794                            QueryUtil.ALL_POS, null);
14795            }
14796    
14797            /**
14798             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14799             *
14800             * <p>
14801             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14802             * </p>
14803             *
14804             * @param groupId the group ID
14805             * @param displayDate the display date
14806             * @param status the status
14807             * @param start the lower bound of the range of blogs entries
14808             * @param end the upper bound of the range of blogs entries (not inclusive)
14809             * @return the range of matching blogs entries
14810             * @throws SystemException if a system exception occurred
14811             */
14812            @Override
14813            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14814                    int status, int start, int end) throws SystemException {
14815                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
14816            }
14817    
14818            /**
14819             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14820             *
14821             * <p>
14822             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14823             * </p>
14824             *
14825             * @param groupId the group ID
14826             * @param displayDate the display date
14827             * @param status the status
14828             * @param start the lower bound of the range of blogs entries
14829             * @param end the upper bound of the range of blogs entries (not inclusive)
14830             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14831             * @return the ordered range of matching blogs entries
14832             * @throws SystemException if a system exception occurred
14833             */
14834            @Override
14835            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
14836                    int status, int start, int end, OrderByComparator orderByComparator)
14837                    throws SystemException {
14838                    boolean pagination = true;
14839                    FinderPath finderPath = null;
14840                    Object[] finderArgs = null;
14841    
14842                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
14843                    finderArgs = new Object[] {
14844                                    groupId, displayDate, status,
14845                                    
14846                                    start, end, orderByComparator
14847                            };
14848    
14849                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14850                                    finderArgs, this);
14851    
14852                    if ((list != null) && !list.isEmpty()) {
14853                            for (BlogsEntry blogsEntry : list) {
14854                                    if ((groupId != blogsEntry.getGroupId()) ||
14855                                                    !Validator.equals(displayDate,
14856                                                            blogsEntry.getDisplayDate()) ||
14857                                                    (status != blogsEntry.getStatus())) {
14858                                            list = null;
14859    
14860                                            break;
14861                                    }
14862                            }
14863                    }
14864    
14865                    if (list == null) {
14866                            StringBundler query = null;
14867    
14868                            if (orderByComparator != null) {
14869                                    query = new StringBundler(5 +
14870                                                    (orderByComparator.getOrderByFields().length * 3));
14871                            }
14872                            else {
14873                                    query = new StringBundler(5);
14874                            }
14875    
14876                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14877    
14878                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
14879    
14880                            boolean bindDisplayDate = false;
14881    
14882                            if (displayDate == null) {
14883                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
14884                            }
14885                            else {
14886                                    bindDisplayDate = true;
14887    
14888                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
14889                            }
14890    
14891                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
14892    
14893                            if (orderByComparator != null) {
14894                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14895                                            orderByComparator);
14896                            }
14897                            else
14898                             if (pagination) {
14899                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14900                            }
14901    
14902                            String sql = query.toString();
14903    
14904                            Session session = null;
14905    
14906                            try {
14907                                    session = openSession();
14908    
14909                                    Query q = session.createQuery(sql);
14910    
14911                                    QueryPos qPos = QueryPos.getInstance(q);
14912    
14913                                    qPos.add(groupId);
14914    
14915                                    if (bindDisplayDate) {
14916                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
14917                                    }
14918    
14919                                    qPos.add(status);
14920    
14921                                    if (!pagination) {
14922                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14923                                                            start, end, false);
14924    
14925                                            Collections.sort(list);
14926    
14927                                            list = new UnmodifiableList<BlogsEntry>(list);
14928                                    }
14929                                    else {
14930                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14931                                                            start, end);
14932                                    }
14933    
14934                                    cacheResult(list);
14935    
14936                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14937                            }
14938                            catch (Exception e) {
14939                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14940    
14941                                    throw processException(e);
14942                            }
14943                            finally {
14944                                    closeSession(session);
14945                            }
14946                    }
14947    
14948                    return list;
14949            }
14950    
14951            /**
14952             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14953             *
14954             * @param groupId the group ID
14955             * @param displayDate the display date
14956             * @param status the status
14957             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14958             * @return the first matching blogs entry
14959             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14960             * @throws SystemException if a system exception occurred
14961             */
14962            @Override
14963            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
14964                    int status, OrderByComparator orderByComparator)
14965                    throws NoSuchEntryException, SystemException {
14966                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
14967                                    status, orderByComparator);
14968    
14969                    if (blogsEntry != null) {
14970                            return blogsEntry;
14971                    }
14972    
14973                    StringBundler msg = new StringBundler(8);
14974    
14975                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14976    
14977                    msg.append("groupId=");
14978                    msg.append(groupId);
14979    
14980                    msg.append(", displayDate=");
14981                    msg.append(displayDate);
14982    
14983                    msg.append(", status=");
14984                    msg.append(status);
14985    
14986                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14987    
14988                    throw new NoSuchEntryException(msg.toString());
14989            }
14990    
14991            /**
14992             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
14993             *
14994             * @param groupId the group ID
14995             * @param displayDate the display date
14996             * @param status the status
14997             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14998             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14999             * @throws SystemException if a system exception occurred
15000             */
15001            @Override
15002            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
15003                    int status, OrderByComparator orderByComparator)
15004                    throws SystemException {
15005                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
15006                                    1, orderByComparator);
15007    
15008                    if (!list.isEmpty()) {
15009                            return list.get(0);
15010                    }
15011    
15012                    return null;
15013            }
15014    
15015            /**
15016             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15017             *
15018             * @param groupId the group ID
15019             * @param displayDate the display date
15020             * @param status the status
15021             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15022             * @return the last matching blogs entry
15023             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15024             * @throws SystemException if a system exception occurred
15025             */
15026            @Override
15027            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
15028                    int status, OrderByComparator orderByComparator)
15029                    throws NoSuchEntryException, SystemException {
15030                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
15031                                    status, orderByComparator);
15032    
15033                    if (blogsEntry != null) {
15034                            return blogsEntry;
15035                    }
15036    
15037                    StringBundler msg = new StringBundler(8);
15038    
15039                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15040    
15041                    msg.append("groupId=");
15042                    msg.append(groupId);
15043    
15044                    msg.append(", displayDate=");
15045                    msg.append(displayDate);
15046    
15047                    msg.append(", status=");
15048                    msg.append(status);
15049    
15050                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15051    
15052                    throw new NoSuchEntryException(msg.toString());
15053            }
15054    
15055            /**
15056             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15057             *
15058             * @param groupId the group ID
15059             * @param displayDate the display date
15060             * @param status the status
15061             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15062             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15063             * @throws SystemException if a system exception occurred
15064             */
15065            @Override
15066            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
15067                    int status, OrderByComparator orderByComparator)
15068                    throws SystemException {
15069                    int count = countByG_LtD_S(groupId, displayDate, status);
15070    
15071                    if (count == 0) {
15072                            return null;
15073                    }
15074    
15075                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
15076                                    count - 1, count, orderByComparator);
15077    
15078                    if (!list.isEmpty()) {
15079                            return list.get(0);
15080                    }
15081    
15082                    return null;
15083            }
15084    
15085            /**
15086             * 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;.
15087             *
15088             * @param entryId the primary key of the current blogs entry
15089             * @param groupId the group ID
15090             * @param displayDate the display date
15091             * @param status the status
15092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15093             * @return the previous, current, and next blogs entry
15094             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15095             * @throws SystemException if a system exception occurred
15096             */
15097            @Override
15098            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
15099                    Date displayDate, int status, OrderByComparator orderByComparator)
15100                    throws NoSuchEntryException, SystemException {
15101                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15102    
15103                    Session session = null;
15104    
15105                    try {
15106                            session = openSession();
15107    
15108                            BlogsEntry[] array = new BlogsEntryImpl[3];
15109    
15110                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15111                                            displayDate, status, orderByComparator, true);
15112    
15113                            array[1] = blogsEntry;
15114    
15115                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15116                                            displayDate, status, orderByComparator, false);
15117    
15118                            return array;
15119                    }
15120                    catch (Exception e) {
15121                            throw processException(e);
15122                    }
15123                    finally {
15124                            closeSession(session);
15125                    }
15126            }
15127    
15128            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
15129                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
15130                    OrderByComparator orderByComparator, boolean previous) {
15131                    StringBundler query = null;
15132    
15133                    if (orderByComparator != null) {
15134                            query = new StringBundler(6 +
15135                                            (orderByComparator.getOrderByFields().length * 6));
15136                    }
15137                    else {
15138                            query = new StringBundler(3);
15139                    }
15140    
15141                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15142    
15143                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15144    
15145                    boolean bindDisplayDate = false;
15146    
15147                    if (displayDate == null) {
15148                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15149                    }
15150                    else {
15151                            bindDisplayDate = true;
15152    
15153                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15154                    }
15155    
15156                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15157    
15158                    if (orderByComparator != null) {
15159                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15160    
15161                            if (orderByConditionFields.length > 0) {
15162                                    query.append(WHERE_AND);
15163                            }
15164    
15165                            for (int i = 0; i < orderByConditionFields.length; i++) {
15166                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15167                                    query.append(orderByConditionFields[i]);
15168    
15169                                    if ((i + 1) < orderByConditionFields.length) {
15170                                            if (orderByComparator.isAscending() ^ previous) {
15171                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15172                                            }
15173                                            else {
15174                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15175                                            }
15176                                    }
15177                                    else {
15178                                            if (orderByComparator.isAscending() ^ previous) {
15179                                                    query.append(WHERE_GREATER_THAN);
15180                                            }
15181                                            else {
15182                                                    query.append(WHERE_LESSER_THAN);
15183                                            }
15184                                    }
15185                            }
15186    
15187                            query.append(ORDER_BY_CLAUSE);
15188    
15189                            String[] orderByFields = orderByComparator.getOrderByFields();
15190    
15191                            for (int i = 0; i < orderByFields.length; i++) {
15192                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15193                                    query.append(orderByFields[i]);
15194    
15195                                    if ((i + 1) < orderByFields.length) {
15196                                            if (orderByComparator.isAscending() ^ previous) {
15197                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15198                                            }
15199                                            else {
15200                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15201                                            }
15202                                    }
15203                                    else {
15204                                            if (orderByComparator.isAscending() ^ previous) {
15205                                                    query.append(ORDER_BY_ASC);
15206                                            }
15207                                            else {
15208                                                    query.append(ORDER_BY_DESC);
15209                                            }
15210                                    }
15211                            }
15212                    }
15213                    else {
15214                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15215                    }
15216    
15217                    String sql = query.toString();
15218    
15219                    Query q = session.createQuery(sql);
15220    
15221                    q.setFirstResult(0);
15222                    q.setMaxResults(2);
15223    
15224                    QueryPos qPos = QueryPos.getInstance(q);
15225    
15226                    qPos.add(groupId);
15227    
15228                    if (bindDisplayDate) {
15229                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15230                    }
15231    
15232                    qPos.add(status);
15233    
15234                    if (orderByComparator != null) {
15235                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15236    
15237                            for (Object value : values) {
15238                                    qPos.add(value);
15239                            }
15240                    }
15241    
15242                    List<BlogsEntry> list = q.list();
15243    
15244                    if (list.size() == 2) {
15245                            return list.get(1);
15246                    }
15247                    else {
15248                            return null;
15249                    }
15250            }
15251    
15252            /**
15253             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15254             *
15255             * @param groupId the group ID
15256             * @param displayDate the display date
15257             * @param status the status
15258             * @return the matching blogs entries that the user has permission to view
15259             * @throws SystemException if a system exception occurred
15260             */
15261            @Override
15262            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
15263                    int status) throws SystemException {
15264                    return filterFindByG_LtD_S(groupId, displayDate, status,
15265                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15266            }
15267    
15268            /**
15269             * 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;.
15270             *
15271             * <p>
15272             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15273             * </p>
15274             *
15275             * @param groupId the group ID
15276             * @param displayDate the display date
15277             * @param status the status
15278             * @param start the lower bound of the range of blogs entries
15279             * @param end the upper bound of the range of blogs entries (not inclusive)
15280             * @return the range of matching blogs entries that the user has permission to view
15281             * @throws SystemException if a system exception occurred
15282             */
15283            @Override
15284            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
15285                    int status, int start, int end) throws SystemException {
15286                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
15287                            null);
15288            }
15289    
15290            /**
15291             * 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;.
15292             *
15293             * <p>
15294             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15295             * </p>
15296             *
15297             * @param groupId the group ID
15298             * @param displayDate the display date
15299             * @param status the status
15300             * @param start the lower bound of the range of blogs entries
15301             * @param end the upper bound of the range of blogs entries (not inclusive)
15302             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15303             * @return the ordered range of matching blogs entries that the user has permission to view
15304             * @throws SystemException if a system exception occurred
15305             */
15306            @Override
15307            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
15308                    int status, int start, int end, OrderByComparator orderByComparator)
15309                    throws SystemException {
15310                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15311                            return findByG_LtD_S(groupId, displayDate, status, start, end,
15312                                    orderByComparator);
15313                    }
15314    
15315                    StringBundler query = null;
15316    
15317                    if (orderByComparator != null) {
15318                            query = new StringBundler(5 +
15319                                            (orderByComparator.getOrderByFields().length * 3));
15320                    }
15321                    else {
15322                            query = new StringBundler(5);
15323                    }
15324    
15325                    if (getDB().isSupportsInlineDistinct()) {
15326                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
15327                    }
15328                    else {
15329                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
15330                    }
15331    
15332                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15333    
15334                    boolean bindDisplayDate = false;
15335    
15336                    if (displayDate == null) {
15337                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15338                    }
15339                    else {
15340                            bindDisplayDate = true;
15341    
15342                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15343                    }
15344    
15345                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15346    
15347                    if (!getDB().isSupportsInlineDistinct()) {
15348                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
15349                    }
15350    
15351                    if (orderByComparator != null) {
15352                            if (getDB().isSupportsInlineDistinct()) {
15353                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15354                                            orderByComparator, true);
15355                            }
15356                            else {
15357                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
15358                                            orderByComparator, true);
15359                            }
15360                    }
15361                    else {
15362                            if (getDB().isSupportsInlineDistinct()) {
15363                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15364                            }
15365                            else {
15366                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15367                            }
15368                    }
15369    
15370                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15371                                    BlogsEntry.class.getName(),
15372                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15373    
15374                    Session session = null;
15375    
15376                    try {
15377                            session = openSession();
15378    
15379                            SQLQuery q = session.createSQLQuery(sql);
15380    
15381                            if (getDB().isSupportsInlineDistinct()) {
15382                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15383                            }
15384                            else {
15385                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15386                            }
15387    
15388                            QueryPos qPos = QueryPos.getInstance(q);
15389    
15390                            qPos.add(groupId);
15391    
15392                            if (bindDisplayDate) {
15393                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
15394                            }
15395    
15396                            qPos.add(status);
15397    
15398                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
15399                    }
15400                    catch (Exception e) {
15401                            throw processException(e);
15402                    }
15403                    finally {
15404                            closeSession(session);
15405                    }
15406            }
15407    
15408            /**
15409             * 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;.
15410             *
15411             * @param entryId the primary key of the current blogs entry
15412             * @param groupId the group ID
15413             * @param displayDate the display date
15414             * @param status the status
15415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15416             * @return the previous, current, and next blogs entry
15417             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15418             * @throws SystemException if a system exception occurred
15419             */
15420            @Override
15421            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
15422                    long groupId, Date displayDate, int status,
15423                    OrderByComparator orderByComparator)
15424                    throws NoSuchEntryException, SystemException {
15425                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15426                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
15427                                    status, orderByComparator);
15428                    }
15429    
15430                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15431    
15432                    Session session = null;
15433    
15434                    try {
15435                            session = openSession();
15436    
15437                            BlogsEntry[] array = new BlogsEntryImpl[3];
15438    
15439                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
15440                                            groupId, displayDate, status, orderByComparator, true);
15441    
15442                            array[1] = blogsEntry;
15443    
15444                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
15445                                            groupId, displayDate, status, orderByComparator, false);
15446    
15447                            return array;
15448                    }
15449                    catch (Exception e) {
15450                            throw processException(e);
15451                    }
15452                    finally {
15453                            closeSession(session);
15454                    }
15455            }
15456    
15457            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
15458                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
15459                    OrderByComparator orderByComparator, boolean previous) {
15460                    StringBundler query = null;
15461    
15462                    if (orderByComparator != null) {
15463                            query = new StringBundler(6 +
15464                                            (orderByComparator.getOrderByFields().length * 6));
15465                    }
15466                    else {
15467                            query = new StringBundler(3);
15468                    }
15469    
15470                    if (getDB().isSupportsInlineDistinct()) {
15471                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
15472                    }
15473                    else {
15474                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
15475                    }
15476    
15477                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15478    
15479                    boolean bindDisplayDate = false;
15480    
15481                    if (displayDate == null) {
15482                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15483                    }
15484                    else {
15485                            bindDisplayDate = true;
15486    
15487                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15488                    }
15489    
15490                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15491    
15492                    if (!getDB().isSupportsInlineDistinct()) {
15493                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
15494                    }
15495    
15496                    if (orderByComparator != null) {
15497                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15498    
15499                            if (orderByConditionFields.length > 0) {
15500                                    query.append(WHERE_AND);
15501                            }
15502    
15503                            for (int i = 0; i < orderByConditionFields.length; i++) {
15504                                    if (getDB().isSupportsInlineDistinct()) {
15505                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15506                                    }
15507                                    else {
15508                                            query.append(_ORDER_BY_ENTITY_TABLE);
15509                                    }
15510    
15511                                    query.append(orderByConditionFields[i]);
15512    
15513                                    if ((i + 1) < orderByConditionFields.length) {
15514                                            if (orderByComparator.isAscending() ^ previous) {
15515                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15516                                            }
15517                                            else {
15518                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15519                                            }
15520                                    }
15521                                    else {
15522                                            if (orderByComparator.isAscending() ^ previous) {
15523                                                    query.append(WHERE_GREATER_THAN);
15524                                            }
15525                                            else {
15526                                                    query.append(WHERE_LESSER_THAN);
15527                                            }
15528                                    }
15529                            }
15530    
15531                            query.append(ORDER_BY_CLAUSE);
15532    
15533                            String[] orderByFields = orderByComparator.getOrderByFields();
15534    
15535                            for (int i = 0; i < orderByFields.length; i++) {
15536                                    if (getDB().isSupportsInlineDistinct()) {
15537                                            query.append(_ORDER_BY_ENTITY_ALIAS);
15538                                    }
15539                                    else {
15540                                            query.append(_ORDER_BY_ENTITY_TABLE);
15541                                    }
15542    
15543                                    query.append(orderByFields[i]);
15544    
15545                                    if ((i + 1) < orderByFields.length) {
15546                                            if (orderByComparator.isAscending() ^ previous) {
15547                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15548                                            }
15549                                            else {
15550                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15551                                            }
15552                                    }
15553                                    else {
15554                                            if (orderByComparator.isAscending() ^ previous) {
15555                                                    query.append(ORDER_BY_ASC);
15556                                            }
15557                                            else {
15558                                                    query.append(ORDER_BY_DESC);
15559                                            }
15560                                    }
15561                            }
15562                    }
15563                    else {
15564                            if (getDB().isSupportsInlineDistinct()) {
15565                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15566                            }
15567                            else {
15568                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
15569                            }
15570                    }
15571    
15572                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15573                                    BlogsEntry.class.getName(),
15574                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15575    
15576                    SQLQuery q = session.createSQLQuery(sql);
15577    
15578                    q.setFirstResult(0);
15579                    q.setMaxResults(2);
15580    
15581                    if (getDB().isSupportsInlineDistinct()) {
15582                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
15583                    }
15584                    else {
15585                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
15586                    }
15587    
15588                    QueryPos qPos = QueryPos.getInstance(q);
15589    
15590                    qPos.add(groupId);
15591    
15592                    if (bindDisplayDate) {
15593                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15594                    }
15595    
15596                    qPos.add(status);
15597    
15598                    if (orderByComparator != null) {
15599                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15600    
15601                            for (Object value : values) {
15602                                    qPos.add(value);
15603                            }
15604                    }
15605    
15606                    List<BlogsEntry> list = q.list();
15607    
15608                    if (list.size() == 2) {
15609                            return list.get(1);
15610                    }
15611                    else {
15612                            return null;
15613                    }
15614            }
15615    
15616            /**
15617             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15618             *
15619             * @param groupId the group ID
15620             * @param displayDate the display date
15621             * @param status the status
15622             * @throws SystemException if a system exception occurred
15623             */
15624            @Override
15625            public void removeByG_LtD_S(long groupId, Date displayDate, int status)
15626                    throws SystemException {
15627                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
15628                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15629                            remove(blogsEntry);
15630                    }
15631            }
15632    
15633            /**
15634             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15635             *
15636             * @param groupId the group ID
15637             * @param displayDate the display date
15638             * @param status the status
15639             * @return the number of matching blogs entries
15640             * @throws SystemException if a system exception occurred
15641             */
15642            @Override
15643            public int countByG_LtD_S(long groupId, Date displayDate, int status)
15644                    throws SystemException {
15645                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
15646    
15647                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
15648    
15649                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15650                                    this);
15651    
15652                    if (count == null) {
15653                            StringBundler query = new StringBundler(4);
15654    
15655                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15656    
15657                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15658    
15659                            boolean bindDisplayDate = false;
15660    
15661                            if (displayDate == null) {
15662                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15663                            }
15664                            else {
15665                                    bindDisplayDate = true;
15666    
15667                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15668                            }
15669    
15670                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15671    
15672                            String sql = query.toString();
15673    
15674                            Session session = null;
15675    
15676                            try {
15677                                    session = openSession();
15678    
15679                                    Query q = session.createQuery(sql);
15680    
15681                                    QueryPos qPos = QueryPos.getInstance(q);
15682    
15683                                    qPos.add(groupId);
15684    
15685                                    if (bindDisplayDate) {
15686                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15687                                    }
15688    
15689                                    qPos.add(status);
15690    
15691                                    count = (Long)q.uniqueResult();
15692    
15693                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15694                            }
15695                            catch (Exception e) {
15696                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15697    
15698                                    throw processException(e);
15699                            }
15700                            finally {
15701                                    closeSession(session);
15702                            }
15703                    }
15704    
15705                    return count.intValue();
15706            }
15707    
15708            /**
15709             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
15710             *
15711             * @param groupId the group ID
15712             * @param displayDate the display date
15713             * @param status the status
15714             * @return the number of matching blogs entries that the user has permission to view
15715             * @throws SystemException if a system exception occurred
15716             */
15717            @Override
15718            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status)
15719                    throws SystemException {
15720                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
15721                            return countByG_LtD_S(groupId, displayDate, status);
15722                    }
15723    
15724                    StringBundler query = new StringBundler(4);
15725    
15726                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
15727    
15728                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
15729    
15730                    boolean bindDisplayDate = false;
15731    
15732                    if (displayDate == null) {
15733                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
15734                    }
15735                    else {
15736                            bindDisplayDate = true;
15737    
15738                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
15739                    }
15740    
15741                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
15742    
15743                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
15744                                    BlogsEntry.class.getName(),
15745                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
15746    
15747                    Session session = null;
15748    
15749                    try {
15750                            session = openSession();
15751    
15752                            SQLQuery q = session.createSQLQuery(sql);
15753    
15754                            q.addScalar(COUNT_COLUMN_NAME,
15755                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
15756    
15757                            QueryPos qPos = QueryPos.getInstance(q);
15758    
15759                            qPos.add(groupId);
15760    
15761                            if (bindDisplayDate) {
15762                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
15763                            }
15764    
15765                            qPos.add(status);
15766    
15767                            Long count = (Long)q.uniqueResult();
15768    
15769                            return count.intValue();
15770                    }
15771                    catch (Exception e) {
15772                            throw processException(e);
15773                    }
15774                    finally {
15775                            closeSession(session);
15776                    }
15777            }
15778    
15779            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
15780            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
15781            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15782            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15783            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
15784                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15785                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15786                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
15787                            new String[] {
15788                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15789                                    Integer.class.getName(),
15790                                    
15791                            Integer.class.getName(), Integer.class.getName(),
15792                                    OrderByComparator.class.getName()
15793                            });
15794            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
15795                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15796                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15797                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
15798                            new String[] {
15799                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15800                                    Integer.class.getName()
15801                            });
15802    
15803            /**
15804             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15805             *
15806             * @param groupId the group ID
15807             * @param userId the user ID
15808             * @param displayDate the display date
15809             * @param status the status
15810             * @return the matching blogs entries
15811             * @throws SystemException if a system exception occurred
15812             */
15813            @Override
15814            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15815                    Date displayDate, int status) throws SystemException {
15816                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
15817                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15818            }
15819    
15820            /**
15821             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15822             *
15823             * <p>
15824             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15825             * </p>
15826             *
15827             * @param groupId the group ID
15828             * @param userId the user ID
15829             * @param displayDate the display date
15830             * @param status the status
15831             * @param start the lower bound of the range of blogs entries
15832             * @param end the upper bound of the range of blogs entries (not inclusive)
15833             * @return the range of matching blogs entries
15834             * @throws SystemException if a system exception occurred
15835             */
15836            @Override
15837            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15838                    Date displayDate, int status, int start, int end)
15839                    throws SystemException {
15840                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
15841                            end, null);
15842            }
15843    
15844            /**
15845             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15846             *
15847             * <p>
15848             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15849             * </p>
15850             *
15851             * @param groupId the group ID
15852             * @param userId the user ID
15853             * @param displayDate the display date
15854             * @param status the status
15855             * @param start the lower bound of the range of blogs entries
15856             * @param end the upper bound of the range of blogs entries (not inclusive)
15857             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15858             * @return the ordered range of matching blogs entries
15859             * @throws SystemException if a system exception occurred
15860             */
15861            @Override
15862            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
15863                    Date displayDate, int status, int start, int end,
15864                    OrderByComparator orderByComparator) throws SystemException {
15865                    boolean pagination = true;
15866                    FinderPath finderPath = null;
15867                    Object[] finderArgs = null;
15868    
15869                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
15870                    finderArgs = new Object[] {
15871                                    groupId, userId, displayDate, status,
15872                                    
15873                                    start, end, orderByComparator
15874                            };
15875    
15876                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
15877                                    finderArgs, this);
15878    
15879                    if ((list != null) && !list.isEmpty()) {
15880                            for (BlogsEntry blogsEntry : list) {
15881                                    if ((groupId != blogsEntry.getGroupId()) ||
15882                                                    (userId != blogsEntry.getUserId()) ||
15883                                                    !Validator.equals(displayDate,
15884                                                            blogsEntry.getDisplayDate()) ||
15885                                                    (status != blogsEntry.getStatus())) {
15886                                            list = null;
15887    
15888                                            break;
15889                                    }
15890                            }
15891                    }
15892    
15893                    if (list == null) {
15894                            StringBundler query = null;
15895    
15896                            if (orderByComparator != null) {
15897                                    query = new StringBundler(6 +
15898                                                    (orderByComparator.getOrderByFields().length * 3));
15899                            }
15900                            else {
15901                                    query = new StringBundler(6);
15902                            }
15903    
15904                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15905    
15906                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
15907    
15908                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
15909    
15910                            boolean bindDisplayDate = false;
15911    
15912                            if (displayDate == null) {
15913                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
15914                            }
15915                            else {
15916                                    bindDisplayDate = true;
15917    
15918                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
15919                            }
15920    
15921                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
15922    
15923                            if (orderByComparator != null) {
15924                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15925                                            orderByComparator);
15926                            }
15927                            else
15928                             if (pagination) {
15929                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15930                            }
15931    
15932                            String sql = query.toString();
15933    
15934                            Session session = null;
15935    
15936                            try {
15937                                    session = openSession();
15938    
15939                                    Query q = session.createQuery(sql);
15940    
15941                                    QueryPos qPos = QueryPos.getInstance(q);
15942    
15943                                    qPos.add(groupId);
15944    
15945                                    qPos.add(userId);
15946    
15947                                    if (bindDisplayDate) {
15948                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
15949                                    }
15950    
15951                                    qPos.add(status);
15952    
15953                                    if (!pagination) {
15954                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15955                                                            start, end, false);
15956    
15957                                            Collections.sort(list);
15958    
15959                                            list = new UnmodifiableList<BlogsEntry>(list);
15960                                    }
15961                                    else {
15962                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15963                                                            start, end);
15964                                    }
15965    
15966                                    cacheResult(list);
15967    
15968                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15969                            }
15970                            catch (Exception e) {
15971                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15972    
15973                                    throw processException(e);
15974                            }
15975                            finally {
15976                                    closeSession(session);
15977                            }
15978                    }
15979    
15980                    return list;
15981            }
15982    
15983            /**
15984             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15985             *
15986             * @param groupId the group ID
15987             * @param userId the user ID
15988             * @param displayDate the display date
15989             * @param status the status
15990             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15991             * @return the first matching blogs entry
15992             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15993             * @throws SystemException if a system exception occurred
15994             */
15995            @Override
15996            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
15997                    Date displayDate, int status, OrderByComparator orderByComparator)
15998                    throws NoSuchEntryException, SystemException {
15999                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
16000                                    displayDate, status, orderByComparator);
16001    
16002                    if (blogsEntry != null) {
16003                            return blogsEntry;
16004                    }
16005    
16006                    StringBundler msg = new StringBundler(10);
16007    
16008                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16009    
16010                    msg.append("groupId=");
16011                    msg.append(groupId);
16012    
16013                    msg.append(", userId=");
16014                    msg.append(userId);
16015    
16016                    msg.append(", displayDate=");
16017                    msg.append(displayDate);
16018    
16019                    msg.append(", status=");
16020                    msg.append(status);
16021    
16022                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16023    
16024                    throw new NoSuchEntryException(msg.toString());
16025            }
16026    
16027            /**
16028             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16029             *
16030             * @param groupId the group ID
16031             * @param userId the user ID
16032             * @param displayDate the display date
16033             * @param status the status
16034             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16035             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16036             * @throws SystemException if a system exception occurred
16037             */
16038            @Override
16039            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
16040                    Date displayDate, int status, OrderByComparator orderByComparator)
16041                    throws SystemException {
16042                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16043                                    displayDate, status, 0, 1, orderByComparator);
16044    
16045                    if (!list.isEmpty()) {
16046                            return list.get(0);
16047                    }
16048    
16049                    return null;
16050            }
16051    
16052            /**
16053             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16054             *
16055             * @param groupId the group ID
16056             * @param userId the user ID
16057             * @param displayDate the display date
16058             * @param status the status
16059             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16060             * @return the last matching blogs entry
16061             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
16062             * @throws SystemException if a system exception occurred
16063             */
16064            @Override
16065            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
16066                    Date displayDate, int status, OrderByComparator orderByComparator)
16067                    throws NoSuchEntryException, SystemException {
16068                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
16069                                    displayDate, status, orderByComparator);
16070    
16071                    if (blogsEntry != null) {
16072                            return blogsEntry;
16073                    }
16074    
16075                    StringBundler msg = new StringBundler(10);
16076    
16077                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16078    
16079                    msg.append("groupId=");
16080                    msg.append(groupId);
16081    
16082                    msg.append(", userId=");
16083                    msg.append(userId);
16084    
16085                    msg.append(", displayDate=");
16086                    msg.append(displayDate);
16087    
16088                    msg.append(", status=");
16089                    msg.append(status);
16090    
16091                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16092    
16093                    throw new NoSuchEntryException(msg.toString());
16094            }
16095    
16096            /**
16097             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16098             *
16099             * @param groupId the group ID
16100             * @param userId the user ID
16101             * @param displayDate the display date
16102             * @param status the status
16103             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16104             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16105             * @throws SystemException if a system exception occurred
16106             */
16107            @Override
16108            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
16109                    Date displayDate, int status, OrderByComparator orderByComparator)
16110                    throws SystemException {
16111                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16112    
16113                    if (count == 0) {
16114                            return null;
16115                    }
16116    
16117                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16118                                    displayDate, status, count - 1, count, orderByComparator);
16119    
16120                    if (!list.isEmpty()) {
16121                            return list.get(0);
16122                    }
16123    
16124                    return null;
16125            }
16126    
16127            /**
16128             * 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;.
16129             *
16130             * @param entryId the primary key of the current blogs entry
16131             * @param groupId the group ID
16132             * @param userId the user ID
16133             * @param displayDate the display date
16134             * @param status the status
16135             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16136             * @return the previous, current, and next blogs entry
16137             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16138             * @throws SystemException if a system exception occurred
16139             */
16140            @Override
16141            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
16142                    long groupId, long userId, Date displayDate, int status,
16143                    OrderByComparator orderByComparator)
16144                    throws NoSuchEntryException, SystemException {
16145                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16146    
16147                    Session session = null;
16148    
16149                    try {
16150                            session = openSession();
16151    
16152                            BlogsEntry[] array = new BlogsEntryImpl[3];
16153    
16154                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16155                                            groupId, userId, displayDate, status, orderByComparator,
16156                                            true);
16157    
16158                            array[1] = blogsEntry;
16159    
16160                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16161                                            groupId, userId, displayDate, status, orderByComparator,
16162                                            false);
16163    
16164                            return array;
16165                    }
16166                    catch (Exception e) {
16167                            throw processException(e);
16168                    }
16169                    finally {
16170                            closeSession(session);
16171                    }
16172            }
16173    
16174            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
16175                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16176                    int status, OrderByComparator orderByComparator, boolean previous) {
16177                    StringBundler query = null;
16178    
16179                    if (orderByComparator != null) {
16180                            query = new StringBundler(6 +
16181                                            (orderByComparator.getOrderByFields().length * 6));
16182                    }
16183                    else {
16184                            query = new StringBundler(3);
16185                    }
16186    
16187                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16188    
16189                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16190    
16191                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16192    
16193                    boolean bindDisplayDate = false;
16194    
16195                    if (displayDate == null) {
16196                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16197                    }
16198                    else {
16199                            bindDisplayDate = true;
16200    
16201                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16202                    }
16203    
16204                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16205    
16206                    if (orderByComparator != null) {
16207                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16208    
16209                            if (orderByConditionFields.length > 0) {
16210                                    query.append(WHERE_AND);
16211                            }
16212    
16213                            for (int i = 0; i < orderByConditionFields.length; i++) {
16214                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16215                                    query.append(orderByConditionFields[i]);
16216    
16217                                    if ((i + 1) < orderByConditionFields.length) {
16218                                            if (orderByComparator.isAscending() ^ previous) {
16219                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16220                                            }
16221                                            else {
16222                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16223                                            }
16224                                    }
16225                                    else {
16226                                            if (orderByComparator.isAscending() ^ previous) {
16227                                                    query.append(WHERE_GREATER_THAN);
16228                                            }
16229                                            else {
16230                                                    query.append(WHERE_LESSER_THAN);
16231                                            }
16232                                    }
16233                            }
16234    
16235                            query.append(ORDER_BY_CLAUSE);
16236    
16237                            String[] orderByFields = orderByComparator.getOrderByFields();
16238    
16239                            for (int i = 0; i < orderByFields.length; i++) {
16240                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16241                                    query.append(orderByFields[i]);
16242    
16243                                    if ((i + 1) < orderByFields.length) {
16244                                            if (orderByComparator.isAscending() ^ previous) {
16245                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16246                                            }
16247                                            else {
16248                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16249                                            }
16250                                    }
16251                                    else {
16252                                            if (orderByComparator.isAscending() ^ previous) {
16253                                                    query.append(ORDER_BY_ASC);
16254                                            }
16255                                            else {
16256                                                    query.append(ORDER_BY_DESC);
16257                                            }
16258                                    }
16259                            }
16260                    }
16261                    else {
16262                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16263                    }
16264    
16265                    String sql = query.toString();
16266    
16267                    Query q = session.createQuery(sql);
16268    
16269                    q.setFirstResult(0);
16270                    q.setMaxResults(2);
16271    
16272                    QueryPos qPos = QueryPos.getInstance(q);
16273    
16274                    qPos.add(groupId);
16275    
16276                    qPos.add(userId);
16277    
16278                    if (bindDisplayDate) {
16279                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16280                    }
16281    
16282                    qPos.add(status);
16283    
16284                    if (orderByComparator != null) {
16285                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16286    
16287                            for (Object value : values) {
16288                                    qPos.add(value);
16289                            }
16290                    }
16291    
16292                    List<BlogsEntry> list = q.list();
16293    
16294                    if (list.size() == 2) {
16295                            return list.get(1);
16296                    }
16297                    else {
16298                            return null;
16299                    }
16300            }
16301    
16302            /**
16303             * 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;.
16304             *
16305             * @param groupId the group ID
16306             * @param userId the user ID
16307             * @param displayDate the display date
16308             * @param status the status
16309             * @return the matching blogs entries that the user has permission to view
16310             * @throws SystemException if a system exception occurred
16311             */
16312            @Override
16313            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
16314                    Date displayDate, int status) throws SystemException {
16315                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
16316                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16317            }
16318    
16319            /**
16320             * 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;.
16321             *
16322             * <p>
16323             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16324             * </p>
16325             *
16326             * @param groupId the group ID
16327             * @param userId the user ID
16328             * @param displayDate the display date
16329             * @param status the status
16330             * @param start the lower bound of the range of blogs entries
16331             * @param end the upper bound of the range of blogs entries (not inclusive)
16332             * @return the range of matching blogs entries that the user has permission to view
16333             * @throws SystemException if a system exception occurred
16334             */
16335            @Override
16336            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
16337                    Date displayDate, int status, int start, int end)
16338                    throws SystemException {
16339                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
16340                            start, end, null);
16341            }
16342    
16343            /**
16344             * 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;.
16345             *
16346             * <p>
16347             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16348             * </p>
16349             *
16350             * @param groupId the group ID
16351             * @param userId the user ID
16352             * @param displayDate the display date
16353             * @param status the status
16354             * @param start the lower bound of the range of blogs entries
16355             * @param end the upper bound of the range of blogs entries (not inclusive)
16356             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16357             * @return the ordered range of matching blogs entries that the user has permission to view
16358             * @throws SystemException if a system exception occurred
16359             */
16360            @Override
16361            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
16362                    Date displayDate, int status, int start, int end,
16363                    OrderByComparator orderByComparator) throws SystemException {
16364                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16365                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
16366                                    start, end, orderByComparator);
16367                    }
16368    
16369                    StringBundler query = null;
16370    
16371                    if (orderByComparator != null) {
16372                            query = new StringBundler(6 +
16373                                            (orderByComparator.getOrderByFields().length * 3));
16374                    }
16375                    else {
16376                            query = new StringBundler(6);
16377                    }
16378    
16379                    if (getDB().isSupportsInlineDistinct()) {
16380                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16381                    }
16382                    else {
16383                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16384                    }
16385    
16386                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16387    
16388                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16389    
16390                    boolean bindDisplayDate = false;
16391    
16392                    if (displayDate == null) {
16393                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16394                    }
16395                    else {
16396                            bindDisplayDate = true;
16397    
16398                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16399                    }
16400    
16401                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16402    
16403                    if (!getDB().isSupportsInlineDistinct()) {
16404                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16405                    }
16406    
16407                    if (orderByComparator != null) {
16408                            if (getDB().isSupportsInlineDistinct()) {
16409                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16410                                            orderByComparator, true);
16411                            }
16412                            else {
16413                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16414                                            orderByComparator, true);
16415                            }
16416                    }
16417                    else {
16418                            if (getDB().isSupportsInlineDistinct()) {
16419                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16420                            }
16421                            else {
16422                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16423                            }
16424                    }
16425    
16426                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16427                                    BlogsEntry.class.getName(),
16428                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16429    
16430                    Session session = null;
16431    
16432                    try {
16433                            session = openSession();
16434    
16435                            SQLQuery q = session.createSQLQuery(sql);
16436    
16437                            if (getDB().isSupportsInlineDistinct()) {
16438                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16439                            }
16440                            else {
16441                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16442                            }
16443    
16444                            QueryPos qPos = QueryPos.getInstance(q);
16445    
16446                            qPos.add(groupId);
16447    
16448                            qPos.add(userId);
16449    
16450                            if (bindDisplayDate) {
16451                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
16452                            }
16453    
16454                            qPos.add(status);
16455    
16456                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16457                    }
16458                    catch (Exception e) {
16459                            throw processException(e);
16460                    }
16461                    finally {
16462                            closeSession(session);
16463                    }
16464            }
16465    
16466            /**
16467             * 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;.
16468             *
16469             * @param entryId the primary key of the current blogs entry
16470             * @param groupId the group ID
16471             * @param userId the user ID
16472             * @param displayDate the display date
16473             * @param status the status
16474             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16475             * @return the previous, current, and next blogs entry
16476             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16477             * @throws SystemException if a system exception occurred
16478             */
16479            @Override
16480            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
16481                    long groupId, long userId, Date displayDate, int status,
16482                    OrderByComparator orderByComparator)
16483                    throws NoSuchEntryException, SystemException {
16484                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16485                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
16486                                    displayDate, status, orderByComparator);
16487                    }
16488    
16489                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16490    
16491                    Session session = null;
16492    
16493                    try {
16494                            session = openSession();
16495    
16496                            BlogsEntry[] array = new BlogsEntryImpl[3];
16497    
16498                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16499                                            groupId, userId, displayDate, status, orderByComparator,
16500                                            true);
16501    
16502                            array[1] = blogsEntry;
16503    
16504                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16505                                            groupId, userId, displayDate, status, orderByComparator,
16506                                            false);
16507    
16508                            return array;
16509                    }
16510                    catch (Exception e) {
16511                            throw processException(e);
16512                    }
16513                    finally {
16514                            closeSession(session);
16515                    }
16516            }
16517    
16518            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
16519                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16520                    int status, OrderByComparator orderByComparator, boolean previous) {
16521                    StringBundler query = null;
16522    
16523                    if (orderByComparator != null) {
16524                            query = new StringBundler(6 +
16525                                            (orderByComparator.getOrderByFields().length * 6));
16526                    }
16527                    else {
16528                            query = new StringBundler(3);
16529                    }
16530    
16531                    if (getDB().isSupportsInlineDistinct()) {
16532                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16533                    }
16534                    else {
16535                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16536                    }
16537    
16538                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16539    
16540                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16541    
16542                    boolean bindDisplayDate = false;
16543    
16544                    if (displayDate == null) {
16545                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16546                    }
16547                    else {
16548                            bindDisplayDate = true;
16549    
16550                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16551                    }
16552    
16553                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16554    
16555                    if (!getDB().isSupportsInlineDistinct()) {
16556                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16557                    }
16558    
16559                    if (orderByComparator != null) {
16560                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16561    
16562                            if (orderByConditionFields.length > 0) {
16563                                    query.append(WHERE_AND);
16564                            }
16565    
16566                            for (int i = 0; i < orderByConditionFields.length; i++) {
16567                                    if (getDB().isSupportsInlineDistinct()) {
16568                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16569                                    }
16570                                    else {
16571                                            query.append(_ORDER_BY_ENTITY_TABLE);
16572                                    }
16573    
16574                                    query.append(orderByConditionFields[i]);
16575    
16576                                    if ((i + 1) < orderByConditionFields.length) {
16577                                            if (orderByComparator.isAscending() ^ previous) {
16578                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16579                                            }
16580                                            else {
16581                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16582                                            }
16583                                    }
16584                                    else {
16585                                            if (orderByComparator.isAscending() ^ previous) {
16586                                                    query.append(WHERE_GREATER_THAN);
16587                                            }
16588                                            else {
16589                                                    query.append(WHERE_LESSER_THAN);
16590                                            }
16591                                    }
16592                            }
16593    
16594                            query.append(ORDER_BY_CLAUSE);
16595    
16596                            String[] orderByFields = orderByComparator.getOrderByFields();
16597    
16598                            for (int i = 0; i < orderByFields.length; i++) {
16599                                    if (getDB().isSupportsInlineDistinct()) {
16600                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16601                                    }
16602                                    else {
16603                                            query.append(_ORDER_BY_ENTITY_TABLE);
16604                                    }
16605    
16606                                    query.append(orderByFields[i]);
16607    
16608                                    if ((i + 1) < orderByFields.length) {
16609                                            if (orderByComparator.isAscending() ^ previous) {
16610                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16611                                            }
16612                                            else {
16613                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16614                                            }
16615                                    }
16616                                    else {
16617                                            if (orderByComparator.isAscending() ^ previous) {
16618                                                    query.append(ORDER_BY_ASC);
16619                                            }
16620                                            else {
16621                                                    query.append(ORDER_BY_DESC);
16622                                            }
16623                                    }
16624                            }
16625                    }
16626                    else {
16627                            if (getDB().isSupportsInlineDistinct()) {
16628                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16629                            }
16630                            else {
16631                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16632                            }
16633                    }
16634    
16635                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16636                                    BlogsEntry.class.getName(),
16637                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16638    
16639                    SQLQuery q = session.createSQLQuery(sql);
16640    
16641                    q.setFirstResult(0);
16642                    q.setMaxResults(2);
16643    
16644                    if (getDB().isSupportsInlineDistinct()) {
16645                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16646                    }
16647                    else {
16648                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16649                    }
16650    
16651                    QueryPos qPos = QueryPos.getInstance(q);
16652    
16653                    qPos.add(groupId);
16654    
16655                    qPos.add(userId);
16656    
16657                    if (bindDisplayDate) {
16658                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16659                    }
16660    
16661                    qPos.add(status);
16662    
16663                    if (orderByComparator != null) {
16664                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16665    
16666                            for (Object value : values) {
16667                                    qPos.add(value);
16668                            }
16669                    }
16670    
16671                    List<BlogsEntry> list = q.list();
16672    
16673                    if (list.size() == 2) {
16674                            return list.get(1);
16675                    }
16676                    else {
16677                            return null;
16678                    }
16679            }
16680    
16681            /**
16682             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
16683             *
16684             * @param groupId the group ID
16685             * @param userId the user ID
16686             * @param displayDate the display date
16687             * @param status the status
16688             * @throws SystemException if a system exception occurred
16689             */
16690            @Override
16691            public void removeByG_U_LtD_NotS(long groupId, long userId,
16692                    Date displayDate, int status) throws SystemException {
16693                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
16694                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16695                            remove(blogsEntry);
16696                    }
16697            }
16698    
16699            /**
16700             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16701             *
16702             * @param groupId the group ID
16703             * @param userId the user ID
16704             * @param displayDate the display date
16705             * @param status the status
16706             * @return the number of matching blogs entries
16707             * @throws SystemException if a system exception occurred
16708             */
16709            @Override
16710            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
16711                    int status) throws SystemException {
16712                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
16713    
16714                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16715    
16716                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16717                                    this);
16718    
16719                    if (count == null) {
16720                            StringBundler query = new StringBundler(5);
16721    
16722                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16723    
16724                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16725    
16726                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16727    
16728                            boolean bindDisplayDate = false;
16729    
16730                            if (displayDate == null) {
16731                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16732                            }
16733                            else {
16734                                    bindDisplayDate = true;
16735    
16736                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16737                            }
16738    
16739                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16740    
16741                            String sql = query.toString();
16742    
16743                            Session session = null;
16744    
16745                            try {
16746                                    session = openSession();
16747    
16748                                    Query q = session.createQuery(sql);
16749    
16750                                    QueryPos qPos = QueryPos.getInstance(q);
16751    
16752                                    qPos.add(groupId);
16753    
16754                                    qPos.add(userId);
16755    
16756                                    if (bindDisplayDate) {
16757                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
16758                                    }
16759    
16760                                    qPos.add(status);
16761    
16762                                    count = (Long)q.uniqueResult();
16763    
16764                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16765                            }
16766                            catch (Exception e) {
16767                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16768    
16769                                    throw processException(e);
16770                            }
16771                            finally {
16772                                    closeSession(session);
16773                            }
16774                    }
16775    
16776                    return count.intValue();
16777            }
16778    
16779            /**
16780             * 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;.
16781             *
16782             * @param groupId the group ID
16783             * @param userId the user ID
16784             * @param displayDate the display date
16785             * @param status the status
16786             * @return the number of matching blogs entries that the user has permission to view
16787             * @throws SystemException if a system exception occurred
16788             */
16789            @Override
16790            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
16791                    Date displayDate, int status) throws SystemException {
16792                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16793                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16794                    }
16795    
16796                    StringBundler query = new StringBundler(5);
16797    
16798                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16799    
16800                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16801    
16802                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16803    
16804                    boolean bindDisplayDate = false;
16805    
16806                    if (displayDate == null) {
16807                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16808                    }
16809                    else {
16810                            bindDisplayDate = true;
16811    
16812                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16813                    }
16814    
16815                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16816    
16817                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16818                                    BlogsEntry.class.getName(),
16819                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16820    
16821                    Session session = null;
16822    
16823                    try {
16824                            session = openSession();
16825    
16826                            SQLQuery q = session.createSQLQuery(sql);
16827    
16828                            q.addScalar(COUNT_COLUMN_NAME,
16829                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16830    
16831                            QueryPos qPos = QueryPos.getInstance(q);
16832    
16833                            qPos.add(groupId);
16834    
16835                            qPos.add(userId);
16836    
16837                            if (bindDisplayDate) {
16838                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
16839                            }
16840    
16841                            qPos.add(status);
16842    
16843                            Long count = (Long)q.uniqueResult();
16844    
16845                            return count.intValue();
16846                    }
16847                    catch (Exception e) {
16848                            throw processException(e);
16849                    }
16850                    finally {
16851                            closeSession(session);
16852                    }
16853            }
16854    
16855            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
16856            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
16857            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
16858            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16859            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
16860            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
16861                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16862                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16863                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
16864                            new String[] {
16865                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16866                                    Integer.class.getName(),
16867                                    
16868                            Integer.class.getName(), Integer.class.getName(),
16869                                    OrderByComparator.class.getName()
16870                            });
16871            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16872                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16873                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16874                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16875                            new String[] {
16876                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16877                                    Integer.class.getName()
16878                            });
16879    
16880            /**
16881             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16882             *
16883             * @param groupId the group ID
16884             * @param userId the user ID
16885             * @param displayDate the display date
16886             * @param status the status
16887             * @return the matching blogs entries
16888             * @throws SystemException if a system exception occurred
16889             */
16890            @Override
16891            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16892                    Date displayDate, int status) throws SystemException {
16893                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16894                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16895            }
16896    
16897            /**
16898             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16899             *
16900             * <p>
16901             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16902             * </p>
16903             *
16904             * @param groupId the group ID
16905             * @param userId the user ID
16906             * @param displayDate the display date
16907             * @param status the status
16908             * @param start the lower bound of the range of blogs entries
16909             * @param end the upper bound of the range of blogs entries (not inclusive)
16910             * @return the range of matching blogs entries
16911             * @throws SystemException if a system exception occurred
16912             */
16913            @Override
16914            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16915                    Date displayDate, int status, int start, int end)
16916                    throws SystemException {
16917                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16918                            end, null);
16919            }
16920    
16921            /**
16922             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16923             *
16924             * <p>
16925             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16926             * </p>
16927             *
16928             * @param groupId the group ID
16929             * @param userId the user ID
16930             * @param displayDate the display date
16931             * @param status the status
16932             * @param start the lower bound of the range of blogs entries
16933             * @param end the upper bound of the range of blogs entries (not inclusive)
16934             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16935             * @return the ordered range of matching blogs entries
16936             * @throws SystemException if a system exception occurred
16937             */
16938            @Override
16939            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16940                    Date displayDate, int status, int start, int end,
16941                    OrderByComparator orderByComparator) throws SystemException {
16942                    boolean pagination = true;
16943                    FinderPath finderPath = null;
16944                    Object[] finderArgs = null;
16945    
16946                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16947                    finderArgs = new Object[] {
16948                                    groupId, userId, displayDate, status,
16949                                    
16950                                    start, end, orderByComparator
16951                            };
16952    
16953                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
16954                                    finderArgs, this);
16955    
16956                    if ((list != null) && !list.isEmpty()) {
16957                            for (BlogsEntry blogsEntry : list) {
16958                                    if ((groupId != blogsEntry.getGroupId()) ||
16959                                                    (userId != blogsEntry.getUserId()) ||
16960                                                    !Validator.equals(displayDate,
16961                                                            blogsEntry.getDisplayDate()) ||
16962                                                    (status != blogsEntry.getStatus())) {
16963                                            list = null;
16964    
16965                                            break;
16966                                    }
16967                            }
16968                    }
16969    
16970                    if (list == null) {
16971                            StringBundler query = null;
16972    
16973                            if (orderByComparator != null) {
16974                                    query = new StringBundler(6 +
16975                                                    (orderByComparator.getOrderByFields().length * 3));
16976                            }
16977                            else {
16978                                    query = new StringBundler(6);
16979                            }
16980    
16981                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16982    
16983                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16984    
16985                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16986    
16987                            boolean bindDisplayDate = false;
16988    
16989                            if (displayDate == null) {
16990                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16991                            }
16992                            else {
16993                                    bindDisplayDate = true;
16994    
16995                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16996                            }
16997    
16998                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16999    
17000                            if (orderByComparator != null) {
17001                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17002                                            orderByComparator);
17003                            }
17004                            else
17005                             if (pagination) {
17006                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17007                            }
17008    
17009                            String sql = query.toString();
17010    
17011                            Session session = null;
17012    
17013                            try {
17014                                    session = openSession();
17015    
17016                                    Query q = session.createQuery(sql);
17017    
17018                                    QueryPos qPos = QueryPos.getInstance(q);
17019    
17020                                    qPos.add(groupId);
17021    
17022                                    qPos.add(userId);
17023    
17024                                    if (bindDisplayDate) {
17025                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17026                                    }
17027    
17028                                    qPos.add(status);
17029    
17030                                    if (!pagination) {
17031                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17032                                                            start, end, false);
17033    
17034                                            Collections.sort(list);
17035    
17036                                            list = new UnmodifiableList<BlogsEntry>(list);
17037                                    }
17038                                    else {
17039                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17040                                                            start, end);
17041                                    }
17042    
17043                                    cacheResult(list);
17044    
17045                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
17046                            }
17047                            catch (Exception e) {
17048                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17049    
17050                                    throw processException(e);
17051                            }
17052                            finally {
17053                                    closeSession(session);
17054                            }
17055                    }
17056    
17057                    return list;
17058            }
17059    
17060            /**
17061             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17062             *
17063             * @param groupId the group ID
17064             * @param userId the user ID
17065             * @param displayDate the display date
17066             * @param status the status
17067             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17068             * @return the first matching blogs entry
17069             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
17070             * @throws SystemException if a system exception occurred
17071             */
17072            @Override
17073            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
17074                    Date displayDate, int status, OrderByComparator orderByComparator)
17075                    throws NoSuchEntryException, SystemException {
17076                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
17077                                    displayDate, status, orderByComparator);
17078    
17079                    if (blogsEntry != null) {
17080                            return blogsEntry;
17081                    }
17082    
17083                    StringBundler msg = new StringBundler(10);
17084    
17085                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17086    
17087                    msg.append("groupId=");
17088                    msg.append(groupId);
17089    
17090                    msg.append(", userId=");
17091                    msg.append(userId);
17092    
17093                    msg.append(", displayDate=");
17094                    msg.append(displayDate);
17095    
17096                    msg.append(", status=");
17097                    msg.append(status);
17098    
17099                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17100    
17101                    throw new NoSuchEntryException(msg.toString());
17102            }
17103    
17104            /**
17105             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17106             *
17107             * @param groupId the group ID
17108             * @param userId the user ID
17109             * @param displayDate the display date
17110             * @param status the status
17111             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17112             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17113             * @throws SystemException if a system exception occurred
17114             */
17115            @Override
17116            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
17117                    Date displayDate, int status, OrderByComparator orderByComparator)
17118                    throws SystemException {
17119                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
17120                                    status, 0, 1, orderByComparator);
17121    
17122                    if (!list.isEmpty()) {
17123                            return list.get(0);
17124                    }
17125    
17126                    return null;
17127            }
17128    
17129            /**
17130             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17131             *
17132             * @param groupId the group ID
17133             * @param userId the user ID
17134             * @param displayDate the display date
17135             * @param status the status
17136             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17137             * @return the last matching blogs entry
17138             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
17139             * @throws SystemException if a system exception occurred
17140             */
17141            @Override
17142            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
17143                    Date displayDate, int status, OrderByComparator orderByComparator)
17144                    throws NoSuchEntryException, SystemException {
17145                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
17146                                    displayDate, status, orderByComparator);
17147    
17148                    if (blogsEntry != null) {
17149                            return blogsEntry;
17150                    }
17151    
17152                    StringBundler msg = new StringBundler(10);
17153    
17154                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17155    
17156                    msg.append("groupId=");
17157                    msg.append(groupId);
17158    
17159                    msg.append(", userId=");
17160                    msg.append(userId);
17161    
17162                    msg.append(", displayDate=");
17163                    msg.append(displayDate);
17164    
17165                    msg.append(", status=");
17166                    msg.append(status);
17167    
17168                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17169    
17170                    throw new NoSuchEntryException(msg.toString());
17171            }
17172    
17173            /**
17174             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17175             *
17176             * @param groupId the group ID
17177             * @param userId the user ID
17178             * @param displayDate the display date
17179             * @param status the status
17180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17181             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17182             * @throws SystemException if a system exception occurred
17183             */
17184            @Override
17185            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
17186                    Date displayDate, int status, OrderByComparator orderByComparator)
17187                    throws SystemException {
17188                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
17189    
17190                    if (count == 0) {
17191                            return null;
17192                    }
17193    
17194                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
17195                                    status, count - 1, count, orderByComparator);
17196    
17197                    if (!list.isEmpty()) {
17198                            return list.get(0);
17199                    }
17200    
17201                    return null;
17202            }
17203    
17204            /**
17205             * 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;.
17206             *
17207             * @param entryId the primary key of the current blogs entry
17208             * @param groupId the group ID
17209             * @param userId the user ID
17210             * @param displayDate the display date
17211             * @param status the status
17212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17213             * @return the previous, current, and next blogs entry
17214             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17215             * @throws SystemException if a system exception occurred
17216             */
17217            @Override
17218            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
17219                    long userId, Date displayDate, int status,
17220                    OrderByComparator orderByComparator)
17221                    throws NoSuchEntryException, SystemException {
17222                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17223    
17224                    Session session = null;
17225    
17226                    try {
17227                            session = openSession();
17228    
17229                            BlogsEntry[] array = new BlogsEntryImpl[3];
17230    
17231                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
17232                                            userId, displayDate, status, orderByComparator, true);
17233    
17234                            array[1] = blogsEntry;
17235    
17236                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
17237                                            userId, displayDate, status, orderByComparator, false);
17238    
17239                            return array;
17240                    }
17241                    catch (Exception e) {
17242                            throw processException(e);
17243                    }
17244                    finally {
17245                            closeSession(session);
17246                    }
17247            }
17248    
17249            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
17250                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17251                    int status, OrderByComparator orderByComparator, boolean previous) {
17252                    StringBundler query = null;
17253    
17254                    if (orderByComparator != null) {
17255                            query = new StringBundler(6 +
17256                                            (orderByComparator.getOrderByFields().length * 6));
17257                    }
17258                    else {
17259                            query = new StringBundler(3);
17260                    }
17261    
17262                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17263    
17264                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17265    
17266                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17267    
17268                    boolean bindDisplayDate = false;
17269    
17270                    if (displayDate == null) {
17271                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17272                    }
17273                    else {
17274                            bindDisplayDate = true;
17275    
17276                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17277                    }
17278    
17279                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17280    
17281                    if (orderByComparator != null) {
17282                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17283    
17284                            if (orderByConditionFields.length > 0) {
17285                                    query.append(WHERE_AND);
17286                            }
17287    
17288                            for (int i = 0; i < orderByConditionFields.length; i++) {
17289                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17290                                    query.append(orderByConditionFields[i]);
17291    
17292                                    if ((i + 1) < orderByConditionFields.length) {
17293                                            if (orderByComparator.isAscending() ^ previous) {
17294                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17295                                            }
17296                                            else {
17297                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17298                                            }
17299                                    }
17300                                    else {
17301                                            if (orderByComparator.isAscending() ^ previous) {
17302                                                    query.append(WHERE_GREATER_THAN);
17303                                            }
17304                                            else {
17305                                                    query.append(WHERE_LESSER_THAN);
17306                                            }
17307                                    }
17308                            }
17309    
17310                            query.append(ORDER_BY_CLAUSE);
17311    
17312                            String[] orderByFields = orderByComparator.getOrderByFields();
17313    
17314                            for (int i = 0; i < orderByFields.length; i++) {
17315                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17316                                    query.append(orderByFields[i]);
17317    
17318                                    if ((i + 1) < orderByFields.length) {
17319                                            if (orderByComparator.isAscending() ^ previous) {
17320                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17321                                            }
17322                                            else {
17323                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17324                                            }
17325                                    }
17326                                    else {
17327                                            if (orderByComparator.isAscending() ^ previous) {
17328                                                    query.append(ORDER_BY_ASC);
17329                                            }
17330                                            else {
17331                                                    query.append(ORDER_BY_DESC);
17332                                            }
17333                                    }
17334                            }
17335                    }
17336                    else {
17337                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17338                    }
17339    
17340                    String sql = query.toString();
17341    
17342                    Query q = session.createQuery(sql);
17343    
17344                    q.setFirstResult(0);
17345                    q.setMaxResults(2);
17346    
17347                    QueryPos qPos = QueryPos.getInstance(q);
17348    
17349                    qPos.add(groupId);
17350    
17351                    qPos.add(userId);
17352    
17353                    if (bindDisplayDate) {
17354                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17355                    }
17356    
17357                    qPos.add(status);
17358    
17359                    if (orderByComparator != null) {
17360                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17361    
17362                            for (Object value : values) {
17363                                    qPos.add(value);
17364                            }
17365                    }
17366    
17367                    List<BlogsEntry> list = q.list();
17368    
17369                    if (list.size() == 2) {
17370                            return list.get(1);
17371                    }
17372                    else {
17373                            return null;
17374                    }
17375            }
17376    
17377            /**
17378             * 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;.
17379             *
17380             * @param groupId the group ID
17381             * @param userId the user ID
17382             * @param displayDate the display date
17383             * @param status the status
17384             * @return the matching blogs entries that the user has permission to view
17385             * @throws SystemException if a system exception occurred
17386             */
17387            @Override
17388            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17389                    Date displayDate, int status) throws SystemException {
17390                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17391                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17392            }
17393    
17394            /**
17395             * 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;.
17396             *
17397             * <p>
17398             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
17399             * </p>
17400             *
17401             * @param groupId the group ID
17402             * @param userId the user ID
17403             * @param displayDate the display date
17404             * @param status the status
17405             * @param start the lower bound of the range of blogs entries
17406             * @param end the upper bound of the range of blogs entries (not inclusive)
17407             * @return the range of matching blogs entries that the user has permission to view
17408             * @throws SystemException if a system exception occurred
17409             */
17410            @Override
17411            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17412                    Date displayDate, int status, int start, int end)
17413                    throws SystemException {
17414                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17415                            start, end, null);
17416            }
17417    
17418            /**
17419             * 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;.
17420             *
17421             * <p>
17422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
17423             * </p>
17424             *
17425             * @param groupId the group ID
17426             * @param userId the user ID
17427             * @param displayDate the display date
17428             * @param status the status
17429             * @param start the lower bound of the range of blogs entries
17430             * @param end the upper bound of the range of blogs entries (not inclusive)
17431             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17432             * @return the ordered range of matching blogs entries that the user has permission to view
17433             * @throws SystemException if a system exception occurred
17434             */
17435            @Override
17436            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17437                    Date displayDate, int status, int start, int end,
17438                    OrderByComparator orderByComparator) throws SystemException {
17439                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17440                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
17441                                    end, orderByComparator);
17442                    }
17443    
17444                    StringBundler query = null;
17445    
17446                    if (orderByComparator != null) {
17447                            query = new StringBundler(6 +
17448                                            (orderByComparator.getOrderByFields().length * 3));
17449                    }
17450                    else {
17451                            query = new StringBundler(6);
17452                    }
17453    
17454                    if (getDB().isSupportsInlineDistinct()) {
17455                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17456                    }
17457                    else {
17458                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17459                    }
17460    
17461                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17462    
17463                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17464    
17465                    boolean bindDisplayDate = false;
17466    
17467                    if (displayDate == null) {
17468                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17469                    }
17470                    else {
17471                            bindDisplayDate = true;
17472    
17473                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17474                    }
17475    
17476                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17477    
17478                    if (!getDB().isSupportsInlineDistinct()) {
17479                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17480                    }
17481    
17482                    if (orderByComparator != null) {
17483                            if (getDB().isSupportsInlineDistinct()) {
17484                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17485                                            orderByComparator, true);
17486                            }
17487                            else {
17488                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17489                                            orderByComparator, true);
17490                            }
17491                    }
17492                    else {
17493                            if (getDB().isSupportsInlineDistinct()) {
17494                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17495                            }
17496                            else {
17497                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17498                            }
17499                    }
17500    
17501                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17502                                    BlogsEntry.class.getName(),
17503                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17504    
17505                    Session session = null;
17506    
17507                    try {
17508                            session = openSession();
17509    
17510                            SQLQuery q = session.createSQLQuery(sql);
17511    
17512                            if (getDB().isSupportsInlineDistinct()) {
17513                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17514                            }
17515                            else {
17516                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17517                            }
17518    
17519                            QueryPos qPos = QueryPos.getInstance(q);
17520    
17521                            qPos.add(groupId);
17522    
17523                            qPos.add(userId);
17524    
17525                            if (bindDisplayDate) {
17526                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17527                            }
17528    
17529                            qPos.add(status);
17530    
17531                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17532                    }
17533                    catch (Exception e) {
17534                            throw processException(e);
17535                    }
17536                    finally {
17537                            closeSession(session);
17538                    }
17539            }
17540    
17541            /**
17542             * 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;.
17543             *
17544             * @param entryId the primary key of the current blogs entry
17545             * @param groupId the group ID
17546             * @param userId the user ID
17547             * @param displayDate the display date
17548             * @param status the status
17549             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17550             * @return the previous, current, and next blogs entry
17551             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17552             * @throws SystemException if a system exception occurred
17553             */
17554            @Override
17555            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
17556                    long groupId, long userId, Date displayDate, int status,
17557                    OrderByComparator orderByComparator)
17558                    throws NoSuchEntryException, SystemException {
17559                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17560                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
17561                                    displayDate, status, orderByComparator);
17562                    }
17563    
17564                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17565    
17566                    Session session = null;
17567    
17568                    try {
17569                            session = openSession();
17570    
17571                            BlogsEntry[] array = new BlogsEntryImpl[3];
17572    
17573                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17574                                            groupId, userId, displayDate, status, orderByComparator,
17575                                            true);
17576    
17577                            array[1] = blogsEntry;
17578    
17579                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17580                                            groupId, userId, displayDate, status, orderByComparator,
17581                                            false);
17582    
17583                            return array;
17584                    }
17585                    catch (Exception e) {
17586                            throw processException(e);
17587                    }
17588                    finally {
17589                            closeSession(session);
17590                    }
17591            }
17592    
17593            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
17594                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17595                    int status, OrderByComparator orderByComparator, boolean previous) {
17596                    StringBundler query = null;
17597    
17598                    if (orderByComparator != null) {
17599                            query = new StringBundler(6 +
17600                                            (orderByComparator.getOrderByFields().length * 6));
17601                    }
17602                    else {
17603                            query = new StringBundler(3);
17604                    }
17605    
17606                    if (getDB().isSupportsInlineDistinct()) {
17607                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17608                    }
17609                    else {
17610                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17611                    }
17612    
17613                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17614    
17615                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17616    
17617                    boolean bindDisplayDate = false;
17618    
17619                    if (displayDate == null) {
17620                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17621                    }
17622                    else {
17623                            bindDisplayDate = true;
17624    
17625                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17626                    }
17627    
17628                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17629    
17630                    if (!getDB().isSupportsInlineDistinct()) {
17631                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17632                    }
17633    
17634                    if (orderByComparator != null) {
17635                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17636    
17637                            if (orderByConditionFields.length > 0) {
17638                                    query.append(WHERE_AND);
17639                            }
17640    
17641                            for (int i = 0; i < orderByConditionFields.length; i++) {
17642                                    if (getDB().isSupportsInlineDistinct()) {
17643                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17644                                    }
17645                                    else {
17646                                            query.append(_ORDER_BY_ENTITY_TABLE);
17647                                    }
17648    
17649                                    query.append(orderByConditionFields[i]);
17650    
17651                                    if ((i + 1) < orderByConditionFields.length) {
17652                                            if (orderByComparator.isAscending() ^ previous) {
17653                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17654                                            }
17655                                            else {
17656                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17657                                            }
17658                                    }
17659                                    else {
17660                                            if (orderByComparator.isAscending() ^ previous) {
17661                                                    query.append(WHERE_GREATER_THAN);
17662                                            }
17663                                            else {
17664                                                    query.append(WHERE_LESSER_THAN);
17665                                            }
17666                                    }
17667                            }
17668    
17669                            query.append(ORDER_BY_CLAUSE);
17670    
17671                            String[] orderByFields = orderByComparator.getOrderByFields();
17672    
17673                            for (int i = 0; i < orderByFields.length; i++) {
17674                                    if (getDB().isSupportsInlineDistinct()) {
17675                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17676                                    }
17677                                    else {
17678                                            query.append(_ORDER_BY_ENTITY_TABLE);
17679                                    }
17680    
17681                                    query.append(orderByFields[i]);
17682    
17683                                    if ((i + 1) < orderByFields.length) {
17684                                            if (orderByComparator.isAscending() ^ previous) {
17685                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17686                                            }
17687                                            else {
17688                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17689                                            }
17690                                    }
17691                                    else {
17692                                            if (orderByComparator.isAscending() ^ previous) {
17693                                                    query.append(ORDER_BY_ASC);
17694                                            }
17695                                            else {
17696                                                    query.append(ORDER_BY_DESC);
17697                                            }
17698                                    }
17699                            }
17700                    }
17701                    else {
17702                            if (getDB().isSupportsInlineDistinct()) {
17703                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17704                            }
17705                            else {
17706                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17707                            }
17708                    }
17709    
17710                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17711                                    BlogsEntry.class.getName(),
17712                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17713    
17714                    SQLQuery q = session.createSQLQuery(sql);
17715    
17716                    q.setFirstResult(0);
17717                    q.setMaxResults(2);
17718    
17719                    if (getDB().isSupportsInlineDistinct()) {
17720                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17721                    }
17722                    else {
17723                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17724                    }
17725    
17726                    QueryPos qPos = QueryPos.getInstance(q);
17727    
17728                    qPos.add(groupId);
17729    
17730                    qPos.add(userId);
17731    
17732                    if (bindDisplayDate) {
17733                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17734                    }
17735    
17736                    qPos.add(status);
17737    
17738                    if (orderByComparator != null) {
17739                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17740    
17741                            for (Object value : values) {
17742                                    qPos.add(value);
17743                            }
17744                    }
17745    
17746                    List<BlogsEntry> list = q.list();
17747    
17748                    if (list.size() == 2) {
17749                            return list.get(1);
17750                    }
17751                    else {
17752                            return null;
17753                    }
17754            }
17755    
17756            /**
17757             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
17758             *
17759             * @param groupId the group ID
17760             * @param userId the user ID
17761             * @param displayDate the display date
17762             * @param status the status
17763             * @throws SystemException if a system exception occurred
17764             */
17765            @Override
17766            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
17767                    int status) throws SystemException {
17768                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
17769                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17770                            remove(blogsEntry);
17771                    }
17772            }
17773    
17774            /**
17775             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17776             *
17777             * @param groupId the group ID
17778             * @param userId the user ID
17779             * @param displayDate the display date
17780             * @param status the status
17781             * @return the number of matching blogs entries
17782             * @throws SystemException if a system exception occurred
17783             */
17784            @Override
17785            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17786                    int status) throws SystemException {
17787                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
17788    
17789                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17790    
17791                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17792                                    this);
17793    
17794                    if (count == null) {
17795                            StringBundler query = new StringBundler(5);
17796    
17797                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17798    
17799                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17800    
17801                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17802    
17803                            boolean bindDisplayDate = false;
17804    
17805                            if (displayDate == null) {
17806                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17807                            }
17808                            else {
17809                                    bindDisplayDate = true;
17810    
17811                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17812                            }
17813    
17814                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17815    
17816                            String sql = query.toString();
17817    
17818                            Session session = null;
17819    
17820                            try {
17821                                    session = openSession();
17822    
17823                                    Query q = session.createQuery(sql);
17824    
17825                                    QueryPos qPos = QueryPos.getInstance(q);
17826    
17827                                    qPos.add(groupId);
17828    
17829                                    qPos.add(userId);
17830    
17831                                    if (bindDisplayDate) {
17832                                            qPos.add(CalendarUtil.getTimestamp(displayDate));
17833                                    }
17834    
17835                                    qPos.add(status);
17836    
17837                                    count = (Long)q.uniqueResult();
17838    
17839                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17840                            }
17841                            catch (Exception e) {
17842                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17843    
17844                                    throw processException(e);
17845                            }
17846                            finally {
17847                                    closeSession(session);
17848                            }
17849                    }
17850    
17851                    return count.intValue();
17852            }
17853    
17854            /**
17855             * 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;.
17856             *
17857             * @param groupId the group ID
17858             * @param userId the user ID
17859             * @param displayDate the display date
17860             * @param status the status
17861             * @return the number of matching blogs entries that the user has permission to view
17862             * @throws SystemException if a system exception occurred
17863             */
17864            @Override
17865            public int filterCountByG_U_LtD_S(long groupId, long userId,
17866                    Date displayDate, int status) throws SystemException {
17867                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17868                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17869                    }
17870    
17871                    StringBundler query = new StringBundler(5);
17872    
17873                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17874    
17875                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17876    
17877                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17878    
17879                    boolean bindDisplayDate = false;
17880    
17881                    if (displayDate == null) {
17882                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17883                    }
17884                    else {
17885                            bindDisplayDate = true;
17886    
17887                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17888                    }
17889    
17890                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17891    
17892                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17893                                    BlogsEntry.class.getName(),
17894                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17895    
17896                    Session session = null;
17897    
17898                    try {
17899                            session = openSession();
17900    
17901                            SQLQuery q = session.createSQLQuery(sql);
17902    
17903                            q.addScalar(COUNT_COLUMN_NAME,
17904                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17905    
17906                            QueryPos qPos = QueryPos.getInstance(q);
17907    
17908                            qPos.add(groupId);
17909    
17910                            qPos.add(userId);
17911    
17912                            if (bindDisplayDate) {
17913                                    qPos.add(CalendarUtil.getTimestamp(displayDate));
17914                            }
17915    
17916                            qPos.add(status);
17917    
17918                            Long count = (Long)q.uniqueResult();
17919    
17920                            return count.intValue();
17921                    }
17922                    catch (Exception e) {
17923                            throw processException(e);
17924                    }
17925                    finally {
17926                            closeSession(session);
17927                    }
17928            }
17929    
17930            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17931            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17932            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
17933            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17934            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17935    
17936            public BlogsEntryPersistenceImpl() {
17937                    setModelClass(BlogsEntry.class);
17938            }
17939    
17940            /**
17941             * Caches the blogs entry in the entity cache if it is enabled.
17942             *
17943             * @param blogsEntry the blogs entry
17944             */
17945            @Override
17946            public void cacheResult(BlogsEntry blogsEntry) {
17947                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17948                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
17949    
17950                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
17951                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
17952                            blogsEntry);
17953    
17954                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
17955                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
17956                            blogsEntry);
17957    
17958                    blogsEntry.resetOriginalValues();
17959            }
17960    
17961            /**
17962             * Caches the blogs entries in the entity cache if it is enabled.
17963             *
17964             * @param blogsEntries the blogs entries
17965             */
17966            @Override
17967            public void cacheResult(List<BlogsEntry> blogsEntries) {
17968                    for (BlogsEntry blogsEntry : blogsEntries) {
17969                            if (EntityCacheUtil.getResult(
17970                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17971                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
17972                                    cacheResult(blogsEntry);
17973                            }
17974                            else {
17975                                    blogsEntry.resetOriginalValues();
17976                            }
17977                    }
17978            }
17979    
17980            /**
17981             * Clears the cache for all blogs entries.
17982             *
17983             * <p>
17984             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17985             * </p>
17986             */
17987            @Override
17988            public void clearCache() {
17989                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
17990                            CacheRegistryUtil.clear(BlogsEntryImpl.class.getName());
17991                    }
17992    
17993                    EntityCacheUtil.clearCache(BlogsEntryImpl.class.getName());
17994    
17995                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
17996                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17997                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17998            }
17999    
18000            /**
18001             * Clears the cache for the blogs entry.
18002             *
18003             * <p>
18004             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
18005             * </p>
18006             */
18007            @Override
18008            public void clearCache(BlogsEntry blogsEntry) {
18009                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18010                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18011    
18012                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18013                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18014    
18015                    clearUniqueFindersCache(blogsEntry);
18016            }
18017    
18018            @Override
18019            public void clearCache(List<BlogsEntry> blogsEntries) {
18020                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18021                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18022    
18023                    for (BlogsEntry blogsEntry : blogsEntries) {
18024                            EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18025                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18026    
18027                            clearUniqueFindersCache(blogsEntry);
18028                    }
18029            }
18030    
18031            protected void cacheUniqueFindersCache(BlogsEntry blogsEntry) {
18032                    if (blogsEntry.isNew()) {
18033                            Object[] args = new Object[] {
18034                                            blogsEntry.getUuid(), blogsEntry.getGroupId()
18035                                    };
18036    
18037                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18038                                    Long.valueOf(1));
18039                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18040                                    blogsEntry);
18041    
18042                            args = new Object[] {
18043                                            blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
18044                                    };
18045    
18046                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18047                                    Long.valueOf(1));
18048                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18049                                    blogsEntry);
18050                    }
18051                    else {
18052                            BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18053    
18054                            if ((blogsEntryModelImpl.getColumnBitmask() &
18055                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18056                                    Object[] args = new Object[] {
18057                                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
18058                                            };
18059    
18060                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18061                                            Long.valueOf(1));
18062                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18063                                            blogsEntry);
18064                            }
18065    
18066                            if ((blogsEntryModelImpl.getColumnBitmask() &
18067                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18068                                    Object[] args = new Object[] {
18069                                                    blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
18070                                            };
18071    
18072                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18073                                            Long.valueOf(1));
18074                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18075                                            blogsEntry);
18076                            }
18077                    }
18078            }
18079    
18080            protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
18081                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18082    
18083                    Object[] args = new Object[] {
18084                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
18085                            };
18086    
18087                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18088                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18089    
18090                    if ((blogsEntryModelImpl.getColumnBitmask() &
18091                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18092                            args = new Object[] {
18093                                            blogsEntryModelImpl.getOriginalUuid(),
18094                                            blogsEntryModelImpl.getOriginalGroupId()
18095                                    };
18096    
18097                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18098                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18099                    }
18100    
18101                    args = new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() };
18102    
18103                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18104                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18105    
18106                    if ((blogsEntryModelImpl.getColumnBitmask() &
18107                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18108                            args = new Object[] {
18109                                            blogsEntryModelImpl.getOriginalGroupId(),
18110                                            blogsEntryModelImpl.getOriginalUrlTitle()
18111                                    };
18112    
18113                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18114                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18115                    }
18116            }
18117    
18118            /**
18119             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18120             *
18121             * @param entryId the primary key for the new blogs entry
18122             * @return the new blogs entry
18123             */
18124            @Override
18125            public BlogsEntry create(long entryId) {
18126                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18127    
18128                    blogsEntry.setNew(true);
18129                    blogsEntry.setPrimaryKey(entryId);
18130    
18131                    String uuid = PortalUUIDUtil.generate();
18132    
18133                    blogsEntry.setUuid(uuid);
18134    
18135                    return blogsEntry;
18136            }
18137    
18138            /**
18139             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18140             *
18141             * @param entryId the primary key of the blogs entry
18142             * @return the blogs entry that was removed
18143             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18144             * @throws SystemException if a system exception occurred
18145             */
18146            @Override
18147            public BlogsEntry remove(long entryId)
18148                    throws NoSuchEntryException, SystemException {
18149                    return remove((Serializable)entryId);
18150            }
18151    
18152            /**
18153             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18154             *
18155             * @param primaryKey the primary key of the blogs entry
18156             * @return the blogs entry that was removed
18157             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18158             * @throws SystemException if a system exception occurred
18159             */
18160            @Override
18161            public BlogsEntry remove(Serializable primaryKey)
18162                    throws NoSuchEntryException, SystemException {
18163                    Session session = null;
18164    
18165                    try {
18166                            session = openSession();
18167    
18168                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18169                                            primaryKey);
18170    
18171                            if (blogsEntry == null) {
18172                                    if (_log.isWarnEnabled()) {
18173                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18174                                    }
18175    
18176                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18177                                            primaryKey);
18178                            }
18179    
18180                            return remove(blogsEntry);
18181                    }
18182                    catch (NoSuchEntryException nsee) {
18183                            throw nsee;
18184                    }
18185                    catch (Exception e) {
18186                            throw processException(e);
18187                    }
18188                    finally {
18189                            closeSession(session);
18190                    }
18191            }
18192    
18193            @Override
18194            protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
18195                    throws SystemException {
18196                    blogsEntry = toUnwrappedModel(blogsEntry);
18197    
18198                    Session session = null;
18199    
18200                    try {
18201                            session = openSession();
18202    
18203                            if (!session.contains(blogsEntry)) {
18204                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18205                                                    blogsEntry.getPrimaryKeyObj());
18206                            }
18207    
18208                            if (blogsEntry != null) {
18209                                    session.delete(blogsEntry);
18210                            }
18211                    }
18212                    catch (Exception e) {
18213                            throw processException(e);
18214                    }
18215                    finally {
18216                            closeSession(session);
18217                    }
18218    
18219                    if (blogsEntry != null) {
18220                            clearCache(blogsEntry);
18221                    }
18222    
18223                    return blogsEntry;
18224            }
18225    
18226            @Override
18227            public BlogsEntry updateImpl(
18228                    com.liferay.portlet.blogs.model.BlogsEntry blogsEntry)
18229                    throws SystemException {
18230                    blogsEntry = toUnwrappedModel(blogsEntry);
18231    
18232                    boolean isNew = blogsEntry.isNew();
18233    
18234                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18235    
18236                    if (Validator.isNull(blogsEntry.getUuid())) {
18237                            String uuid = PortalUUIDUtil.generate();
18238    
18239                            blogsEntry.setUuid(uuid);
18240                    }
18241    
18242                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
18243    
18244                    if (userId > 0) {
18245                            long companyId = blogsEntry.getCompanyId();
18246    
18247                            long groupId = blogsEntry.getGroupId();
18248    
18249                            long entryId = 0;
18250    
18251                            if (!isNew) {
18252                                    entryId = blogsEntry.getPrimaryKey();
18253                            }
18254    
18255                            try {
18256                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
18257                                                    userId,
18258                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18259                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
18260                                                    blogsEntry.getTitle(), null));
18261    
18262                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
18263                                                    groupId, userId,
18264                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18265                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
18266                                                    blogsEntry.getContent(), null));
18267                            }
18268                            catch (SanitizerException se) {
18269                                    throw new SystemException(se);
18270                            }
18271                    }
18272    
18273                    Session session = null;
18274    
18275                    try {
18276                            session = openSession();
18277    
18278                            if (blogsEntry.isNew()) {
18279                                    session.save(blogsEntry);
18280    
18281                                    blogsEntry.setNew(false);
18282                            }
18283                            else {
18284                                    session.merge(blogsEntry);
18285                            }
18286                    }
18287                    catch (Exception e) {
18288                            throw processException(e);
18289                    }
18290                    finally {
18291                            closeSession(session);
18292                    }
18293    
18294                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18295    
18296                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
18297                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18298                    }
18299    
18300                    else {
18301                            if ((blogsEntryModelImpl.getColumnBitmask() &
18302                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
18303                                    Object[] args = new Object[] {
18304                                                    blogsEntryModelImpl.getOriginalUuid()
18305                                            };
18306    
18307                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18308                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18309                                            args);
18310    
18311                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
18312    
18313                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18314                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18315                                            args);
18316                            }
18317    
18318                            if ((blogsEntryModelImpl.getColumnBitmask() &
18319                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
18320                                    Object[] args = new Object[] {
18321                                                    blogsEntryModelImpl.getOriginalUuid(),
18322                                                    blogsEntryModelImpl.getOriginalCompanyId()
18323                                            };
18324    
18325                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18326                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18327                                            args);
18328    
18329                                    args = new Object[] {
18330                                                    blogsEntryModelImpl.getUuid(),
18331                                                    blogsEntryModelImpl.getCompanyId()
18332                                            };
18333    
18334                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18335                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18336                                            args);
18337                            }
18338    
18339                            if ((blogsEntryModelImpl.getColumnBitmask() &
18340                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
18341                                    Object[] args = new Object[] {
18342                                                    blogsEntryModelImpl.getOriginalGroupId()
18343                                            };
18344    
18345                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18346                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18347                                            args);
18348    
18349                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
18350    
18351                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18352                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18353                                            args);
18354                            }
18355    
18356                            if ((blogsEntryModelImpl.getColumnBitmask() &
18357                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
18358                                    Object[] args = new Object[] {
18359                                                    blogsEntryModelImpl.getOriginalCompanyId()
18360                                            };
18361    
18362                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
18363                                            args);
18364                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18365                                            args);
18366    
18367                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
18368    
18369                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
18370                                            args);
18371                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18372                                            args);
18373                            }
18374    
18375                            if ((blogsEntryModelImpl.getColumnBitmask() &
18376                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
18377                                    Object[] args = new Object[] {
18378                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18379                                                    blogsEntryModelImpl.getOriginalUserId()
18380                                            };
18381    
18382                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18383                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18384                                            args);
18385    
18386                                    args = new Object[] {
18387                                                    blogsEntryModelImpl.getCompanyId(),
18388                                                    blogsEntryModelImpl.getUserId()
18389                                            };
18390    
18391                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18392                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18393                                            args);
18394                            }
18395    
18396                            if ((blogsEntryModelImpl.getColumnBitmask() &
18397                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18398                                    Object[] args = new Object[] {
18399                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18400                                                    blogsEntryModelImpl.getOriginalStatus()
18401                                            };
18402    
18403                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18404                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18405                                            args);
18406    
18407                                    args = new Object[] {
18408                                                    blogsEntryModelImpl.getCompanyId(),
18409                                                    blogsEntryModelImpl.getStatus()
18410                                            };
18411    
18412                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18413                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18414                                            args);
18415                            }
18416    
18417                            if ((blogsEntryModelImpl.getColumnBitmask() &
18418                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18419                                    Object[] args = new Object[] {
18420                                                    blogsEntryModelImpl.getOriginalGroupId(),
18421                                                    blogsEntryModelImpl.getOriginalStatus()
18422                                            };
18423    
18424                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18425                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18426                                            args);
18427    
18428                                    args = new Object[] {
18429                                                    blogsEntryModelImpl.getGroupId(),
18430                                                    blogsEntryModelImpl.getStatus()
18431                                            };
18432    
18433                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18434                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18435                                            args);
18436                            }
18437    
18438                            if ((blogsEntryModelImpl.getColumnBitmask() &
18439                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18440                                    Object[] args = new Object[] {
18441                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18442                                                    blogsEntryModelImpl.getOriginalUserId(),
18443                                                    blogsEntryModelImpl.getOriginalStatus()
18444                                            };
18445    
18446                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18447                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18448                                            args);
18449    
18450                                    args = new Object[] {
18451                                                    blogsEntryModelImpl.getCompanyId(),
18452                                                    blogsEntryModelImpl.getUserId(),
18453                                                    blogsEntryModelImpl.getStatus()
18454                                            };
18455    
18456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18457                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18458                                            args);
18459                            }
18460    
18461                            if ((blogsEntryModelImpl.getColumnBitmask() &
18462                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18463                                    Object[] args = new Object[] {
18464                                                    blogsEntryModelImpl.getOriginalGroupId(),
18465                                                    blogsEntryModelImpl.getOriginalUserId(),
18466                                                    blogsEntryModelImpl.getOriginalStatus()
18467                                            };
18468    
18469                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18470                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18471                                            args);
18472    
18473                                    args = new Object[] {
18474                                                    blogsEntryModelImpl.getGroupId(),
18475                                                    blogsEntryModelImpl.getUserId(),
18476                                                    blogsEntryModelImpl.getStatus()
18477                                            };
18478    
18479                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18480                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18481                                            args);
18482                            }
18483                    }
18484    
18485                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18486                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18487    
18488                    clearUniqueFindersCache(blogsEntry);
18489                    cacheUniqueFindersCache(blogsEntry);
18490    
18491                    return blogsEntry;
18492            }
18493    
18494            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18495                    if (blogsEntry instanceof BlogsEntryImpl) {
18496                            return blogsEntry;
18497                    }
18498    
18499                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18500    
18501                    blogsEntryImpl.setNew(blogsEntry.isNew());
18502                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18503    
18504                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
18505                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18506                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18507                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18508                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
18509                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
18510                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18511                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18512                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
18513                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18514                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
18515                    blogsEntryImpl.setContent(blogsEntry.getContent());
18516                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18517                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18518                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18519                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18520                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18521                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18522                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18523                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
18524                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18525                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18526                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18527    
18528                    return blogsEntryImpl;
18529            }
18530    
18531            /**
18532             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
18533             *
18534             * @param primaryKey the primary key of the blogs entry
18535             * @return the blogs entry
18536             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18537             * @throws SystemException if a system exception occurred
18538             */
18539            @Override
18540            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18541                    throws NoSuchEntryException, SystemException {
18542                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18543    
18544                    if (blogsEntry == null) {
18545                            if (_log.isWarnEnabled()) {
18546                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18547                            }
18548    
18549                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18550                                    primaryKey);
18551                    }
18552    
18553                    return blogsEntry;
18554            }
18555    
18556            /**
18557             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
18558             *
18559             * @param entryId the primary key of the blogs entry
18560             * @return the blogs entry
18561             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18562             * @throws SystemException if a system exception occurred
18563             */
18564            @Override
18565            public BlogsEntry findByPrimaryKey(long entryId)
18566                    throws NoSuchEntryException, SystemException {
18567                    return findByPrimaryKey((Serializable)entryId);
18568            }
18569    
18570            /**
18571             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18572             *
18573             * @param primaryKey the primary key of the blogs entry
18574             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18575             * @throws SystemException if a system exception occurred
18576             */
18577            @Override
18578            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey)
18579                    throws SystemException {
18580                    BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18581                                    BlogsEntryImpl.class, primaryKey);
18582    
18583                    if (blogsEntry == _nullBlogsEntry) {
18584                            return null;
18585                    }
18586    
18587                    if (blogsEntry == null) {
18588                            Session session = null;
18589    
18590                            try {
18591                                    session = openSession();
18592    
18593                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18594                                                    primaryKey);
18595    
18596                                    if (blogsEntry != null) {
18597                                            cacheResult(blogsEntry);
18598                                    }
18599                                    else {
18600                                            EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18601                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18602                                    }
18603                            }
18604                            catch (Exception e) {
18605                                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18606                                            BlogsEntryImpl.class, primaryKey);
18607    
18608                                    throw processException(e);
18609                            }
18610                            finally {
18611                                    closeSession(session);
18612                            }
18613                    }
18614    
18615                    return blogsEntry;
18616            }
18617    
18618            /**
18619             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18620             *
18621             * @param entryId the primary key of the blogs entry
18622             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18623             * @throws SystemException if a system exception occurred
18624             */
18625            @Override
18626            public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
18627                    return fetchByPrimaryKey((Serializable)entryId);
18628            }
18629    
18630            /**
18631             * Returns all the blogs entries.
18632             *
18633             * @return the blogs entries
18634             * @throws SystemException if a system exception occurred
18635             */
18636            @Override
18637            public List<BlogsEntry> findAll() throws SystemException {
18638                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18639            }
18640    
18641            /**
18642             * Returns a range of all the blogs entries.
18643             *
18644             * <p>
18645             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
18646             * </p>
18647             *
18648             * @param start the lower bound of the range of blogs entries
18649             * @param end the upper bound of the range of blogs entries (not inclusive)
18650             * @return the range of blogs entries
18651             * @throws SystemException if a system exception occurred
18652             */
18653            @Override
18654            public List<BlogsEntry> findAll(int start, int end)
18655                    throws SystemException {
18656                    return findAll(start, end, null);
18657            }
18658    
18659            /**
18660             * Returns an ordered range of all the blogs entries.
18661             *
18662             * <p>
18663             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
18664             * </p>
18665             *
18666             * @param start the lower bound of the range of blogs entries
18667             * @param end the upper bound of the range of blogs entries (not inclusive)
18668             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18669             * @return the ordered range of blogs entries
18670             * @throws SystemException if a system exception occurred
18671             */
18672            @Override
18673            public List<BlogsEntry> findAll(int start, int end,
18674                    OrderByComparator orderByComparator) throws SystemException {
18675                    boolean pagination = true;
18676                    FinderPath finderPath = null;
18677                    Object[] finderArgs = null;
18678    
18679                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18680                                    (orderByComparator == null)) {
18681                            pagination = false;
18682                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
18683                            finderArgs = FINDER_ARGS_EMPTY;
18684                    }
18685                    else {
18686                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
18687                            finderArgs = new Object[] { start, end, orderByComparator };
18688                    }
18689    
18690                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
18691                                    finderArgs, this);
18692    
18693                    if (list == null) {
18694                            StringBundler query = null;
18695                            String sql = null;
18696    
18697                            if (orderByComparator != null) {
18698                                    query = new StringBundler(2 +
18699                                                    (orderByComparator.getOrderByFields().length * 3));
18700    
18701                                    query.append(_SQL_SELECT_BLOGSENTRY);
18702    
18703                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18704                                            orderByComparator);
18705    
18706                                    sql = query.toString();
18707                            }
18708                            else {
18709                                    sql = _SQL_SELECT_BLOGSENTRY;
18710    
18711                                    if (pagination) {
18712                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
18713                                    }
18714                            }
18715    
18716                            Session session = null;
18717    
18718                            try {
18719                                    session = openSession();
18720    
18721                                    Query q = session.createQuery(sql);
18722    
18723                                    if (!pagination) {
18724                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18725                                                            start, end, false);
18726    
18727                                            Collections.sort(list);
18728    
18729                                            list = new UnmodifiableList<BlogsEntry>(list);
18730                                    }
18731                                    else {
18732                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18733                                                            start, end);
18734                                    }
18735    
18736                                    cacheResult(list);
18737    
18738                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18739                            }
18740                            catch (Exception e) {
18741                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18742    
18743                                    throw processException(e);
18744                            }
18745                            finally {
18746                                    closeSession(session);
18747                            }
18748                    }
18749    
18750                    return list;
18751            }
18752    
18753            /**
18754             * Removes all the blogs entries from the database.
18755             *
18756             * @throws SystemException if a system exception occurred
18757             */
18758            @Override
18759            public void removeAll() throws SystemException {
18760                    for (BlogsEntry blogsEntry : findAll()) {
18761                            remove(blogsEntry);
18762                    }
18763            }
18764    
18765            /**
18766             * Returns the number of blogs entries.
18767             *
18768             * @return the number of blogs entries
18769             * @throws SystemException if a system exception occurred
18770             */
18771            @Override
18772            public int countAll() throws SystemException {
18773                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18774                                    FINDER_ARGS_EMPTY, this);
18775    
18776                    if (count == null) {
18777                            Session session = null;
18778    
18779                            try {
18780                                    session = openSession();
18781    
18782                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
18783    
18784                                    count = (Long)q.uniqueResult();
18785    
18786                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18787                                            FINDER_ARGS_EMPTY, count);
18788                            }
18789                            catch (Exception e) {
18790                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
18791                                            FINDER_ARGS_EMPTY);
18792    
18793                                    throw processException(e);
18794                            }
18795                            finally {
18796                                    closeSession(session);
18797                            }
18798                    }
18799    
18800                    return count.intValue();
18801            }
18802    
18803            @Override
18804            protected Set<String> getBadColumnNames() {
18805                    return _badColumnNames;
18806            }
18807    
18808            /**
18809             * Initializes the blogs entry persistence.
18810             */
18811            public void afterPropertiesSet() {
18812                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
18813                                            com.liferay.portal.util.PropsUtil.get(
18814                                                    "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
18815    
18816                    if (listenerClassNames.length > 0) {
18817                            try {
18818                                    List<ModelListener<BlogsEntry>> listenersList = new ArrayList<ModelListener<BlogsEntry>>();
18819    
18820                                    for (String listenerClassName : listenerClassNames) {
18821                                            listenersList.add((ModelListener<BlogsEntry>)InstanceFactory.newInstance(
18822                                                            getClassLoader(), listenerClassName));
18823                                    }
18824    
18825                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
18826                            }
18827                            catch (Exception e) {
18828                                    _log.error(e);
18829                            }
18830                    }
18831            }
18832    
18833            public void destroy() {
18834                    EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
18835                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18836                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18837                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18838            }
18839    
18840            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
18841            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
18842            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
18843            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
18844            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
18845            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
18846            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
18847                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
18848            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
18849                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
18850            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
18851            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
18852            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
18853            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
18854            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
18855            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
18856            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
18857            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18858            private static Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
18859            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
18860                                    "uuid"
18861                            });
18862            private static BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
18863                            @Override
18864                            public Object clone() {
18865                                    return this;
18866                            }
18867    
18868                            @Override
18869                            public CacheModel<BlogsEntry> toCacheModel() {
18870                                    return _nullBlogsEntryCacheModel;
18871                            }
18872                    };
18873    
18874            private static CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
18875                            @Override
18876                            public BlogsEntry toEntityModel() {
18877                                    return _nullBlogsEntry;
18878                            }
18879                    };
18880    }