001    /**
002     * Copyright (c) 2000-present 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.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.sanitizer.Sanitizer;
032    import com.liferay.portal.kernel.sanitizer.SanitizerException;
033    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
034    import com.liferay.portal.kernel.util.ContentTypes;
035    import com.liferay.portal.kernel.util.GetterUtil;
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.Validator;
041    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
042    import com.liferay.portal.model.CacheModel;
043    import com.liferay.portal.security.auth.PrincipalThreadLocal;
044    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import com.liferay.portlet.blogs.NoSuchEntryException;
048    import com.liferay.portlet.blogs.model.BlogsEntry;
049    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
050    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
051    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
052    
053    import java.io.Serializable;
054    
055    import java.sql.Timestamp;
056    
057    import java.util.Collections;
058    import java.util.Date;
059    import java.util.HashMap;
060    import java.util.HashSet;
061    import java.util.Iterator;
062    import java.util.List;
063    import java.util.Map;
064    import java.util.Set;
065    
066    /**
067     * The persistence implementation for the blogs entry service.
068     *
069     * <p>
070     * Caching information and settings can be found in <code>portal.properties</code>
071     * </p>
072     *
073     * @author Brian Wing Shun Chan
074     * @see BlogsEntryPersistence
075     * @see BlogsEntryUtil
076     * @generated
077     */
078    @ProviderType
079    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
080            implements BlogsEntryPersistence {
081            /*
082             * NOTE FOR DEVELOPERS:
083             *
084             * 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.
085             */
086            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
087            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
088                    ".List1";
089            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
090                    ".List2";
091            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
092                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
093                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
094            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
095                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
097            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
098                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
100            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
101                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
103                            new String[] {
104                                    String.class.getName(),
105                                    
106                            Integer.class.getName(), Integer.class.getName(),
107                                    OrderByComparator.class.getName()
108                            });
109            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
110                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
112                            new String[] { String.class.getName() },
113                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
114                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
115                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
116            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
117                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
119                            new String[] { String.class.getName() });
120    
121            /**
122             * Returns all the blogs entries where uuid = &#63;.
123             *
124             * @param uuid the uuid
125             * @return the matching blogs entries
126             */
127            @Override
128            public List<BlogsEntry> findByUuid(String uuid) {
129                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
130            }
131    
132            /**
133             * Returns a range of all the blogs entries where uuid = &#63;.
134             *
135             * <p>
136             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
137             * </p>
138             *
139             * @param uuid the uuid
140             * @param start the lower bound of the range of blogs entries
141             * @param end the upper bound of the range of blogs entries (not inclusive)
142             * @return the range of matching blogs entries
143             */
144            @Override
145            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
146                    return findByUuid(uuid, start, end, null);
147            }
148    
149            /**
150             * Returns an ordered range of all the blogs entries where uuid = &#63;.
151             *
152             * <p>
153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
154             * </p>
155             *
156             * @param uuid the uuid
157             * @param start the lower bound of the range of blogs entries
158             * @param end the upper bound of the range of blogs entries (not inclusive)
159             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
160             * @return the ordered range of matching blogs entries
161             */
162            @Override
163            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
164                    OrderByComparator<BlogsEntry> orderByComparator) {
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 = Collections.unmodifiableList(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             */
282            @Override
283            public BlogsEntry findByUuid_First(String uuid,
284                    OrderByComparator<BlogsEntry> orderByComparator)
285                    throws NoSuchEntryException {
286                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
287    
288                    if (blogsEntry != null) {
289                            return blogsEntry;
290                    }
291    
292                    StringBundler msg = new StringBundler(4);
293    
294                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
295    
296                    msg.append("uuid=");
297                    msg.append(uuid);
298    
299                    msg.append(StringPool.CLOSE_CURLY_BRACE);
300    
301                    throw new NoSuchEntryException(msg.toString());
302            }
303    
304            /**
305             * Returns the first blogs entry in the ordered set where uuid = &#63;.
306             *
307             * @param uuid the uuid
308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
309             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
310             */
311            @Override
312            public BlogsEntry fetchByUuid_First(String uuid,
313                    OrderByComparator<BlogsEntry> orderByComparator) {
314                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
315    
316                    if (!list.isEmpty()) {
317                            return list.get(0);
318                    }
319    
320                    return null;
321            }
322    
323            /**
324             * Returns the last blogs entry in the ordered set where uuid = &#63;.
325             *
326             * @param uuid the uuid
327             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
328             * @return the last matching blogs entry
329             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
330             */
331            @Override
332            public BlogsEntry findByUuid_Last(String uuid,
333                    OrderByComparator<BlogsEntry> orderByComparator)
334                    throws NoSuchEntryException {
335                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
336    
337                    if (blogsEntry != null) {
338                            return blogsEntry;
339                    }
340    
341                    StringBundler msg = new StringBundler(4);
342    
343                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
344    
345                    msg.append("uuid=");
346                    msg.append(uuid);
347    
348                    msg.append(StringPool.CLOSE_CURLY_BRACE);
349    
350                    throw new NoSuchEntryException(msg.toString());
351            }
352    
353            /**
354             * Returns the last blogs entry in the ordered set where uuid = &#63;.
355             *
356             * @param uuid the uuid
357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
358             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
359             */
360            @Override
361            public BlogsEntry fetchByUuid_Last(String uuid,
362                    OrderByComparator<BlogsEntry> orderByComparator) {
363                    int count = countByUuid(uuid);
364    
365                    if (count == 0) {
366                            return null;
367                    }
368    
369                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
370                                    orderByComparator);
371    
372                    if (!list.isEmpty()) {
373                            return list.get(0);
374                    }
375    
376                    return null;
377            }
378    
379            /**
380             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
381             *
382             * @param entryId the primary key of the current blogs entry
383             * @param uuid the uuid
384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
385             * @return the previous, current, and next blogs entry
386             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
387             */
388            @Override
389            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
390                    OrderByComparator<BlogsEntry> orderByComparator)
391                    throws NoSuchEntryException {
392                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
393    
394                    Session session = null;
395    
396                    try {
397                            session = openSession();
398    
399                            BlogsEntry[] array = new BlogsEntryImpl[3];
400    
401                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
402                                            orderByComparator, true);
403    
404                            array[1] = blogsEntry;
405    
406                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
407                                            orderByComparator, false);
408    
409                            return array;
410                    }
411                    catch (Exception e) {
412                            throw processException(e);
413                    }
414                    finally {
415                            closeSession(session);
416                    }
417            }
418    
419            protected BlogsEntry getByUuid_PrevAndNext(Session session,
420                    BlogsEntry blogsEntry, String uuid,
421                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
422                    StringBundler query = null;
423    
424                    if (orderByComparator != null) {
425                            query = new StringBundler(6 +
426                                            (orderByComparator.getOrderByFields().length * 6));
427                    }
428                    else {
429                            query = new StringBundler(3);
430                    }
431    
432                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
433    
434                    boolean bindUuid = false;
435    
436                    if (uuid == null) {
437                            query.append(_FINDER_COLUMN_UUID_UUID_1);
438                    }
439                    else if (uuid.equals(StringPool.BLANK)) {
440                            query.append(_FINDER_COLUMN_UUID_UUID_3);
441                    }
442                    else {
443                            bindUuid = true;
444    
445                            query.append(_FINDER_COLUMN_UUID_UUID_2);
446                    }
447    
448                    if (orderByComparator != null) {
449                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
450    
451                            if (orderByConditionFields.length > 0) {
452                                    query.append(WHERE_AND);
453                            }
454    
455                            for (int i = 0; i < orderByConditionFields.length; i++) {
456                                    query.append(_ORDER_BY_ENTITY_ALIAS);
457                                    query.append(orderByConditionFields[i]);
458    
459                                    if ((i + 1) < orderByConditionFields.length) {
460                                            if (orderByComparator.isAscending() ^ previous) {
461                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
462                                            }
463                                            else {
464                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
465                                            }
466                                    }
467                                    else {
468                                            if (orderByComparator.isAscending() ^ previous) {
469                                                    query.append(WHERE_GREATER_THAN);
470                                            }
471                                            else {
472                                                    query.append(WHERE_LESSER_THAN);
473                                            }
474                                    }
475                            }
476    
477                            query.append(ORDER_BY_CLAUSE);
478    
479                            String[] orderByFields = orderByComparator.getOrderByFields();
480    
481                            for (int i = 0; i < orderByFields.length; i++) {
482                                    query.append(_ORDER_BY_ENTITY_ALIAS);
483                                    query.append(orderByFields[i]);
484    
485                                    if ((i + 1) < orderByFields.length) {
486                                            if (orderByComparator.isAscending() ^ previous) {
487                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
488                                            }
489                                            else {
490                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
491                                            }
492                                    }
493                                    else {
494                                            if (orderByComparator.isAscending() ^ previous) {
495                                                    query.append(ORDER_BY_ASC);
496                                            }
497                                            else {
498                                                    query.append(ORDER_BY_DESC);
499                                            }
500                                    }
501                            }
502                    }
503                    else {
504                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
505                    }
506    
507                    String sql = query.toString();
508    
509                    Query q = session.createQuery(sql);
510    
511                    q.setFirstResult(0);
512                    q.setMaxResults(2);
513    
514                    QueryPos qPos = QueryPos.getInstance(q);
515    
516                    if (bindUuid) {
517                            qPos.add(uuid);
518                    }
519    
520                    if (orderByComparator != null) {
521                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
522    
523                            for (Object value : values) {
524                                    qPos.add(value);
525                            }
526                    }
527    
528                    List<BlogsEntry> list = q.list();
529    
530                    if (list.size() == 2) {
531                            return list.get(1);
532                    }
533                    else {
534                            return null;
535                    }
536            }
537    
538            /**
539             * Removes all the blogs entries where uuid = &#63; from the database.
540             *
541             * @param uuid the uuid
542             */
543            @Override
544            public void removeByUuid(String uuid) {
545                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
546                                    QueryUtil.ALL_POS, null)) {
547                            remove(blogsEntry);
548                    }
549            }
550    
551            /**
552             * Returns the number of blogs entries where uuid = &#63;.
553             *
554             * @param uuid the uuid
555             * @return the number of matching blogs entries
556             */
557            @Override
558            public int countByUuid(String uuid) {
559                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
560    
561                    Object[] finderArgs = new Object[] { uuid };
562    
563                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
564                                    this);
565    
566                    if (count == null) {
567                            StringBundler query = new StringBundler(2);
568    
569                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
570    
571                            boolean bindUuid = false;
572    
573                            if (uuid == null) {
574                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
575                            }
576                            else if (uuid.equals(StringPool.BLANK)) {
577                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
578                            }
579                            else {
580                                    bindUuid = true;
581    
582                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
583                            }
584    
585                            String sql = query.toString();
586    
587                            Session session = null;
588    
589                            try {
590                                    session = openSession();
591    
592                                    Query q = session.createQuery(sql);
593    
594                                    QueryPos qPos = QueryPos.getInstance(q);
595    
596                                    if (bindUuid) {
597                                            qPos.add(uuid);
598                                    }
599    
600                                    count = (Long)q.uniqueResult();
601    
602                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
603                            }
604                            catch (Exception e) {
605                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
606    
607                                    throw processException(e);
608                            }
609                            finally {
610                                    closeSession(session);
611                            }
612                    }
613    
614                    return count.intValue();
615            }
616    
617            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
618            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
619            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
620            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
621                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
622                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
623                            new String[] { String.class.getName(), Long.class.getName() },
624                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
625                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
626            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
627                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
628                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
629                            new String[] { String.class.getName(), Long.class.getName() });
630    
631            /**
632             * 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.
633             *
634             * @param uuid the uuid
635             * @param groupId the group ID
636             * @return the matching blogs entry
637             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
638             */
639            @Override
640            public BlogsEntry findByUUID_G(String uuid, long groupId)
641                    throws NoSuchEntryException {
642                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
643    
644                    if (blogsEntry == null) {
645                            StringBundler msg = new StringBundler(6);
646    
647                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
648    
649                            msg.append("uuid=");
650                            msg.append(uuid);
651    
652                            msg.append(", groupId=");
653                            msg.append(groupId);
654    
655                            msg.append(StringPool.CLOSE_CURLY_BRACE);
656    
657                            if (_log.isWarnEnabled()) {
658                                    _log.warn(msg.toString());
659                            }
660    
661                            throw new NoSuchEntryException(msg.toString());
662                    }
663    
664                    return blogsEntry;
665            }
666    
667            /**
668             * 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.
669             *
670             * @param uuid the uuid
671             * @param groupId the group ID
672             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
673             */
674            @Override
675            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
676                    return fetchByUUID_G(uuid, groupId, true);
677            }
678    
679            /**
680             * 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.
681             *
682             * @param uuid the uuid
683             * @param groupId the group ID
684             * @param retrieveFromCache whether to use the finder cache
685             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
686             */
687            @Override
688            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
689                    boolean retrieveFromCache) {
690                    Object[] finderArgs = new Object[] { uuid, groupId };
691    
692                    Object result = null;
693    
694                    if (retrieveFromCache) {
695                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
696                                            finderArgs, this);
697                    }
698    
699                    if (result instanceof BlogsEntry) {
700                            BlogsEntry blogsEntry = (BlogsEntry)result;
701    
702                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
703                                            (groupId != blogsEntry.getGroupId())) {
704                                    result = null;
705                            }
706                    }
707    
708                    if (result == null) {
709                            StringBundler query = new StringBundler(4);
710    
711                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
712    
713                            boolean bindUuid = false;
714    
715                            if (uuid == null) {
716                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
717                            }
718                            else if (uuid.equals(StringPool.BLANK)) {
719                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
720                            }
721                            else {
722                                    bindUuid = true;
723    
724                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
725                            }
726    
727                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
728    
729                            String sql = query.toString();
730    
731                            Session session = null;
732    
733                            try {
734                                    session = openSession();
735    
736                                    Query q = session.createQuery(sql);
737    
738                                    QueryPos qPos = QueryPos.getInstance(q);
739    
740                                    if (bindUuid) {
741                                            qPos.add(uuid);
742                                    }
743    
744                                    qPos.add(groupId);
745    
746                                    List<BlogsEntry> list = q.list();
747    
748                                    if (list.isEmpty()) {
749                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
750                                                    finderArgs, list);
751                                    }
752                                    else {
753                                            BlogsEntry blogsEntry = list.get(0);
754    
755                                            result = blogsEntry;
756    
757                                            cacheResult(blogsEntry);
758    
759                                            if ((blogsEntry.getUuid() == null) ||
760                                                            !blogsEntry.getUuid().equals(uuid) ||
761                                                            (blogsEntry.getGroupId() != groupId)) {
762                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
763                                                            finderArgs, blogsEntry);
764                                            }
765                                    }
766                            }
767                            catch (Exception e) {
768                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
769                                            finderArgs);
770    
771                                    throw processException(e);
772                            }
773                            finally {
774                                    closeSession(session);
775                            }
776                    }
777    
778                    if (result instanceof List<?>) {
779                            return null;
780                    }
781                    else {
782                            return (BlogsEntry)result;
783                    }
784            }
785    
786            /**
787             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
788             *
789             * @param uuid the uuid
790             * @param groupId the group ID
791             * @return the blogs entry that was removed
792             */
793            @Override
794            public BlogsEntry removeByUUID_G(String uuid, long groupId)
795                    throws NoSuchEntryException {
796                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
797    
798                    return remove(blogsEntry);
799            }
800    
801            /**
802             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
803             *
804             * @param uuid the uuid
805             * @param groupId the group ID
806             * @return the number of matching blogs entries
807             */
808            @Override
809            public int countByUUID_G(String uuid, long groupId) {
810                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
811    
812                    Object[] finderArgs = new Object[] { uuid, groupId };
813    
814                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
815                                    this);
816    
817                    if (count == null) {
818                            StringBundler query = new StringBundler(3);
819    
820                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
821    
822                            boolean bindUuid = false;
823    
824                            if (uuid == null) {
825                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
826                            }
827                            else if (uuid.equals(StringPool.BLANK)) {
828                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
829                            }
830                            else {
831                                    bindUuid = true;
832    
833                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
834                            }
835    
836                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
837    
838                            String sql = query.toString();
839    
840                            Session session = null;
841    
842                            try {
843                                    session = openSession();
844    
845                                    Query q = session.createQuery(sql);
846    
847                                    QueryPos qPos = QueryPos.getInstance(q);
848    
849                                    if (bindUuid) {
850                                            qPos.add(uuid);
851                                    }
852    
853                                    qPos.add(groupId);
854    
855                                    count = (Long)q.uniqueResult();
856    
857                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
858                            }
859                            catch (Exception e) {
860                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
861    
862                                    throw processException(e);
863                            }
864                            finally {
865                                    closeSession(session);
866                            }
867                    }
868    
869                    return count.intValue();
870            }
871    
872            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
873            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
874            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
875            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
876            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
877                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
878                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
879                            new String[] {
880                                    String.class.getName(), Long.class.getName(),
881                                    
882                            Integer.class.getName(), Integer.class.getName(),
883                                    OrderByComparator.class.getName()
884                            });
885            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
886                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
887                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
888                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
889                            new String[] { String.class.getName(), Long.class.getName() },
890                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
891                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
892                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
893                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
894            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
895                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
896                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
897                            new String[] { String.class.getName(), Long.class.getName() });
898    
899            /**
900             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
901             *
902             * @param uuid the uuid
903             * @param companyId the company ID
904             * @return the matching blogs entries
905             */
906            @Override
907            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
908                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
909                            QueryUtil.ALL_POS, null);
910            }
911    
912            /**
913             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
914             *
915             * <p>
916             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
917             * </p>
918             *
919             * @param uuid the uuid
920             * @param companyId the company ID
921             * @param start the lower bound of the range of blogs entries
922             * @param end the upper bound of the range of blogs entries (not inclusive)
923             * @return the range of matching blogs entries
924             */
925            @Override
926            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
927                    int start, int end) {
928                    return findByUuid_C(uuid, companyId, start, end, null);
929            }
930    
931            /**
932             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
933             *
934             * <p>
935             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
936             * </p>
937             *
938             * @param uuid the uuid
939             * @param companyId the company ID
940             * @param start the lower bound of the range of blogs entries
941             * @param end the upper bound of the range of blogs entries (not inclusive)
942             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
943             * @return the ordered range of matching blogs entries
944             */
945            @Override
946            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
947                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
948                    boolean pagination = true;
949                    FinderPath finderPath = null;
950                    Object[] finderArgs = null;
951    
952                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
953                                    (orderByComparator == null)) {
954                            pagination = false;
955                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
956                            finderArgs = new Object[] { uuid, companyId };
957                    }
958                    else {
959                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
960                            finderArgs = new Object[] {
961                                            uuid, companyId,
962                                            
963                                            start, end, orderByComparator
964                                    };
965                    }
966    
967                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
968                                    finderArgs, this);
969    
970                    if ((list != null) && !list.isEmpty()) {
971                            for (BlogsEntry blogsEntry : list) {
972                                    if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
973                                                    (companyId != blogsEntry.getCompanyId())) {
974                                            list = null;
975    
976                                            break;
977                                    }
978                            }
979                    }
980    
981                    if (list == null) {
982                            StringBundler query = null;
983    
984                            if (orderByComparator != null) {
985                                    query = new StringBundler(4 +
986                                                    (orderByComparator.getOrderByFields().length * 3));
987                            }
988                            else {
989                                    query = new StringBundler(4);
990                            }
991    
992                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
993    
994                            boolean bindUuid = false;
995    
996                            if (uuid == null) {
997                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
998                            }
999                            else if (uuid.equals(StringPool.BLANK)) {
1000                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1001                            }
1002                            else {
1003                                    bindUuid = true;
1004    
1005                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1006                            }
1007    
1008                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1009    
1010                            if (orderByComparator != null) {
1011                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1012                                            orderByComparator);
1013                            }
1014                            else
1015                             if (pagination) {
1016                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1017                            }
1018    
1019                            String sql = query.toString();
1020    
1021                            Session session = null;
1022    
1023                            try {
1024                                    session = openSession();
1025    
1026                                    Query q = session.createQuery(sql);
1027    
1028                                    QueryPos qPos = QueryPos.getInstance(q);
1029    
1030                                    if (bindUuid) {
1031                                            qPos.add(uuid);
1032                                    }
1033    
1034                                    qPos.add(companyId);
1035    
1036                                    if (!pagination) {
1037                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1038                                                            start, end, false);
1039    
1040                                            Collections.sort(list);
1041    
1042                                            list = Collections.unmodifiableList(list);
1043                                    }
1044                                    else {
1045                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1046                                                            start, end);
1047                                    }
1048    
1049                                    cacheResult(list);
1050    
1051                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1052                            }
1053                            catch (Exception e) {
1054                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1055    
1056                                    throw processException(e);
1057                            }
1058                            finally {
1059                                    closeSession(session);
1060                            }
1061                    }
1062    
1063                    return list;
1064            }
1065    
1066            /**
1067             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1068             *
1069             * @param uuid the uuid
1070             * @param companyId the company ID
1071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1072             * @return the first matching blogs entry
1073             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1074             */
1075            @Override
1076            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1077                    OrderByComparator<BlogsEntry> orderByComparator)
1078                    throws NoSuchEntryException {
1079                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1080                                    orderByComparator);
1081    
1082                    if (blogsEntry != null) {
1083                            return blogsEntry;
1084                    }
1085    
1086                    StringBundler msg = new StringBundler(6);
1087    
1088                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1089    
1090                    msg.append("uuid=");
1091                    msg.append(uuid);
1092    
1093                    msg.append(", companyId=");
1094                    msg.append(companyId);
1095    
1096                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1097    
1098                    throw new NoSuchEntryException(msg.toString());
1099            }
1100    
1101            /**
1102             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1103             *
1104             * @param uuid the uuid
1105             * @param companyId the company ID
1106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1107             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1108             */
1109            @Override
1110            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1111                    OrderByComparator<BlogsEntry> orderByComparator) {
1112                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1113                                    orderByComparator);
1114    
1115                    if (!list.isEmpty()) {
1116                            return list.get(0);
1117                    }
1118    
1119                    return null;
1120            }
1121    
1122            /**
1123             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1124             *
1125             * @param uuid the uuid
1126             * @param companyId the company ID
1127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1128             * @return the last matching blogs entry
1129             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1130             */
1131            @Override
1132            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1133                    OrderByComparator<BlogsEntry> orderByComparator)
1134                    throws NoSuchEntryException {
1135                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1136                                    orderByComparator);
1137    
1138                    if (blogsEntry != null) {
1139                            return blogsEntry;
1140                    }
1141    
1142                    StringBundler msg = new StringBundler(6);
1143    
1144                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145    
1146                    msg.append("uuid=");
1147                    msg.append(uuid);
1148    
1149                    msg.append(", companyId=");
1150                    msg.append(companyId);
1151    
1152                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                    throw new NoSuchEntryException(msg.toString());
1155            }
1156    
1157            /**
1158             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1159             *
1160             * @param uuid the uuid
1161             * @param companyId the company ID
1162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1163             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1164             */
1165            @Override
1166            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1167                    OrderByComparator<BlogsEntry> orderByComparator) {
1168                    int count = countByUuid_C(uuid, companyId);
1169    
1170                    if (count == 0) {
1171                            return null;
1172                    }
1173    
1174                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1175                                    orderByComparator);
1176    
1177                    if (!list.isEmpty()) {
1178                            return list.get(0);
1179                    }
1180    
1181                    return null;
1182            }
1183    
1184            /**
1185             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1186             *
1187             * @param entryId the primary key of the current blogs entry
1188             * @param uuid the uuid
1189             * @param companyId the company ID
1190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1191             * @return the previous, current, and next blogs entry
1192             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1193             */
1194            @Override
1195            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1196                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1197                    throws NoSuchEntryException {
1198                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1199    
1200                    Session session = null;
1201    
1202                    try {
1203                            session = openSession();
1204    
1205                            BlogsEntry[] array = new BlogsEntryImpl[3];
1206    
1207                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1208                                            companyId, orderByComparator, true);
1209    
1210                            array[1] = blogsEntry;
1211    
1212                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1213                                            companyId, orderByComparator, false);
1214    
1215                            return array;
1216                    }
1217                    catch (Exception e) {
1218                            throw processException(e);
1219                    }
1220                    finally {
1221                            closeSession(session);
1222                    }
1223            }
1224    
1225            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1226                    BlogsEntry blogsEntry, String uuid, long companyId,
1227                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1228                    StringBundler query = null;
1229    
1230                    if (orderByComparator != null) {
1231                            query = new StringBundler(6 +
1232                                            (orderByComparator.getOrderByFields().length * 6));
1233                    }
1234                    else {
1235                            query = new StringBundler(3);
1236                    }
1237    
1238                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1239    
1240                    boolean bindUuid = false;
1241    
1242                    if (uuid == null) {
1243                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1244                    }
1245                    else if (uuid.equals(StringPool.BLANK)) {
1246                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1247                    }
1248                    else {
1249                            bindUuid = true;
1250    
1251                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1252                    }
1253    
1254                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1255    
1256                    if (orderByComparator != null) {
1257                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1258    
1259                            if (orderByConditionFields.length > 0) {
1260                                    query.append(WHERE_AND);
1261                            }
1262    
1263                            for (int i = 0; i < orderByConditionFields.length; i++) {
1264                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1265                                    query.append(orderByConditionFields[i]);
1266    
1267                                    if ((i + 1) < orderByConditionFields.length) {
1268                                            if (orderByComparator.isAscending() ^ previous) {
1269                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1270                                            }
1271                                            else {
1272                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1273                                            }
1274                                    }
1275                                    else {
1276                                            if (orderByComparator.isAscending() ^ previous) {
1277                                                    query.append(WHERE_GREATER_THAN);
1278                                            }
1279                                            else {
1280                                                    query.append(WHERE_LESSER_THAN);
1281                                            }
1282                                    }
1283                            }
1284    
1285                            query.append(ORDER_BY_CLAUSE);
1286    
1287                            String[] orderByFields = orderByComparator.getOrderByFields();
1288    
1289                            for (int i = 0; i < orderByFields.length; i++) {
1290                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1291                                    query.append(orderByFields[i]);
1292    
1293                                    if ((i + 1) < orderByFields.length) {
1294                                            if (orderByComparator.isAscending() ^ previous) {
1295                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1296                                            }
1297                                            else {
1298                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1299                                            }
1300                                    }
1301                                    else {
1302                                            if (orderByComparator.isAscending() ^ previous) {
1303                                                    query.append(ORDER_BY_ASC);
1304                                            }
1305                                            else {
1306                                                    query.append(ORDER_BY_DESC);
1307                                            }
1308                                    }
1309                            }
1310                    }
1311                    else {
1312                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1313                    }
1314    
1315                    String sql = query.toString();
1316    
1317                    Query q = session.createQuery(sql);
1318    
1319                    q.setFirstResult(0);
1320                    q.setMaxResults(2);
1321    
1322                    QueryPos qPos = QueryPos.getInstance(q);
1323    
1324                    if (bindUuid) {
1325                            qPos.add(uuid);
1326                    }
1327    
1328                    qPos.add(companyId);
1329    
1330                    if (orderByComparator != null) {
1331                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1332    
1333                            for (Object value : values) {
1334                                    qPos.add(value);
1335                            }
1336                    }
1337    
1338                    List<BlogsEntry> list = q.list();
1339    
1340                    if (list.size() == 2) {
1341                            return list.get(1);
1342                    }
1343                    else {
1344                            return null;
1345                    }
1346            }
1347    
1348            /**
1349             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1350             *
1351             * @param uuid the uuid
1352             * @param companyId the company ID
1353             */
1354            @Override
1355            public void removeByUuid_C(String uuid, long companyId) {
1356                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1357                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1358                            remove(blogsEntry);
1359                    }
1360            }
1361    
1362            /**
1363             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1364             *
1365             * @param uuid the uuid
1366             * @param companyId the company ID
1367             * @return the number of matching blogs entries
1368             */
1369            @Override
1370            public int countByUuid_C(String uuid, long companyId) {
1371                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1372    
1373                    Object[] finderArgs = new Object[] { uuid, companyId };
1374    
1375                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1376                                    this);
1377    
1378                    if (count == null) {
1379                            StringBundler query = new StringBundler(3);
1380    
1381                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1382    
1383                            boolean bindUuid = false;
1384    
1385                            if (uuid == null) {
1386                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1387                            }
1388                            else if (uuid.equals(StringPool.BLANK)) {
1389                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1390                            }
1391                            else {
1392                                    bindUuid = true;
1393    
1394                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1395                            }
1396    
1397                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1398    
1399                            String sql = query.toString();
1400    
1401                            Session session = null;
1402    
1403                            try {
1404                                    session = openSession();
1405    
1406                                    Query q = session.createQuery(sql);
1407    
1408                                    QueryPos qPos = QueryPos.getInstance(q);
1409    
1410                                    if (bindUuid) {
1411                                            qPos.add(uuid);
1412                                    }
1413    
1414                                    qPos.add(companyId);
1415    
1416                                    count = (Long)q.uniqueResult();
1417    
1418                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1419                            }
1420                            catch (Exception e) {
1421                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1422    
1423                                    throw processException(e);
1424                            }
1425                            finally {
1426                                    closeSession(session);
1427                            }
1428                    }
1429    
1430                    return count.intValue();
1431            }
1432    
1433            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1434            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1435            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1436            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1437            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1438                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1439                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1440                            new String[] {
1441                                    Long.class.getName(),
1442                                    
1443                            Integer.class.getName(), Integer.class.getName(),
1444                                    OrderByComparator.class.getName()
1445                            });
1446            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1447                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1448                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1449                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1450                            new String[] { Long.class.getName() },
1451                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1452                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1453                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1454            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1455                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1456                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1457                            new String[] { Long.class.getName() });
1458    
1459            /**
1460             * Returns all the blogs entries where groupId = &#63;.
1461             *
1462             * @param groupId the group ID
1463             * @return the matching blogs entries
1464             */
1465            @Override
1466            public List<BlogsEntry> findByGroupId(long groupId) {
1467                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1468            }
1469    
1470            /**
1471             * Returns a range of all the blogs entries where groupId = &#63;.
1472             *
1473             * <p>
1474             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1475             * </p>
1476             *
1477             * @param groupId the group ID
1478             * @param start the lower bound of the range of blogs entries
1479             * @param end the upper bound of the range of blogs entries (not inclusive)
1480             * @return the range of matching blogs entries
1481             */
1482            @Override
1483            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1484                    return findByGroupId(groupId, start, end, null);
1485            }
1486    
1487            /**
1488             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1489             *
1490             * <p>
1491             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1492             * </p>
1493             *
1494             * @param groupId the group ID
1495             * @param start the lower bound of the range of blogs entries
1496             * @param end the upper bound of the range of blogs entries (not inclusive)
1497             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1498             * @return the ordered range of matching blogs entries
1499             */
1500            @Override
1501            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1502                    OrderByComparator<BlogsEntry> orderByComparator) {
1503                    boolean pagination = true;
1504                    FinderPath finderPath = null;
1505                    Object[] finderArgs = null;
1506    
1507                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1508                                    (orderByComparator == null)) {
1509                            pagination = false;
1510                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1511                            finderArgs = new Object[] { groupId };
1512                    }
1513                    else {
1514                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1515                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1516                    }
1517    
1518                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1519                                    finderArgs, this);
1520    
1521                    if ((list != null) && !list.isEmpty()) {
1522                            for (BlogsEntry blogsEntry : list) {
1523                                    if ((groupId != blogsEntry.getGroupId())) {
1524                                            list = null;
1525    
1526                                            break;
1527                                    }
1528                            }
1529                    }
1530    
1531                    if (list == null) {
1532                            StringBundler query = null;
1533    
1534                            if (orderByComparator != null) {
1535                                    query = new StringBundler(3 +
1536                                                    (orderByComparator.getOrderByFields().length * 3));
1537                            }
1538                            else {
1539                                    query = new StringBundler(3);
1540                            }
1541    
1542                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1543    
1544                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1545    
1546                            if (orderByComparator != null) {
1547                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1548                                            orderByComparator);
1549                            }
1550                            else
1551                             if (pagination) {
1552                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1553                            }
1554    
1555                            String sql = query.toString();
1556    
1557                            Session session = null;
1558    
1559                            try {
1560                                    session = openSession();
1561    
1562                                    Query q = session.createQuery(sql);
1563    
1564                                    QueryPos qPos = QueryPos.getInstance(q);
1565    
1566                                    qPos.add(groupId);
1567    
1568                                    if (!pagination) {
1569                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1570                                                            start, end, false);
1571    
1572                                            Collections.sort(list);
1573    
1574                                            list = Collections.unmodifiableList(list);
1575                                    }
1576                                    else {
1577                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1578                                                            start, end);
1579                                    }
1580    
1581                                    cacheResult(list);
1582    
1583                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1584                            }
1585                            catch (Exception e) {
1586                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1587    
1588                                    throw processException(e);
1589                            }
1590                            finally {
1591                                    closeSession(session);
1592                            }
1593                    }
1594    
1595                    return list;
1596            }
1597    
1598            /**
1599             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1600             *
1601             * @param groupId the group ID
1602             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1603             * @return the first matching blogs entry
1604             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1605             */
1606            @Override
1607            public BlogsEntry findByGroupId_First(long groupId,
1608                    OrderByComparator<BlogsEntry> orderByComparator)
1609                    throws NoSuchEntryException {
1610                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1611    
1612                    if (blogsEntry != null) {
1613                            return blogsEntry;
1614                    }
1615    
1616                    StringBundler msg = new StringBundler(4);
1617    
1618                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1619    
1620                    msg.append("groupId=");
1621                    msg.append(groupId);
1622    
1623                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1624    
1625                    throw new NoSuchEntryException(msg.toString());
1626            }
1627    
1628            /**
1629             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1630             *
1631             * @param groupId the group ID
1632             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1633             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1634             */
1635            @Override
1636            public BlogsEntry fetchByGroupId_First(long groupId,
1637                    OrderByComparator<BlogsEntry> orderByComparator) {
1638                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1639    
1640                    if (!list.isEmpty()) {
1641                            return list.get(0);
1642                    }
1643    
1644                    return null;
1645            }
1646    
1647            /**
1648             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1649             *
1650             * @param groupId the group ID
1651             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1652             * @return the last matching blogs entry
1653             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
1654             */
1655            @Override
1656            public BlogsEntry findByGroupId_Last(long groupId,
1657                    OrderByComparator<BlogsEntry> orderByComparator)
1658                    throws NoSuchEntryException {
1659                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1660    
1661                    if (blogsEntry != null) {
1662                            return blogsEntry;
1663                    }
1664    
1665                    StringBundler msg = new StringBundler(4);
1666    
1667                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1668    
1669                    msg.append("groupId=");
1670                    msg.append(groupId);
1671    
1672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1673    
1674                    throw new NoSuchEntryException(msg.toString());
1675            }
1676    
1677            /**
1678             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1679             *
1680             * @param groupId the group ID
1681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1682             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1683             */
1684            @Override
1685            public BlogsEntry fetchByGroupId_Last(long groupId,
1686                    OrderByComparator<BlogsEntry> orderByComparator) {
1687                    int count = countByGroupId(groupId);
1688    
1689                    if (count == 0) {
1690                            return null;
1691                    }
1692    
1693                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1694                                    orderByComparator);
1695    
1696                    if (!list.isEmpty()) {
1697                            return list.get(0);
1698                    }
1699    
1700                    return null;
1701            }
1702    
1703            /**
1704             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1705             *
1706             * @param entryId the primary key of the current blogs entry
1707             * @param groupId the group ID
1708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1709             * @return the previous, current, and next blogs entry
1710             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1711             */
1712            @Override
1713            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1714                    OrderByComparator<BlogsEntry> orderByComparator)
1715                    throws NoSuchEntryException {
1716                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1717    
1718                    Session session = null;
1719    
1720                    try {
1721                            session = openSession();
1722    
1723                            BlogsEntry[] array = new BlogsEntryImpl[3];
1724    
1725                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1726                                            orderByComparator, true);
1727    
1728                            array[1] = blogsEntry;
1729    
1730                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1731                                            orderByComparator, false);
1732    
1733                            return array;
1734                    }
1735                    catch (Exception e) {
1736                            throw processException(e);
1737                    }
1738                    finally {
1739                            closeSession(session);
1740                    }
1741            }
1742    
1743            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1744                    BlogsEntry blogsEntry, long groupId,
1745                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1746                    StringBundler query = null;
1747    
1748                    if (orderByComparator != null) {
1749                            query = new StringBundler(6 +
1750                                            (orderByComparator.getOrderByFields().length * 6));
1751                    }
1752                    else {
1753                            query = new StringBundler(3);
1754                    }
1755    
1756                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1757    
1758                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1759    
1760                    if (orderByComparator != null) {
1761                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1762    
1763                            if (orderByConditionFields.length > 0) {
1764                                    query.append(WHERE_AND);
1765                            }
1766    
1767                            for (int i = 0; i < orderByConditionFields.length; i++) {
1768                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1769                                    query.append(orderByConditionFields[i]);
1770    
1771                                    if ((i + 1) < orderByConditionFields.length) {
1772                                            if (orderByComparator.isAscending() ^ previous) {
1773                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1774                                            }
1775                                            else {
1776                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1777                                            }
1778                                    }
1779                                    else {
1780                                            if (orderByComparator.isAscending() ^ previous) {
1781                                                    query.append(WHERE_GREATER_THAN);
1782                                            }
1783                                            else {
1784                                                    query.append(WHERE_LESSER_THAN);
1785                                            }
1786                                    }
1787                            }
1788    
1789                            query.append(ORDER_BY_CLAUSE);
1790    
1791                            String[] orderByFields = orderByComparator.getOrderByFields();
1792    
1793                            for (int i = 0; i < orderByFields.length; i++) {
1794                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1795                                    query.append(orderByFields[i]);
1796    
1797                                    if ((i + 1) < orderByFields.length) {
1798                                            if (orderByComparator.isAscending() ^ previous) {
1799                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1800                                            }
1801                                            else {
1802                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1803                                            }
1804                                    }
1805                                    else {
1806                                            if (orderByComparator.isAscending() ^ previous) {
1807                                                    query.append(ORDER_BY_ASC);
1808                                            }
1809                                            else {
1810                                                    query.append(ORDER_BY_DESC);
1811                                            }
1812                                    }
1813                            }
1814                    }
1815                    else {
1816                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1817                    }
1818    
1819                    String sql = query.toString();
1820    
1821                    Query q = session.createQuery(sql);
1822    
1823                    q.setFirstResult(0);
1824                    q.setMaxResults(2);
1825    
1826                    QueryPos qPos = QueryPos.getInstance(q);
1827    
1828                    qPos.add(groupId);
1829    
1830                    if (orderByComparator != null) {
1831                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1832    
1833                            for (Object value : values) {
1834                                    qPos.add(value);
1835                            }
1836                    }
1837    
1838                    List<BlogsEntry> list = q.list();
1839    
1840                    if (list.size() == 2) {
1841                            return list.get(1);
1842                    }
1843                    else {
1844                            return null;
1845                    }
1846            }
1847    
1848            /**
1849             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1850             *
1851             * @param groupId the group ID
1852             * @return the matching blogs entries that the user has permission to view
1853             */
1854            @Override
1855            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1856                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1857                            QueryUtil.ALL_POS, null);
1858            }
1859    
1860            /**
1861             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1862             *
1863             * <p>
1864             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1865             * </p>
1866             *
1867             * @param groupId the group ID
1868             * @param start the lower bound of the range of blogs entries
1869             * @param end the upper bound of the range of blogs entries (not inclusive)
1870             * @return the range of matching blogs entries that the user has permission to view
1871             */
1872            @Override
1873            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1874                    return filterFindByGroupId(groupId, start, end, null);
1875            }
1876    
1877            /**
1878             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1879             *
1880             * <p>
1881             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
1882             * </p>
1883             *
1884             * @param groupId the group ID
1885             * @param start the lower bound of the range of blogs entries
1886             * @param end the upper bound of the range of blogs entries (not inclusive)
1887             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1888             * @return the ordered range of matching blogs entries that the user has permission to view
1889             */
1890            @Override
1891            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1892                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1893                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1894                            return findByGroupId(groupId, start, end, orderByComparator);
1895                    }
1896    
1897                    StringBundler query = null;
1898    
1899                    if (orderByComparator != null) {
1900                            query = new StringBundler(3 +
1901                                            (orderByComparator.getOrderByFields().length * 3));
1902                    }
1903                    else {
1904                            query = new StringBundler(3);
1905                    }
1906    
1907                    if (getDB().isSupportsInlineDistinct()) {
1908                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1909                    }
1910                    else {
1911                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1912                    }
1913    
1914                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1915    
1916                    if (!getDB().isSupportsInlineDistinct()) {
1917                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1918                    }
1919    
1920                    if (orderByComparator != null) {
1921                            if (getDB().isSupportsInlineDistinct()) {
1922                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1923                                            orderByComparator, true);
1924                            }
1925                            else {
1926                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1927                                            orderByComparator, true);
1928                            }
1929                    }
1930                    else {
1931                            if (getDB().isSupportsInlineDistinct()) {
1932                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1933                            }
1934                            else {
1935                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
1936                            }
1937                    }
1938    
1939                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1940                                    BlogsEntry.class.getName(),
1941                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1942    
1943                    Session session = null;
1944    
1945                    try {
1946                            session = openSession();
1947    
1948                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1949    
1950                            if (getDB().isSupportsInlineDistinct()) {
1951                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
1952                            }
1953                            else {
1954                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
1955                            }
1956    
1957                            QueryPos qPos = QueryPos.getInstance(q);
1958    
1959                            qPos.add(groupId);
1960    
1961                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
1962                    }
1963                    catch (Exception e) {
1964                            throw processException(e);
1965                    }
1966                    finally {
1967                            closeSession(session);
1968                    }
1969            }
1970    
1971            /**
1972             * 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;.
1973             *
1974             * @param entryId the primary key of the current blogs entry
1975             * @param groupId the group ID
1976             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1977             * @return the previous, current, and next blogs entry
1978             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
1979             */
1980            @Override
1981            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
1982                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
1983                    throws NoSuchEntryException {
1984                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1985                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
1986                    }
1987    
1988                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1989    
1990                    Session session = null;
1991    
1992                    try {
1993                            session = openSession();
1994    
1995                            BlogsEntry[] array = new BlogsEntryImpl[3];
1996    
1997                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
1998                                            groupId, orderByComparator, true);
1999    
2000                            array[1] = blogsEntry;
2001    
2002                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2003                                            groupId, orderByComparator, false);
2004    
2005                            return array;
2006                    }
2007                    catch (Exception e) {
2008                            throw processException(e);
2009                    }
2010                    finally {
2011                            closeSession(session);
2012                    }
2013            }
2014    
2015            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2016                    BlogsEntry blogsEntry, long groupId,
2017                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2018                    StringBundler query = null;
2019    
2020                    if (orderByComparator != null) {
2021                            query = new StringBundler(6 +
2022                                            (orderByComparator.getOrderByFields().length * 6));
2023                    }
2024                    else {
2025                            query = new StringBundler(3);
2026                    }
2027    
2028                    if (getDB().isSupportsInlineDistinct()) {
2029                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2030                    }
2031                    else {
2032                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2033                    }
2034    
2035                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2036    
2037                    if (!getDB().isSupportsInlineDistinct()) {
2038                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2039                    }
2040    
2041                    if (orderByComparator != null) {
2042                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2043    
2044                            if (orderByConditionFields.length > 0) {
2045                                    query.append(WHERE_AND);
2046                            }
2047    
2048                            for (int i = 0; i < orderByConditionFields.length; i++) {
2049                                    if (getDB().isSupportsInlineDistinct()) {
2050                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2051                                    }
2052                                    else {
2053                                            query.append(_ORDER_BY_ENTITY_TABLE);
2054                                    }
2055    
2056                                    query.append(orderByConditionFields[i]);
2057    
2058                                    if ((i + 1) < orderByConditionFields.length) {
2059                                            if (orderByComparator.isAscending() ^ previous) {
2060                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2061                                            }
2062                                            else {
2063                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2064                                            }
2065                                    }
2066                                    else {
2067                                            if (orderByComparator.isAscending() ^ previous) {
2068                                                    query.append(WHERE_GREATER_THAN);
2069                                            }
2070                                            else {
2071                                                    query.append(WHERE_LESSER_THAN);
2072                                            }
2073                                    }
2074                            }
2075    
2076                            query.append(ORDER_BY_CLAUSE);
2077    
2078                            String[] orderByFields = orderByComparator.getOrderByFields();
2079    
2080                            for (int i = 0; i < orderByFields.length; i++) {
2081                                    if (getDB().isSupportsInlineDistinct()) {
2082                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2083                                    }
2084                                    else {
2085                                            query.append(_ORDER_BY_ENTITY_TABLE);
2086                                    }
2087    
2088                                    query.append(orderByFields[i]);
2089    
2090                                    if ((i + 1) < orderByFields.length) {
2091                                            if (orderByComparator.isAscending() ^ previous) {
2092                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2093                                            }
2094                                            else {
2095                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2096                                            }
2097                                    }
2098                                    else {
2099                                            if (orderByComparator.isAscending() ^ previous) {
2100                                                    query.append(ORDER_BY_ASC);
2101                                            }
2102                                            else {
2103                                                    query.append(ORDER_BY_DESC);
2104                                            }
2105                                    }
2106                            }
2107                    }
2108                    else {
2109                            if (getDB().isSupportsInlineDistinct()) {
2110                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2111                            }
2112                            else {
2113                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2114                            }
2115                    }
2116    
2117                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2118                                    BlogsEntry.class.getName(),
2119                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2120    
2121                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2122    
2123                    q.setFirstResult(0);
2124                    q.setMaxResults(2);
2125    
2126                    if (getDB().isSupportsInlineDistinct()) {
2127                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2128                    }
2129                    else {
2130                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2131                    }
2132    
2133                    QueryPos qPos = QueryPos.getInstance(q);
2134    
2135                    qPos.add(groupId);
2136    
2137                    if (orderByComparator != null) {
2138                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2139    
2140                            for (Object value : values) {
2141                                    qPos.add(value);
2142                            }
2143                    }
2144    
2145                    List<BlogsEntry> list = q.list();
2146    
2147                    if (list.size() == 2) {
2148                            return list.get(1);
2149                    }
2150                    else {
2151                            return null;
2152                    }
2153            }
2154    
2155            /**
2156             * Removes all the blogs entries where groupId = &#63; from the database.
2157             *
2158             * @param groupId the group ID
2159             */
2160            @Override
2161            public void removeByGroupId(long groupId) {
2162                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2163                                    QueryUtil.ALL_POS, null)) {
2164                            remove(blogsEntry);
2165                    }
2166            }
2167    
2168            /**
2169             * Returns the number of blogs entries where groupId = &#63;.
2170             *
2171             * @param groupId the group ID
2172             * @return the number of matching blogs entries
2173             */
2174            @Override
2175            public int countByGroupId(long groupId) {
2176                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2177    
2178                    Object[] finderArgs = new Object[] { groupId };
2179    
2180                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2181                                    this);
2182    
2183                    if (count == null) {
2184                            StringBundler query = new StringBundler(2);
2185    
2186                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2187    
2188                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2189    
2190                            String sql = query.toString();
2191    
2192                            Session session = null;
2193    
2194                            try {
2195                                    session = openSession();
2196    
2197                                    Query q = session.createQuery(sql);
2198    
2199                                    QueryPos qPos = QueryPos.getInstance(q);
2200    
2201                                    qPos.add(groupId);
2202    
2203                                    count = (Long)q.uniqueResult();
2204    
2205                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2206                            }
2207                            catch (Exception e) {
2208                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2209    
2210                                    throw processException(e);
2211                            }
2212                            finally {
2213                                    closeSession(session);
2214                            }
2215                    }
2216    
2217                    return count.intValue();
2218            }
2219    
2220            /**
2221             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2222             *
2223             * @param groupId the group ID
2224             * @return the number of matching blogs entries that the user has permission to view
2225             */
2226            @Override
2227            public int filterCountByGroupId(long groupId) {
2228                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2229                            return countByGroupId(groupId);
2230                    }
2231    
2232                    StringBundler query = new StringBundler(2);
2233    
2234                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2235    
2236                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2237    
2238                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2239                                    BlogsEntry.class.getName(),
2240                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2241    
2242                    Session session = null;
2243    
2244                    try {
2245                            session = openSession();
2246    
2247                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2248    
2249                            q.addScalar(COUNT_COLUMN_NAME,
2250                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2251    
2252                            QueryPos qPos = QueryPos.getInstance(q);
2253    
2254                            qPos.add(groupId);
2255    
2256                            Long count = (Long)q.uniqueResult();
2257    
2258                            return count.intValue();
2259                    }
2260                    catch (Exception e) {
2261                            throw processException(e);
2262                    }
2263                    finally {
2264                            closeSession(session);
2265                    }
2266            }
2267    
2268            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2269            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2270                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2271                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2272                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2273                            new String[] {
2274                                    Long.class.getName(),
2275                                    
2276                            Integer.class.getName(), Integer.class.getName(),
2277                                    OrderByComparator.class.getName()
2278                            });
2279            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2280                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2281                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2282                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2283                            new String[] { Long.class.getName() },
2284                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2285                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2286                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2287            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2288                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2289                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2290                            new String[] { Long.class.getName() });
2291    
2292            /**
2293             * Returns all the blogs entries where companyId = &#63;.
2294             *
2295             * @param companyId the company ID
2296             * @return the matching blogs entries
2297             */
2298            @Override
2299            public List<BlogsEntry> findByCompanyId(long companyId) {
2300                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2301                            null);
2302            }
2303    
2304            /**
2305             * Returns a range of all the blogs entries where companyId = &#63;.
2306             *
2307             * <p>
2308             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
2309             * </p>
2310             *
2311             * @param companyId the company ID
2312             * @param start the lower bound of the range of blogs entries
2313             * @param end the upper bound of the range of blogs entries (not inclusive)
2314             * @return the range of matching blogs entries
2315             */
2316            @Override
2317            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2318                    return findByCompanyId(companyId, start, end, null);
2319            }
2320    
2321            /**
2322             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2323             *
2324             * <p>
2325             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
2326             * </p>
2327             *
2328             * @param companyId the company ID
2329             * @param start the lower bound of the range of blogs entries
2330             * @param end the upper bound of the range of blogs entries (not inclusive)
2331             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2332             * @return the ordered range of matching blogs entries
2333             */
2334            @Override
2335            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2336                    OrderByComparator<BlogsEntry> orderByComparator) {
2337                    boolean pagination = true;
2338                    FinderPath finderPath = null;
2339                    Object[] finderArgs = null;
2340    
2341                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2342                                    (orderByComparator == null)) {
2343                            pagination = false;
2344                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2345                            finderArgs = new Object[] { companyId };
2346                    }
2347                    else {
2348                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2349                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2350                    }
2351    
2352                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2353                                    finderArgs, this);
2354    
2355                    if ((list != null) && !list.isEmpty()) {
2356                            for (BlogsEntry blogsEntry : list) {
2357                                    if ((companyId != blogsEntry.getCompanyId())) {
2358                                            list = null;
2359    
2360                                            break;
2361                                    }
2362                            }
2363                    }
2364    
2365                    if (list == null) {
2366                            StringBundler query = null;
2367    
2368                            if (orderByComparator != null) {
2369                                    query = new StringBundler(3 +
2370                                                    (orderByComparator.getOrderByFields().length * 3));
2371                            }
2372                            else {
2373                                    query = new StringBundler(3);
2374                            }
2375    
2376                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2377    
2378                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2379    
2380                            if (orderByComparator != null) {
2381                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2382                                            orderByComparator);
2383                            }
2384                            else
2385                             if (pagination) {
2386                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2387                            }
2388    
2389                            String sql = query.toString();
2390    
2391                            Session session = null;
2392    
2393                            try {
2394                                    session = openSession();
2395    
2396                                    Query q = session.createQuery(sql);
2397    
2398                                    QueryPos qPos = QueryPos.getInstance(q);
2399    
2400                                    qPos.add(companyId);
2401    
2402                                    if (!pagination) {
2403                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2404                                                            start, end, false);
2405    
2406                                            Collections.sort(list);
2407    
2408                                            list = Collections.unmodifiableList(list);
2409                                    }
2410                                    else {
2411                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2412                                                            start, end);
2413                                    }
2414    
2415                                    cacheResult(list);
2416    
2417                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2418                            }
2419                            catch (Exception e) {
2420                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2421    
2422                                    throw processException(e);
2423                            }
2424                            finally {
2425                                    closeSession(session);
2426                            }
2427                    }
2428    
2429                    return list;
2430            }
2431    
2432            /**
2433             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2434             *
2435             * @param companyId the company ID
2436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2437             * @return the first matching blogs entry
2438             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2439             */
2440            @Override
2441            public BlogsEntry findByCompanyId_First(long companyId,
2442                    OrderByComparator<BlogsEntry> orderByComparator)
2443                    throws NoSuchEntryException {
2444                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2445                                    orderByComparator);
2446    
2447                    if (blogsEntry != null) {
2448                            return blogsEntry;
2449                    }
2450    
2451                    StringBundler msg = new StringBundler(4);
2452    
2453                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2454    
2455                    msg.append("companyId=");
2456                    msg.append(companyId);
2457    
2458                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2459    
2460                    throw new NoSuchEntryException(msg.toString());
2461            }
2462    
2463            /**
2464             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2465             *
2466             * @param companyId the company ID
2467             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2468             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2469             */
2470            @Override
2471            public BlogsEntry fetchByCompanyId_First(long companyId,
2472                    OrderByComparator<BlogsEntry> orderByComparator) {
2473                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2474                                    orderByComparator);
2475    
2476                    if (!list.isEmpty()) {
2477                            return list.get(0);
2478                    }
2479    
2480                    return null;
2481            }
2482    
2483            /**
2484             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2485             *
2486             * @param companyId the company ID
2487             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2488             * @return the last matching blogs entry
2489             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2490             */
2491            @Override
2492            public BlogsEntry findByCompanyId_Last(long companyId,
2493                    OrderByComparator<BlogsEntry> orderByComparator)
2494                    throws NoSuchEntryException {
2495                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2496                                    orderByComparator);
2497    
2498                    if (blogsEntry != null) {
2499                            return blogsEntry;
2500                    }
2501    
2502                    StringBundler msg = new StringBundler(4);
2503    
2504                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2505    
2506                    msg.append("companyId=");
2507                    msg.append(companyId);
2508    
2509                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2510    
2511                    throw new NoSuchEntryException(msg.toString());
2512            }
2513    
2514            /**
2515             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2516             *
2517             * @param companyId the company ID
2518             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2519             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2520             */
2521            @Override
2522            public BlogsEntry fetchByCompanyId_Last(long companyId,
2523                    OrderByComparator<BlogsEntry> orderByComparator) {
2524                    int count = countByCompanyId(companyId);
2525    
2526                    if (count == 0) {
2527                            return null;
2528                    }
2529    
2530                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2531                                    orderByComparator);
2532    
2533                    if (!list.isEmpty()) {
2534                            return list.get(0);
2535                    }
2536    
2537                    return null;
2538            }
2539    
2540            /**
2541             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2542             *
2543             * @param entryId the primary key of the current blogs entry
2544             * @param companyId the company ID
2545             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2546             * @return the previous, current, and next blogs entry
2547             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
2548             */
2549            @Override
2550            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2551                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2552                    throws NoSuchEntryException {
2553                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2554    
2555                    Session session = null;
2556    
2557                    try {
2558                            session = openSession();
2559    
2560                            BlogsEntry[] array = new BlogsEntryImpl[3];
2561    
2562                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2563                                            companyId, orderByComparator, true);
2564    
2565                            array[1] = blogsEntry;
2566    
2567                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2568                                            companyId, orderByComparator, false);
2569    
2570                            return array;
2571                    }
2572                    catch (Exception e) {
2573                            throw processException(e);
2574                    }
2575                    finally {
2576                            closeSession(session);
2577                    }
2578            }
2579    
2580            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2581                    BlogsEntry blogsEntry, long companyId,
2582                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2583                    StringBundler query = null;
2584    
2585                    if (orderByComparator != null) {
2586                            query = new StringBundler(6 +
2587                                            (orderByComparator.getOrderByFields().length * 6));
2588                    }
2589                    else {
2590                            query = new StringBundler(3);
2591                    }
2592    
2593                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2594    
2595                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2596    
2597                    if (orderByComparator != null) {
2598                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2599    
2600                            if (orderByConditionFields.length > 0) {
2601                                    query.append(WHERE_AND);
2602                            }
2603    
2604                            for (int i = 0; i < orderByConditionFields.length; i++) {
2605                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2606                                    query.append(orderByConditionFields[i]);
2607    
2608                                    if ((i + 1) < orderByConditionFields.length) {
2609                                            if (orderByComparator.isAscending() ^ previous) {
2610                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2611                                            }
2612                                            else {
2613                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2614                                            }
2615                                    }
2616                                    else {
2617                                            if (orderByComparator.isAscending() ^ previous) {
2618                                                    query.append(WHERE_GREATER_THAN);
2619                                            }
2620                                            else {
2621                                                    query.append(WHERE_LESSER_THAN);
2622                                            }
2623                                    }
2624                            }
2625    
2626                            query.append(ORDER_BY_CLAUSE);
2627    
2628                            String[] orderByFields = orderByComparator.getOrderByFields();
2629    
2630                            for (int i = 0; i < orderByFields.length; i++) {
2631                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2632                                    query.append(orderByFields[i]);
2633    
2634                                    if ((i + 1) < orderByFields.length) {
2635                                            if (orderByComparator.isAscending() ^ previous) {
2636                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2637                                            }
2638                                            else {
2639                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2640                                            }
2641                                    }
2642                                    else {
2643                                            if (orderByComparator.isAscending() ^ previous) {
2644                                                    query.append(ORDER_BY_ASC);
2645                                            }
2646                                            else {
2647                                                    query.append(ORDER_BY_DESC);
2648                                            }
2649                                    }
2650                            }
2651                    }
2652                    else {
2653                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2654                    }
2655    
2656                    String sql = query.toString();
2657    
2658                    Query q = session.createQuery(sql);
2659    
2660                    q.setFirstResult(0);
2661                    q.setMaxResults(2);
2662    
2663                    QueryPos qPos = QueryPos.getInstance(q);
2664    
2665                    qPos.add(companyId);
2666    
2667                    if (orderByComparator != null) {
2668                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2669    
2670                            for (Object value : values) {
2671                                    qPos.add(value);
2672                            }
2673                    }
2674    
2675                    List<BlogsEntry> list = q.list();
2676    
2677                    if (list.size() == 2) {
2678                            return list.get(1);
2679                    }
2680                    else {
2681                            return null;
2682                    }
2683            }
2684    
2685            /**
2686             * Removes all the blogs entries where companyId = &#63; from the database.
2687             *
2688             * @param companyId the company ID
2689             */
2690            @Override
2691            public void removeByCompanyId(long companyId) {
2692                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2693                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2694                            remove(blogsEntry);
2695                    }
2696            }
2697    
2698            /**
2699             * Returns the number of blogs entries where companyId = &#63;.
2700             *
2701             * @param companyId the company ID
2702             * @return the number of matching blogs entries
2703             */
2704            @Override
2705            public int countByCompanyId(long companyId) {
2706                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2707    
2708                    Object[] finderArgs = new Object[] { companyId };
2709    
2710                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2711                                    this);
2712    
2713                    if (count == null) {
2714                            StringBundler query = new StringBundler(2);
2715    
2716                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2717    
2718                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2719    
2720                            String sql = query.toString();
2721    
2722                            Session session = null;
2723    
2724                            try {
2725                                    session = openSession();
2726    
2727                                    Query q = session.createQuery(sql);
2728    
2729                                    QueryPos qPos = QueryPos.getInstance(q);
2730    
2731                                    qPos.add(companyId);
2732    
2733                                    count = (Long)q.uniqueResult();
2734    
2735                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2736                            }
2737                            catch (Exception e) {
2738                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2739    
2740                                    throw processException(e);
2741                            }
2742                            finally {
2743                                    closeSession(session);
2744                            }
2745                    }
2746    
2747                    return count.intValue();
2748            }
2749    
2750            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2751            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2752                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2753                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2754                            new String[] { Long.class.getName(), String.class.getName() },
2755                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2756                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2757            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2758                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2759                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2760                            new String[] { Long.class.getName(), String.class.getName() });
2761    
2762            /**
2763             * 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.
2764             *
2765             * @param groupId the group ID
2766             * @param urlTitle the url title
2767             * @return the matching blogs entry
2768             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
2769             */
2770            @Override
2771            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2772                    throws NoSuchEntryException {
2773                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2774    
2775                    if (blogsEntry == null) {
2776                            StringBundler msg = new StringBundler(6);
2777    
2778                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2779    
2780                            msg.append("groupId=");
2781                            msg.append(groupId);
2782    
2783                            msg.append(", urlTitle=");
2784                            msg.append(urlTitle);
2785    
2786                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2787    
2788                            if (_log.isWarnEnabled()) {
2789                                    _log.warn(msg.toString());
2790                            }
2791    
2792                            throw new NoSuchEntryException(msg.toString());
2793                    }
2794    
2795                    return blogsEntry;
2796            }
2797    
2798            /**
2799             * 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.
2800             *
2801             * @param groupId the group ID
2802             * @param urlTitle the url title
2803             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2804             */
2805            @Override
2806            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2807                    return fetchByG_UT(groupId, urlTitle, true);
2808            }
2809    
2810            /**
2811             * 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.
2812             *
2813             * @param groupId the group ID
2814             * @param urlTitle the url title
2815             * @param retrieveFromCache whether to use the finder cache
2816             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2817             */
2818            @Override
2819            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2820                    boolean retrieveFromCache) {
2821                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2822    
2823                    Object result = null;
2824    
2825                    if (retrieveFromCache) {
2826                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_UT,
2827                                            finderArgs, this);
2828                    }
2829    
2830                    if (result instanceof BlogsEntry) {
2831                            BlogsEntry blogsEntry = (BlogsEntry)result;
2832    
2833                            if ((groupId != blogsEntry.getGroupId()) ||
2834                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
2835                                    result = null;
2836                            }
2837                    }
2838    
2839                    if (result == null) {
2840                            StringBundler query = new StringBundler(4);
2841    
2842                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2843    
2844                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2845    
2846                            boolean bindUrlTitle = false;
2847    
2848                            if (urlTitle == null) {
2849                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2850                            }
2851                            else if (urlTitle.equals(StringPool.BLANK)) {
2852                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2853                            }
2854                            else {
2855                                    bindUrlTitle = true;
2856    
2857                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2858                            }
2859    
2860                            String sql = query.toString();
2861    
2862                            Session session = null;
2863    
2864                            try {
2865                                    session = openSession();
2866    
2867                                    Query q = session.createQuery(sql);
2868    
2869                                    QueryPos qPos = QueryPos.getInstance(q);
2870    
2871                                    qPos.add(groupId);
2872    
2873                                    if (bindUrlTitle) {
2874                                            qPos.add(urlTitle);
2875                                    }
2876    
2877                                    List<BlogsEntry> list = q.list();
2878    
2879                                    if (list.isEmpty()) {
2880                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
2881                                                    finderArgs, list);
2882                                    }
2883                                    else {
2884                                            BlogsEntry blogsEntry = list.get(0);
2885    
2886                                            result = blogsEntry;
2887    
2888                                            cacheResult(blogsEntry);
2889    
2890                                            if ((blogsEntry.getGroupId() != groupId) ||
2891                                                            (blogsEntry.getUrlTitle() == null) ||
2892                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
2893                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
2894                                                            finderArgs, blogsEntry);
2895                                            }
2896                                    }
2897                            }
2898                            catch (Exception e) {
2899                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
2900                                            finderArgs);
2901    
2902                                    throw processException(e);
2903                            }
2904                            finally {
2905                                    closeSession(session);
2906                            }
2907                    }
2908    
2909                    if (result instanceof List<?>) {
2910                            return null;
2911                    }
2912                    else {
2913                            return (BlogsEntry)result;
2914                    }
2915            }
2916    
2917            /**
2918             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
2919             *
2920             * @param groupId the group ID
2921             * @param urlTitle the url title
2922             * @return the blogs entry that was removed
2923             */
2924            @Override
2925            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
2926                    throws NoSuchEntryException {
2927                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
2928    
2929                    return remove(blogsEntry);
2930            }
2931    
2932            /**
2933             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
2934             *
2935             * @param groupId the group ID
2936             * @param urlTitle the url title
2937             * @return the number of matching blogs entries
2938             */
2939            @Override
2940            public int countByG_UT(long groupId, String urlTitle) {
2941                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
2942    
2943                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2944    
2945                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2946                                    this);
2947    
2948                    if (count == null) {
2949                            StringBundler query = new StringBundler(3);
2950    
2951                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2952    
2953                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2954    
2955                            boolean bindUrlTitle = false;
2956    
2957                            if (urlTitle == null) {
2958                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2959                            }
2960                            else if (urlTitle.equals(StringPool.BLANK)) {
2961                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2962                            }
2963                            else {
2964                                    bindUrlTitle = true;
2965    
2966                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2967                            }
2968    
2969                            String sql = query.toString();
2970    
2971                            Session session = null;
2972    
2973                            try {
2974                                    session = openSession();
2975    
2976                                    Query q = session.createQuery(sql);
2977    
2978                                    QueryPos qPos = QueryPos.getInstance(q);
2979    
2980                                    qPos.add(groupId);
2981    
2982                                    if (bindUrlTitle) {
2983                                            qPos.add(urlTitle);
2984                                    }
2985    
2986                                    count = (Long)q.uniqueResult();
2987    
2988                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2989                            }
2990                            catch (Exception e) {
2991                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2992    
2993                                    throw processException(e);
2994                            }
2995                            finally {
2996                                    closeSession(session);
2997                            }
2998                    }
2999    
3000                    return count.intValue();
3001            }
3002    
3003            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3004            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3005            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3006            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3007            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3008                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3009                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3010                            new String[] {
3011                                    Long.class.getName(), Date.class.getName(),
3012                                    
3013                            Integer.class.getName(), Integer.class.getName(),
3014                                    OrderByComparator.class.getName()
3015                            });
3016            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3017                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3018                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3019                            new String[] { Long.class.getName(), Date.class.getName() });
3020    
3021            /**
3022             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3023             *
3024             * @param groupId the group ID
3025             * @param displayDate the display date
3026             * @return the matching blogs entries
3027             */
3028            @Override
3029            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3030                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3031                            QueryUtil.ALL_POS, null);
3032            }
3033    
3034            /**
3035             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3036             *
3037             * <p>
3038             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3039             * </p>
3040             *
3041             * @param groupId the group ID
3042             * @param displayDate the display date
3043             * @param start the lower bound of the range of blogs entries
3044             * @param end the upper bound of the range of blogs entries (not inclusive)
3045             * @return the range of matching blogs entries
3046             */
3047            @Override
3048            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3049                    int start, int end) {
3050                    return findByG_LtD(groupId, displayDate, start, end, null);
3051            }
3052    
3053            /**
3054             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3055             *
3056             * <p>
3057             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3058             * </p>
3059             *
3060             * @param groupId the group ID
3061             * @param displayDate the display date
3062             * @param start the lower bound of the range of blogs entries
3063             * @param end the upper bound of the range of blogs entries (not inclusive)
3064             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3065             * @return the ordered range of matching blogs entries
3066             */
3067            @Override
3068            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3069                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3070                    boolean pagination = true;
3071                    FinderPath finderPath = null;
3072                    Object[] finderArgs = null;
3073    
3074                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3075                    finderArgs = new Object[] {
3076                                    groupId, displayDate,
3077                                    
3078                                    start, end, orderByComparator
3079                            };
3080    
3081                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3082                                    finderArgs, this);
3083    
3084                    if ((list != null) && !list.isEmpty()) {
3085                            for (BlogsEntry blogsEntry : list) {
3086                                    if ((groupId != blogsEntry.getGroupId()) ||
3087                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
3088                                                                                                                                    .getTime())) {
3089                                            list = null;
3090    
3091                                            break;
3092                                    }
3093                            }
3094                    }
3095    
3096                    if (list == null) {
3097                            StringBundler query = null;
3098    
3099                            if (orderByComparator != null) {
3100                                    query = new StringBundler(4 +
3101                                                    (orderByComparator.getOrderByFields().length * 3));
3102                            }
3103                            else {
3104                                    query = new StringBundler(4);
3105                            }
3106    
3107                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3108    
3109                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3110    
3111                            boolean bindDisplayDate = false;
3112    
3113                            if (displayDate == null) {
3114                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3115                            }
3116                            else {
3117                                    bindDisplayDate = true;
3118    
3119                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3120                            }
3121    
3122                            if (orderByComparator != null) {
3123                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3124                                            orderByComparator);
3125                            }
3126                            else
3127                             if (pagination) {
3128                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3129                            }
3130    
3131                            String sql = query.toString();
3132    
3133                            Session session = null;
3134    
3135                            try {
3136                                    session = openSession();
3137    
3138                                    Query q = session.createQuery(sql);
3139    
3140                                    QueryPos qPos = QueryPos.getInstance(q);
3141    
3142                                    qPos.add(groupId);
3143    
3144                                    if (bindDisplayDate) {
3145                                            qPos.add(new Timestamp(displayDate.getTime()));
3146                                    }
3147    
3148                                    if (!pagination) {
3149                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3150                                                            start, end, false);
3151    
3152                                            Collections.sort(list);
3153    
3154                                            list = Collections.unmodifiableList(list);
3155                                    }
3156                                    else {
3157                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3158                                                            start, end);
3159                                    }
3160    
3161                                    cacheResult(list);
3162    
3163                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3164                            }
3165                            catch (Exception e) {
3166                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3167    
3168                                    throw processException(e);
3169                            }
3170                            finally {
3171                                    closeSession(session);
3172                            }
3173                    }
3174    
3175                    return list;
3176            }
3177    
3178            /**
3179             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3180             *
3181             * @param groupId the group ID
3182             * @param displayDate the display date
3183             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3184             * @return the first matching blogs entry
3185             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3186             */
3187            @Override
3188            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3189                    OrderByComparator<BlogsEntry> orderByComparator)
3190                    throws NoSuchEntryException {
3191                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3192                                    orderByComparator);
3193    
3194                    if (blogsEntry != null) {
3195                            return blogsEntry;
3196                    }
3197    
3198                    StringBundler msg = new StringBundler(6);
3199    
3200                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3201    
3202                    msg.append("groupId=");
3203                    msg.append(groupId);
3204    
3205                    msg.append(", displayDate=");
3206                    msg.append(displayDate);
3207    
3208                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3209    
3210                    throw new NoSuchEntryException(msg.toString());
3211            }
3212    
3213            /**
3214             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3215             *
3216             * @param groupId the group ID
3217             * @param displayDate the display date
3218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3219             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3220             */
3221            @Override
3222            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3223                    OrderByComparator<BlogsEntry> orderByComparator) {
3224                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3225                                    orderByComparator);
3226    
3227                    if (!list.isEmpty()) {
3228                            return list.get(0);
3229                    }
3230    
3231                    return null;
3232            }
3233    
3234            /**
3235             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3236             *
3237             * @param groupId the group ID
3238             * @param displayDate the display date
3239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3240             * @return the last matching blogs entry
3241             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
3242             */
3243            @Override
3244            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3245                    OrderByComparator<BlogsEntry> orderByComparator)
3246                    throws NoSuchEntryException {
3247                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3248                                    orderByComparator);
3249    
3250                    if (blogsEntry != null) {
3251                            return blogsEntry;
3252                    }
3253    
3254                    StringBundler msg = new StringBundler(6);
3255    
3256                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3257    
3258                    msg.append("groupId=");
3259                    msg.append(groupId);
3260    
3261                    msg.append(", displayDate=");
3262                    msg.append(displayDate);
3263    
3264                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3265    
3266                    throw new NoSuchEntryException(msg.toString());
3267            }
3268    
3269            /**
3270             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3271             *
3272             * @param groupId the group ID
3273             * @param displayDate the display date
3274             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3275             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3276             */
3277            @Override
3278            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3279                    OrderByComparator<BlogsEntry> orderByComparator) {
3280                    int count = countByG_LtD(groupId, displayDate);
3281    
3282                    if (count == 0) {
3283                            return null;
3284                    }
3285    
3286                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3287                                    count, orderByComparator);
3288    
3289                    if (!list.isEmpty()) {
3290                            return list.get(0);
3291                    }
3292    
3293                    return null;
3294            }
3295    
3296            /**
3297             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3298             *
3299             * @param entryId the primary key of the current blogs entry
3300             * @param groupId the group ID
3301             * @param displayDate the display date
3302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3303             * @return the previous, current, and next blogs entry
3304             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3305             */
3306            @Override
3307            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3308                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3309                    throws NoSuchEntryException {
3310                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3311    
3312                    Session session = null;
3313    
3314                    try {
3315                            session = openSession();
3316    
3317                            BlogsEntry[] array = new BlogsEntryImpl[3];
3318    
3319                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3320                                            displayDate, orderByComparator, true);
3321    
3322                            array[1] = blogsEntry;
3323    
3324                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3325                                            displayDate, orderByComparator, false);
3326    
3327                            return array;
3328                    }
3329                    catch (Exception e) {
3330                            throw processException(e);
3331                    }
3332                    finally {
3333                            closeSession(session);
3334                    }
3335            }
3336    
3337            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3338                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3339                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3340                    StringBundler query = null;
3341    
3342                    if (orderByComparator != null) {
3343                            query = new StringBundler(6 +
3344                                            (orderByComparator.getOrderByFields().length * 6));
3345                    }
3346                    else {
3347                            query = new StringBundler(3);
3348                    }
3349    
3350                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3351    
3352                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3353    
3354                    boolean bindDisplayDate = false;
3355    
3356                    if (displayDate == null) {
3357                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3358                    }
3359                    else {
3360                            bindDisplayDate = true;
3361    
3362                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3363                    }
3364    
3365                    if (orderByComparator != null) {
3366                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3367    
3368                            if (orderByConditionFields.length > 0) {
3369                                    query.append(WHERE_AND);
3370                            }
3371    
3372                            for (int i = 0; i < orderByConditionFields.length; i++) {
3373                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3374                                    query.append(orderByConditionFields[i]);
3375    
3376                                    if ((i + 1) < orderByConditionFields.length) {
3377                                            if (orderByComparator.isAscending() ^ previous) {
3378                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3379                                            }
3380                                            else {
3381                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3382                                            }
3383                                    }
3384                                    else {
3385                                            if (orderByComparator.isAscending() ^ previous) {
3386                                                    query.append(WHERE_GREATER_THAN);
3387                                            }
3388                                            else {
3389                                                    query.append(WHERE_LESSER_THAN);
3390                                            }
3391                                    }
3392                            }
3393    
3394                            query.append(ORDER_BY_CLAUSE);
3395    
3396                            String[] orderByFields = orderByComparator.getOrderByFields();
3397    
3398                            for (int i = 0; i < orderByFields.length; i++) {
3399                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3400                                    query.append(orderByFields[i]);
3401    
3402                                    if ((i + 1) < orderByFields.length) {
3403                                            if (orderByComparator.isAscending() ^ previous) {
3404                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3405                                            }
3406                                            else {
3407                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3408                                            }
3409                                    }
3410                                    else {
3411                                            if (orderByComparator.isAscending() ^ previous) {
3412                                                    query.append(ORDER_BY_ASC);
3413                                            }
3414                                            else {
3415                                                    query.append(ORDER_BY_DESC);
3416                                            }
3417                                    }
3418                            }
3419                    }
3420                    else {
3421                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3422                    }
3423    
3424                    String sql = query.toString();
3425    
3426                    Query q = session.createQuery(sql);
3427    
3428                    q.setFirstResult(0);
3429                    q.setMaxResults(2);
3430    
3431                    QueryPos qPos = QueryPos.getInstance(q);
3432    
3433                    qPos.add(groupId);
3434    
3435                    if (bindDisplayDate) {
3436                            qPos.add(new Timestamp(displayDate.getTime()));
3437                    }
3438    
3439                    if (orderByComparator != null) {
3440                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3441    
3442                            for (Object value : values) {
3443                                    qPos.add(value);
3444                            }
3445                    }
3446    
3447                    List<BlogsEntry> list = q.list();
3448    
3449                    if (list.size() == 2) {
3450                            return list.get(1);
3451                    }
3452                    else {
3453                            return null;
3454                    }
3455            }
3456    
3457            /**
3458             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3459             *
3460             * @param groupId the group ID
3461             * @param displayDate the display date
3462             * @return the matching blogs entries that the user has permission to view
3463             */
3464            @Override
3465            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3466                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3467                            QueryUtil.ALL_POS, null);
3468            }
3469    
3470            /**
3471             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3472             *
3473             * <p>
3474             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3475             * </p>
3476             *
3477             * @param groupId the group ID
3478             * @param displayDate the display date
3479             * @param start the lower bound of the range of blogs entries
3480             * @param end the upper bound of the range of blogs entries (not inclusive)
3481             * @return the range of matching blogs entries that the user has permission to view
3482             */
3483            @Override
3484            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3485                    int start, int end) {
3486                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3487            }
3488    
3489            /**
3490             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3491             *
3492             * <p>
3493             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3494             * </p>
3495             *
3496             * @param groupId the group ID
3497             * @param displayDate the display date
3498             * @param start the lower bound of the range of blogs entries
3499             * @param end the upper bound of the range of blogs entries (not inclusive)
3500             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3501             * @return the ordered range of matching blogs entries that the user has permission to view
3502             */
3503            @Override
3504            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3505                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3506                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3507                            return findByG_LtD(groupId, displayDate, start, end,
3508                                    orderByComparator);
3509                    }
3510    
3511                    StringBundler query = null;
3512    
3513                    if (orderByComparator != null) {
3514                            query = new StringBundler(4 +
3515                                            (orderByComparator.getOrderByFields().length * 3));
3516                    }
3517                    else {
3518                            query = new StringBundler(4);
3519                    }
3520    
3521                    if (getDB().isSupportsInlineDistinct()) {
3522                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3523                    }
3524                    else {
3525                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3526                    }
3527    
3528                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3529    
3530                    boolean bindDisplayDate = false;
3531    
3532                    if (displayDate == null) {
3533                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3534                    }
3535                    else {
3536                            bindDisplayDate = true;
3537    
3538                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3539                    }
3540    
3541                    if (!getDB().isSupportsInlineDistinct()) {
3542                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3543                    }
3544    
3545                    if (orderByComparator != null) {
3546                            if (getDB().isSupportsInlineDistinct()) {
3547                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3548                                            orderByComparator, true);
3549                            }
3550                            else {
3551                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3552                                            orderByComparator, true);
3553                            }
3554                    }
3555                    else {
3556                            if (getDB().isSupportsInlineDistinct()) {
3557                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3558                            }
3559                            else {
3560                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3561                            }
3562                    }
3563    
3564                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3565                                    BlogsEntry.class.getName(),
3566                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3567    
3568                    Session session = null;
3569    
3570                    try {
3571                            session = openSession();
3572    
3573                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3574    
3575                            if (getDB().isSupportsInlineDistinct()) {
3576                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3577                            }
3578                            else {
3579                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3580                            }
3581    
3582                            QueryPos qPos = QueryPos.getInstance(q);
3583    
3584                            qPos.add(groupId);
3585    
3586                            if (bindDisplayDate) {
3587                                    qPos.add(new Timestamp(displayDate.getTime()));
3588                            }
3589    
3590                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3591                    }
3592                    catch (Exception e) {
3593                            throw processException(e);
3594                    }
3595                    finally {
3596                            closeSession(session);
3597                    }
3598            }
3599    
3600            /**
3601             * 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;.
3602             *
3603             * @param entryId the primary key of the current blogs entry
3604             * @param groupId the group ID
3605             * @param displayDate the display date
3606             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3607             * @return the previous, current, and next blogs entry
3608             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
3609             */
3610            @Override
3611            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3612                    long groupId, Date displayDate,
3613                    OrderByComparator<BlogsEntry> orderByComparator)
3614                    throws NoSuchEntryException {
3615                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3616                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3617                                    orderByComparator);
3618                    }
3619    
3620                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3621    
3622                    Session session = null;
3623    
3624                    try {
3625                            session = openSession();
3626    
3627                            BlogsEntry[] array = new BlogsEntryImpl[3];
3628    
3629                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3630                                            groupId, displayDate, orderByComparator, true);
3631    
3632                            array[1] = blogsEntry;
3633    
3634                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3635                                            groupId, displayDate, orderByComparator, false);
3636    
3637                            return array;
3638                    }
3639                    catch (Exception e) {
3640                            throw processException(e);
3641                    }
3642                    finally {
3643                            closeSession(session);
3644                    }
3645            }
3646    
3647            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3648                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3649                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3650                    StringBundler query = null;
3651    
3652                    if (orderByComparator != null) {
3653                            query = new StringBundler(6 +
3654                                            (orderByComparator.getOrderByFields().length * 6));
3655                    }
3656                    else {
3657                            query = new StringBundler(3);
3658                    }
3659    
3660                    if (getDB().isSupportsInlineDistinct()) {
3661                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3662                    }
3663                    else {
3664                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3665                    }
3666    
3667                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3668    
3669                    boolean bindDisplayDate = false;
3670    
3671                    if (displayDate == null) {
3672                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3673                    }
3674                    else {
3675                            bindDisplayDate = true;
3676    
3677                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3678                    }
3679    
3680                    if (!getDB().isSupportsInlineDistinct()) {
3681                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3682                    }
3683    
3684                    if (orderByComparator != null) {
3685                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3686    
3687                            if (orderByConditionFields.length > 0) {
3688                                    query.append(WHERE_AND);
3689                            }
3690    
3691                            for (int i = 0; i < orderByConditionFields.length; i++) {
3692                                    if (getDB().isSupportsInlineDistinct()) {
3693                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3694                                    }
3695                                    else {
3696                                            query.append(_ORDER_BY_ENTITY_TABLE);
3697                                    }
3698    
3699                                    query.append(orderByConditionFields[i]);
3700    
3701                                    if ((i + 1) < orderByConditionFields.length) {
3702                                            if (orderByComparator.isAscending() ^ previous) {
3703                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3704                                            }
3705                                            else {
3706                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3707                                            }
3708                                    }
3709                                    else {
3710                                            if (orderByComparator.isAscending() ^ previous) {
3711                                                    query.append(WHERE_GREATER_THAN);
3712                                            }
3713                                            else {
3714                                                    query.append(WHERE_LESSER_THAN);
3715                                            }
3716                                    }
3717                            }
3718    
3719                            query.append(ORDER_BY_CLAUSE);
3720    
3721                            String[] orderByFields = orderByComparator.getOrderByFields();
3722    
3723                            for (int i = 0; i < orderByFields.length; i++) {
3724                                    if (getDB().isSupportsInlineDistinct()) {
3725                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3726                                    }
3727                                    else {
3728                                            query.append(_ORDER_BY_ENTITY_TABLE);
3729                                    }
3730    
3731                                    query.append(orderByFields[i]);
3732    
3733                                    if ((i + 1) < orderByFields.length) {
3734                                            if (orderByComparator.isAscending() ^ previous) {
3735                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3736                                            }
3737                                            else {
3738                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3739                                            }
3740                                    }
3741                                    else {
3742                                            if (orderByComparator.isAscending() ^ previous) {
3743                                                    query.append(ORDER_BY_ASC);
3744                                            }
3745                                            else {
3746                                                    query.append(ORDER_BY_DESC);
3747                                            }
3748                                    }
3749                            }
3750                    }
3751                    else {
3752                            if (getDB().isSupportsInlineDistinct()) {
3753                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3754                            }
3755                            else {
3756                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3757                            }
3758                    }
3759    
3760                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3761                                    BlogsEntry.class.getName(),
3762                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3763    
3764                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3765    
3766                    q.setFirstResult(0);
3767                    q.setMaxResults(2);
3768    
3769                    if (getDB().isSupportsInlineDistinct()) {
3770                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3771                    }
3772                    else {
3773                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3774                    }
3775    
3776                    QueryPos qPos = QueryPos.getInstance(q);
3777    
3778                    qPos.add(groupId);
3779    
3780                    if (bindDisplayDate) {
3781                            qPos.add(new Timestamp(displayDate.getTime()));
3782                    }
3783    
3784                    if (orderByComparator != null) {
3785                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3786    
3787                            for (Object value : values) {
3788                                    qPos.add(value);
3789                            }
3790                    }
3791    
3792                    List<BlogsEntry> list = q.list();
3793    
3794                    if (list.size() == 2) {
3795                            return list.get(1);
3796                    }
3797                    else {
3798                            return null;
3799                    }
3800            }
3801    
3802            /**
3803             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3804             *
3805             * @param groupId the group ID
3806             * @param displayDate the display date
3807             */
3808            @Override
3809            public void removeByG_LtD(long groupId, Date displayDate) {
3810                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3811                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3812                            remove(blogsEntry);
3813                    }
3814            }
3815    
3816            /**
3817             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3818             *
3819             * @param groupId the group ID
3820             * @param displayDate the display date
3821             * @return the number of matching blogs entries
3822             */
3823            @Override
3824            public int countByG_LtD(long groupId, Date displayDate) {
3825                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3826    
3827                    Object[] finderArgs = new Object[] { groupId, displayDate };
3828    
3829                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3830                                    this);
3831    
3832                    if (count == null) {
3833                            StringBundler query = new StringBundler(3);
3834    
3835                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3836    
3837                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3838    
3839                            boolean bindDisplayDate = false;
3840    
3841                            if (displayDate == null) {
3842                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3843                            }
3844                            else {
3845                                    bindDisplayDate = true;
3846    
3847                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3848                            }
3849    
3850                            String sql = query.toString();
3851    
3852                            Session session = null;
3853    
3854                            try {
3855                                    session = openSession();
3856    
3857                                    Query q = session.createQuery(sql);
3858    
3859                                    QueryPos qPos = QueryPos.getInstance(q);
3860    
3861                                    qPos.add(groupId);
3862    
3863                                    if (bindDisplayDate) {
3864                                            qPos.add(new Timestamp(displayDate.getTime()));
3865                                    }
3866    
3867                                    count = (Long)q.uniqueResult();
3868    
3869                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3870                            }
3871                            catch (Exception e) {
3872                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3873    
3874                                    throw processException(e);
3875                            }
3876                            finally {
3877                                    closeSession(session);
3878                            }
3879                    }
3880    
3881                    return count.intValue();
3882            }
3883    
3884            /**
3885             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3886             *
3887             * @param groupId the group ID
3888             * @param displayDate the display date
3889             * @return the number of matching blogs entries that the user has permission to view
3890             */
3891            @Override
3892            public int filterCountByG_LtD(long groupId, Date displayDate) {
3893                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3894                            return countByG_LtD(groupId, displayDate);
3895                    }
3896    
3897                    StringBundler query = new StringBundler(3);
3898    
3899                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
3900    
3901                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3902    
3903                    boolean bindDisplayDate = false;
3904    
3905                    if (displayDate == null) {
3906                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3907                    }
3908                    else {
3909                            bindDisplayDate = true;
3910    
3911                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3912                    }
3913    
3914                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3915                                    BlogsEntry.class.getName(),
3916                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3917    
3918                    Session session = null;
3919    
3920                    try {
3921                            session = openSession();
3922    
3923                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3924    
3925                            q.addScalar(COUNT_COLUMN_NAME,
3926                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3927    
3928                            QueryPos qPos = QueryPos.getInstance(q);
3929    
3930                            qPos.add(groupId);
3931    
3932                            if (bindDisplayDate) {
3933                                    qPos.add(new Timestamp(displayDate.getTime()));
3934                            }
3935    
3936                            Long count = (Long)q.uniqueResult();
3937    
3938                            return count.intValue();
3939                    }
3940                    catch (Exception e) {
3941                            throw processException(e);
3942                    }
3943                    finally {
3944                            closeSession(session);
3945                    }
3946            }
3947    
3948            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3949            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
3950            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
3951            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3952                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3953                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
3954                            new String[] {
3955                                    Long.class.getName(), Integer.class.getName(),
3956                                    
3957                            Integer.class.getName(), Integer.class.getName(),
3958                                    OrderByComparator.class.getName()
3959                            });
3960            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3961                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3962                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
3963                            new String[] { Long.class.getName(), Integer.class.getName() },
3964                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
3965                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
3966                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
3967                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
3968            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3969                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3970                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
3971                            new String[] { Long.class.getName(), Integer.class.getName() });
3972    
3973            /**
3974             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
3975             *
3976             * @param groupId the group ID
3977             * @param status the status
3978             * @return the matching blogs entries
3979             */
3980            @Override
3981            public List<BlogsEntry> findByG_S(long groupId, int status) {
3982                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3983                            null);
3984            }
3985    
3986            /**
3987             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
3988             *
3989             * <p>
3990             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
3991             * </p>
3992             *
3993             * @param groupId the group ID
3994             * @param status the status
3995             * @param start the lower bound of the range of blogs entries
3996             * @param end the upper bound of the range of blogs entries (not inclusive)
3997             * @return the range of matching blogs entries
3998             */
3999            @Override
4000            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4001                    int end) {
4002                    return findByG_S(groupId, status, start, end, null);
4003            }
4004    
4005            /**
4006             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4007             *
4008             * <p>
4009             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
4010             * </p>
4011             *
4012             * @param groupId the group ID
4013             * @param status the status
4014             * @param start the lower bound of the range of blogs entries
4015             * @param end the upper bound of the range of blogs entries (not inclusive)
4016             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4017             * @return the ordered range of matching blogs entries
4018             */
4019            @Override
4020            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4021                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4022                    boolean pagination = true;
4023                    FinderPath finderPath = null;
4024                    Object[] finderArgs = null;
4025    
4026                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4027                                    (orderByComparator == null)) {
4028                            pagination = false;
4029                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4030                            finderArgs = new Object[] { groupId, status };
4031                    }
4032                    else {
4033                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4034                            finderArgs = new Object[] {
4035                                            groupId, status,
4036                                            
4037                                            start, end, orderByComparator
4038                                    };
4039                    }
4040    
4041                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4042                                    finderArgs, this);
4043    
4044                    if ((list != null) && !list.isEmpty()) {
4045                            for (BlogsEntry blogsEntry : list) {
4046                                    if ((groupId != blogsEntry.getGroupId()) ||
4047                                                    (status != blogsEntry.getStatus())) {
4048                                            list = null;
4049    
4050                                            break;
4051                                    }
4052                            }
4053                    }
4054    
4055                    if (list == null) {
4056                            StringBundler query = null;
4057    
4058                            if (orderByComparator != null) {
4059                                    query = new StringBundler(4 +
4060                                                    (orderByComparator.getOrderByFields().length * 3));
4061                            }
4062                            else {
4063                                    query = new StringBundler(4);
4064                            }
4065    
4066                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4067    
4068                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4069    
4070                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4071    
4072                            if (orderByComparator != null) {
4073                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4074                                            orderByComparator);
4075                            }
4076                            else
4077                             if (pagination) {
4078                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4079                            }
4080    
4081                            String sql = query.toString();
4082    
4083                            Session session = null;
4084    
4085                            try {
4086                                    session = openSession();
4087    
4088                                    Query q = session.createQuery(sql);
4089    
4090                                    QueryPos qPos = QueryPos.getInstance(q);
4091    
4092                                    qPos.add(groupId);
4093    
4094                                    qPos.add(status);
4095    
4096                                    if (!pagination) {
4097                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4098                                                            start, end, false);
4099    
4100                                            Collections.sort(list);
4101    
4102                                            list = Collections.unmodifiableList(list);
4103                                    }
4104                                    else {
4105                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4106                                                            start, end);
4107                                    }
4108    
4109                                    cacheResult(list);
4110    
4111                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4112                            }
4113                            catch (Exception e) {
4114                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4115    
4116                                    throw processException(e);
4117                            }
4118                            finally {
4119                                    closeSession(session);
4120                            }
4121                    }
4122    
4123                    return list;
4124            }
4125    
4126            /**
4127             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4128             *
4129             * @param groupId the group ID
4130             * @param status the status
4131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4132             * @return the first matching blogs entry
4133             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4134             */
4135            @Override
4136            public BlogsEntry findByG_S_First(long groupId, int status,
4137                    OrderByComparator<BlogsEntry> orderByComparator)
4138                    throws NoSuchEntryException {
4139                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4140                                    orderByComparator);
4141    
4142                    if (blogsEntry != null) {
4143                            return blogsEntry;
4144                    }
4145    
4146                    StringBundler msg = new StringBundler(6);
4147    
4148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4149    
4150                    msg.append("groupId=");
4151                    msg.append(groupId);
4152    
4153                    msg.append(", status=");
4154                    msg.append(status);
4155    
4156                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4157    
4158                    throw new NoSuchEntryException(msg.toString());
4159            }
4160    
4161            /**
4162             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4163             *
4164             * @param groupId the group ID
4165             * @param status the status
4166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4167             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4168             */
4169            @Override
4170            public BlogsEntry fetchByG_S_First(long groupId, int status,
4171                    OrderByComparator<BlogsEntry> orderByComparator) {
4172                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4173                                    orderByComparator);
4174    
4175                    if (!list.isEmpty()) {
4176                            return list.get(0);
4177                    }
4178    
4179                    return null;
4180            }
4181    
4182            /**
4183             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4184             *
4185             * @param groupId the group ID
4186             * @param status the status
4187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4188             * @return the last matching blogs entry
4189             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
4190             */
4191            @Override
4192            public BlogsEntry findByG_S_Last(long groupId, int status,
4193                    OrderByComparator<BlogsEntry> orderByComparator)
4194                    throws NoSuchEntryException {
4195                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4196                                    orderByComparator);
4197    
4198                    if (blogsEntry != null) {
4199                            return blogsEntry;
4200                    }
4201    
4202                    StringBundler msg = new StringBundler(6);
4203    
4204                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4205    
4206                    msg.append("groupId=");
4207                    msg.append(groupId);
4208    
4209                    msg.append(", status=");
4210                    msg.append(status);
4211    
4212                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4213    
4214                    throw new NoSuchEntryException(msg.toString());
4215            }
4216    
4217            /**
4218             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4219             *
4220             * @param groupId the group ID
4221             * @param status the status
4222             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4223             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4224             */
4225            @Override
4226            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4227                    OrderByComparator<BlogsEntry> orderByComparator) {
4228                    int count = countByG_S(groupId, status);
4229    
4230                    if (count == 0) {
4231                            return null;
4232                    }
4233    
4234                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4235                                    orderByComparator);
4236    
4237                    if (!list.isEmpty()) {
4238                            return list.get(0);
4239                    }
4240    
4241                    return null;
4242            }
4243    
4244            /**
4245             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4246             *
4247             * @param entryId the primary key of the current blogs entry
4248             * @param groupId the group ID
4249             * @param status the status
4250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4251             * @return the previous, current, and next blogs entry
4252             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4253             */
4254            @Override
4255            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4256                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4257                    throws NoSuchEntryException {
4258                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4259    
4260                    Session session = null;
4261    
4262                    try {
4263                            session = openSession();
4264    
4265                            BlogsEntry[] array = new BlogsEntryImpl[3];
4266    
4267                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4268                                            status, orderByComparator, true);
4269    
4270                            array[1] = blogsEntry;
4271    
4272                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4273                                            status, orderByComparator, false);
4274    
4275                            return array;
4276                    }
4277                    catch (Exception e) {
4278                            throw processException(e);
4279                    }
4280                    finally {
4281                            closeSession(session);
4282                    }
4283            }
4284    
4285            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4286                    BlogsEntry blogsEntry, long groupId, int status,
4287                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4288                    StringBundler query = null;
4289    
4290                    if (orderByComparator != null) {
4291                            query = new StringBundler(6 +
4292                                            (orderByComparator.getOrderByFields().length * 6));
4293                    }
4294                    else {
4295                            query = new StringBundler(3);
4296                    }
4297    
4298                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4299    
4300                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4301    
4302                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4303    
4304                    if (orderByComparator != null) {
4305                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4306    
4307                            if (orderByConditionFields.length > 0) {
4308                                    query.append(WHERE_AND);
4309                            }
4310    
4311                            for (int i = 0; i < orderByConditionFields.length; i++) {
4312                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4313                                    query.append(orderByConditionFields[i]);
4314    
4315                                    if ((i + 1) < orderByConditionFields.length) {
4316                                            if (orderByComparator.isAscending() ^ previous) {
4317                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4318                                            }
4319                                            else {
4320                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4321                                            }
4322                                    }
4323                                    else {
4324                                            if (orderByComparator.isAscending() ^ previous) {
4325                                                    query.append(WHERE_GREATER_THAN);
4326                                            }
4327                                            else {
4328                                                    query.append(WHERE_LESSER_THAN);
4329                                            }
4330                                    }
4331                            }
4332    
4333                            query.append(ORDER_BY_CLAUSE);
4334    
4335                            String[] orderByFields = orderByComparator.getOrderByFields();
4336    
4337                            for (int i = 0; i < orderByFields.length; i++) {
4338                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4339                                    query.append(orderByFields[i]);
4340    
4341                                    if ((i + 1) < orderByFields.length) {
4342                                            if (orderByComparator.isAscending() ^ previous) {
4343                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4344                                            }
4345                                            else {
4346                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4347                                            }
4348                                    }
4349                                    else {
4350                                            if (orderByComparator.isAscending() ^ previous) {
4351                                                    query.append(ORDER_BY_ASC);
4352                                            }
4353                                            else {
4354                                                    query.append(ORDER_BY_DESC);
4355                                            }
4356                                    }
4357                            }
4358                    }
4359                    else {
4360                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4361                    }
4362    
4363                    String sql = query.toString();
4364    
4365                    Query q = session.createQuery(sql);
4366    
4367                    q.setFirstResult(0);
4368                    q.setMaxResults(2);
4369    
4370                    QueryPos qPos = QueryPos.getInstance(q);
4371    
4372                    qPos.add(groupId);
4373    
4374                    qPos.add(status);
4375    
4376                    if (orderByComparator != null) {
4377                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4378    
4379                            for (Object value : values) {
4380                                    qPos.add(value);
4381                            }
4382                    }
4383    
4384                    List<BlogsEntry> list = q.list();
4385    
4386                    if (list.size() == 2) {
4387                            return list.get(1);
4388                    }
4389                    else {
4390                            return null;
4391                    }
4392            }
4393    
4394            /**
4395             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4396             *
4397             * @param groupId the group ID
4398             * @param status the status
4399             * @return the matching blogs entries that the user has permission to view
4400             */
4401            @Override
4402            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4403                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4404                            QueryUtil.ALL_POS, null);
4405            }
4406    
4407            /**
4408             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4409             *
4410             * <p>
4411             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
4412             * </p>
4413             *
4414             * @param groupId the group ID
4415             * @param status the status
4416             * @param start the lower bound of the range of blogs entries
4417             * @param end the upper bound of the range of blogs entries (not inclusive)
4418             * @return the range of matching blogs entries that the user has permission to view
4419             */
4420            @Override
4421            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4422                    int start, int end) {
4423                    return filterFindByG_S(groupId, status, start, end, null);
4424            }
4425    
4426            /**
4427             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4428             *
4429             * <p>
4430             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
4431             * </p>
4432             *
4433             * @param groupId the group ID
4434             * @param status the status
4435             * @param start the lower bound of the range of blogs entries
4436             * @param end the upper bound of the range of blogs entries (not inclusive)
4437             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4438             * @return the ordered range of matching blogs entries that the user has permission to view
4439             */
4440            @Override
4441            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4442                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4443                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4444                            return findByG_S(groupId, status, start, end, orderByComparator);
4445                    }
4446    
4447                    StringBundler query = null;
4448    
4449                    if (orderByComparator != null) {
4450                            query = new StringBundler(4 +
4451                                            (orderByComparator.getOrderByFields().length * 3));
4452                    }
4453                    else {
4454                            query = new StringBundler(4);
4455                    }
4456    
4457                    if (getDB().isSupportsInlineDistinct()) {
4458                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4459                    }
4460                    else {
4461                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4462                    }
4463    
4464                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4465    
4466                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4467    
4468                    if (!getDB().isSupportsInlineDistinct()) {
4469                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4470                    }
4471    
4472                    if (orderByComparator != null) {
4473                            if (getDB().isSupportsInlineDistinct()) {
4474                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4475                                            orderByComparator, true);
4476                            }
4477                            else {
4478                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4479                                            orderByComparator, true);
4480                            }
4481                    }
4482                    else {
4483                            if (getDB().isSupportsInlineDistinct()) {
4484                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4485                            }
4486                            else {
4487                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4488                            }
4489                    }
4490    
4491                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4492                                    BlogsEntry.class.getName(),
4493                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4494    
4495                    Session session = null;
4496    
4497                    try {
4498                            session = openSession();
4499    
4500                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4501    
4502                            if (getDB().isSupportsInlineDistinct()) {
4503                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4504                            }
4505                            else {
4506                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4507                            }
4508    
4509                            QueryPos qPos = QueryPos.getInstance(q);
4510    
4511                            qPos.add(groupId);
4512    
4513                            qPos.add(status);
4514    
4515                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4516                    }
4517                    catch (Exception e) {
4518                            throw processException(e);
4519                    }
4520                    finally {
4521                            closeSession(session);
4522                    }
4523            }
4524    
4525            /**
4526             * 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;.
4527             *
4528             * @param entryId the primary key of the current blogs entry
4529             * @param groupId the group ID
4530             * @param status the status
4531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4532             * @return the previous, current, and next blogs entry
4533             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
4534             */
4535            @Override
4536            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4537                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4538                    throws NoSuchEntryException {
4539                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4540                            return findByG_S_PrevAndNext(entryId, groupId, status,
4541                                    orderByComparator);
4542                    }
4543    
4544                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4545    
4546                    Session session = null;
4547    
4548                    try {
4549                            session = openSession();
4550    
4551                            BlogsEntry[] array = new BlogsEntryImpl[3];
4552    
4553                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4554                                            status, orderByComparator, true);
4555    
4556                            array[1] = blogsEntry;
4557    
4558                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4559                                            status, orderByComparator, false);
4560    
4561                            return array;
4562                    }
4563                    catch (Exception e) {
4564                            throw processException(e);
4565                    }
4566                    finally {
4567                            closeSession(session);
4568                    }
4569            }
4570    
4571            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4572                    BlogsEntry blogsEntry, long groupId, int status,
4573                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4574                    StringBundler query = null;
4575    
4576                    if (orderByComparator != null) {
4577                            query = new StringBundler(6 +
4578                                            (orderByComparator.getOrderByFields().length * 6));
4579                    }
4580                    else {
4581                            query = new StringBundler(3);
4582                    }
4583    
4584                    if (getDB().isSupportsInlineDistinct()) {
4585                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4586                    }
4587                    else {
4588                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4589                    }
4590    
4591                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4592    
4593                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4594    
4595                    if (!getDB().isSupportsInlineDistinct()) {
4596                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4597                    }
4598    
4599                    if (orderByComparator != null) {
4600                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4601    
4602                            if (orderByConditionFields.length > 0) {
4603                                    query.append(WHERE_AND);
4604                            }
4605    
4606                            for (int i = 0; i < orderByConditionFields.length; i++) {
4607                                    if (getDB().isSupportsInlineDistinct()) {
4608                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4609                                    }
4610                                    else {
4611                                            query.append(_ORDER_BY_ENTITY_TABLE);
4612                                    }
4613    
4614                                    query.append(orderByConditionFields[i]);
4615    
4616                                    if ((i + 1) < orderByConditionFields.length) {
4617                                            if (orderByComparator.isAscending() ^ previous) {
4618                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4619                                            }
4620                                            else {
4621                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4622                                            }
4623                                    }
4624                                    else {
4625                                            if (orderByComparator.isAscending() ^ previous) {
4626                                                    query.append(WHERE_GREATER_THAN);
4627                                            }
4628                                            else {
4629                                                    query.append(WHERE_LESSER_THAN);
4630                                            }
4631                                    }
4632                            }
4633    
4634                            query.append(ORDER_BY_CLAUSE);
4635    
4636                            String[] orderByFields = orderByComparator.getOrderByFields();
4637    
4638                            for (int i = 0; i < orderByFields.length; i++) {
4639                                    if (getDB().isSupportsInlineDistinct()) {
4640                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4641                                    }
4642                                    else {
4643                                            query.append(_ORDER_BY_ENTITY_TABLE);
4644                                    }
4645    
4646                                    query.append(orderByFields[i]);
4647    
4648                                    if ((i + 1) < orderByFields.length) {
4649                                            if (orderByComparator.isAscending() ^ previous) {
4650                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4651                                            }
4652                                            else {
4653                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4654                                            }
4655                                    }
4656                                    else {
4657                                            if (orderByComparator.isAscending() ^ previous) {
4658                                                    query.append(ORDER_BY_ASC);
4659                                            }
4660                                            else {
4661                                                    query.append(ORDER_BY_DESC);
4662                                            }
4663                                    }
4664                            }
4665                    }
4666                    else {
4667                            if (getDB().isSupportsInlineDistinct()) {
4668                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4669                            }
4670                            else {
4671                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4672                            }
4673                    }
4674    
4675                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4676                                    BlogsEntry.class.getName(),
4677                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4678    
4679                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4680    
4681                    q.setFirstResult(0);
4682                    q.setMaxResults(2);
4683    
4684                    if (getDB().isSupportsInlineDistinct()) {
4685                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4686                    }
4687                    else {
4688                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4689                    }
4690    
4691                    QueryPos qPos = QueryPos.getInstance(q);
4692    
4693                    qPos.add(groupId);
4694    
4695                    qPos.add(status);
4696    
4697                    if (orderByComparator != null) {
4698                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4699    
4700                            for (Object value : values) {
4701                                    qPos.add(value);
4702                            }
4703                    }
4704    
4705                    List<BlogsEntry> list = q.list();
4706    
4707                    if (list.size() == 2) {
4708                            return list.get(1);
4709                    }
4710                    else {
4711                            return null;
4712                    }
4713            }
4714    
4715            /**
4716             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4717             *
4718             * @param groupId the group ID
4719             * @param status the status
4720             */
4721            @Override
4722            public void removeByG_S(long groupId, int status) {
4723                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4724                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4725                            remove(blogsEntry);
4726                    }
4727            }
4728    
4729            /**
4730             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4731             *
4732             * @param groupId the group ID
4733             * @param status the status
4734             * @return the number of matching blogs entries
4735             */
4736            @Override
4737            public int countByG_S(long groupId, int status) {
4738                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4739    
4740                    Object[] finderArgs = new Object[] { groupId, status };
4741    
4742                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4743                                    this);
4744    
4745                    if (count == null) {
4746                            StringBundler query = new StringBundler(3);
4747    
4748                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4749    
4750                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4751    
4752                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4753    
4754                            String sql = query.toString();
4755    
4756                            Session session = null;
4757    
4758                            try {
4759                                    session = openSession();
4760    
4761                                    Query q = session.createQuery(sql);
4762    
4763                                    QueryPos qPos = QueryPos.getInstance(q);
4764    
4765                                    qPos.add(groupId);
4766    
4767                                    qPos.add(status);
4768    
4769                                    count = (Long)q.uniqueResult();
4770    
4771                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4772                            }
4773                            catch (Exception e) {
4774                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4775    
4776                                    throw processException(e);
4777                            }
4778                            finally {
4779                                    closeSession(session);
4780                            }
4781                    }
4782    
4783                    return count.intValue();
4784            }
4785    
4786            /**
4787             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4788             *
4789             * @param groupId the group ID
4790             * @param status the status
4791             * @return the number of matching blogs entries that the user has permission to view
4792             */
4793            @Override
4794            public int filterCountByG_S(long groupId, int status) {
4795                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4796                            return countByG_S(groupId, status);
4797                    }
4798    
4799                    StringBundler query = new StringBundler(3);
4800    
4801                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4802    
4803                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4804    
4805                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4806    
4807                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4808                                    BlogsEntry.class.getName(),
4809                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4810    
4811                    Session session = null;
4812    
4813                    try {
4814                            session = openSession();
4815    
4816                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4817    
4818                            q.addScalar(COUNT_COLUMN_NAME,
4819                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4820    
4821                            QueryPos qPos = QueryPos.getInstance(q);
4822    
4823                            qPos.add(groupId);
4824    
4825                            qPos.add(status);
4826    
4827                            Long count = (Long)q.uniqueResult();
4828    
4829                            return count.intValue();
4830                    }
4831                    catch (Exception e) {
4832                            throw processException(e);
4833                    }
4834                    finally {
4835                            closeSession(session);
4836                    }
4837            }
4838    
4839            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4840            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
4841            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4842                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4843                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
4844                            new String[] {
4845                                    Long.class.getName(), Integer.class.getName(),
4846                                    
4847                            Integer.class.getName(), Integer.class.getName(),
4848                                    OrderByComparator.class.getName()
4849                            });
4850            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4851                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4852                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
4853                            new String[] { Long.class.getName(), Integer.class.getName() });
4854    
4855            /**
4856             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
4857             *
4858             * @param groupId the group ID
4859             * @param status the status
4860             * @return the matching blogs entries
4861             */
4862            @Override
4863            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
4864                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
4865                            QueryUtil.ALL_POS, null);
4866            }
4867    
4868            /**
4869             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
4870             *
4871             * <p>
4872             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
4873             * </p>
4874             *
4875             * @param groupId the group ID
4876             * @param status the status
4877             * @param start the lower bound of the range of blogs entries
4878             * @param end the upper bound of the range of blogs entries (not inclusive)
4879             * @return the range of matching blogs entries
4880             */
4881            @Override
4882            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
4883                    int end) {
4884                    return findByG_NotS(groupId, status, start, end, null);
4885            }
4886    
4887            /**
4888             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
4889             *
4890             * <p>
4891             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
4892             * </p>
4893             *
4894             * @param groupId the group ID
4895             * @param status the status
4896             * @param start the lower bound of the range of blogs entries
4897             * @param end the upper bound of the range of blogs entries (not inclusive)
4898             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4899             * @return the ordered range of matching blogs entries
4900             */
4901            @Override
4902            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
4903                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4904                    boolean pagination = true;
4905                    FinderPath finderPath = null;
4906                    Object[] finderArgs = null;
4907    
4908                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
4909                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
4910    
4911                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4912                                    finderArgs, this);
4913    
4914                    if ((list != null) && !list.isEmpty()) {
4915                            for (BlogsEntry blogsEntry : list) {
4916                                    if ((groupId != blogsEntry.getGroupId()) ||
4917                                                    (status == blogsEntry.getStatus())) {
4918                                            list = null;
4919    
4920                                            break;
4921                                    }
4922                            }
4923                    }
4924    
4925                    if (list == null) {
4926                            StringBundler query = null;
4927    
4928                            if (orderByComparator != null) {
4929                                    query = new StringBundler(4 +
4930                                                    (orderByComparator.getOrderByFields().length * 3));
4931                            }
4932                            else {
4933                                    query = new StringBundler(4);
4934                            }
4935    
4936                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4937    
4938                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
4939    
4940                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
4941    
4942                            if (orderByComparator != null) {
4943                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4944                                            orderByComparator);
4945                            }
4946                            else
4947                             if (pagination) {
4948                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4949                            }
4950    
4951                            String sql = query.toString();
4952    
4953                            Session session = null;
4954    
4955                            try {
4956                                    session = openSession();
4957    
4958                                    Query q = session.createQuery(sql);
4959    
4960                                    QueryPos qPos = QueryPos.getInstance(q);
4961    
4962                                    qPos.add(groupId);
4963    
4964                                    qPos.add(status);
4965    
4966                                    if (!pagination) {
4967                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4968                                                            start, end, false);
4969    
4970                                            Collections.sort(list);
4971    
4972                                            list = Collections.unmodifiableList(list);
4973                                    }
4974                                    else {
4975                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4976                                                            start, end);
4977                                    }
4978    
4979                                    cacheResult(list);
4980    
4981                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4982                            }
4983                            catch (Exception e) {
4984                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4985    
4986                                    throw processException(e);
4987                            }
4988                            finally {
4989                                    closeSession(session);
4990                            }
4991                    }
4992    
4993                    return list;
4994            }
4995    
4996            /**
4997             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4998             *
4999             * @param groupId the group ID
5000             * @param status the status
5001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5002             * @return the first matching blogs entry
5003             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5004             */
5005            @Override
5006            public BlogsEntry findByG_NotS_First(long groupId, int status,
5007                    OrderByComparator<BlogsEntry> orderByComparator)
5008                    throws NoSuchEntryException {
5009                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5010                                    orderByComparator);
5011    
5012                    if (blogsEntry != null) {
5013                            return blogsEntry;
5014                    }
5015    
5016                    StringBundler msg = new StringBundler(6);
5017    
5018                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5019    
5020                    msg.append("groupId=");
5021                    msg.append(groupId);
5022    
5023                    msg.append(", status=");
5024                    msg.append(status);
5025    
5026                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5027    
5028                    throw new NoSuchEntryException(msg.toString());
5029            }
5030    
5031            /**
5032             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5033             *
5034             * @param groupId the group ID
5035             * @param status the status
5036             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5037             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5038             */
5039            @Override
5040            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5041                    OrderByComparator<BlogsEntry> orderByComparator) {
5042                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5043                                    orderByComparator);
5044    
5045                    if (!list.isEmpty()) {
5046                            return list.get(0);
5047                    }
5048    
5049                    return null;
5050            }
5051    
5052            /**
5053             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5054             *
5055             * @param groupId the group ID
5056             * @param status the status
5057             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5058             * @return the last matching blogs entry
5059             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5060             */
5061            @Override
5062            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5063                    OrderByComparator<BlogsEntry> orderByComparator)
5064                    throws NoSuchEntryException {
5065                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5066                                    orderByComparator);
5067    
5068                    if (blogsEntry != null) {
5069                            return blogsEntry;
5070                    }
5071    
5072                    StringBundler msg = new StringBundler(6);
5073    
5074                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5075    
5076                    msg.append("groupId=");
5077                    msg.append(groupId);
5078    
5079                    msg.append(", status=");
5080                    msg.append(status);
5081    
5082                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5083    
5084                    throw new NoSuchEntryException(msg.toString());
5085            }
5086    
5087            /**
5088             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5089             *
5090             * @param groupId the group ID
5091             * @param status the status
5092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5093             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5094             */
5095            @Override
5096            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5097                    OrderByComparator<BlogsEntry> orderByComparator) {
5098                    int count = countByG_NotS(groupId, status);
5099    
5100                    if (count == 0) {
5101                            return null;
5102                    }
5103    
5104                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5105                                    orderByComparator);
5106    
5107                    if (!list.isEmpty()) {
5108                            return list.get(0);
5109                    }
5110    
5111                    return null;
5112            }
5113    
5114            /**
5115             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5116             *
5117             * @param entryId the primary key of the current blogs entry
5118             * @param groupId the group ID
5119             * @param status the status
5120             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5121             * @return the previous, current, and next blogs entry
5122             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5123             */
5124            @Override
5125            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5126                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5127                    throws NoSuchEntryException {
5128                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5129    
5130                    Session session = null;
5131    
5132                    try {
5133                            session = openSession();
5134    
5135                            BlogsEntry[] array = new BlogsEntryImpl[3];
5136    
5137                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5138                                            status, orderByComparator, true);
5139    
5140                            array[1] = blogsEntry;
5141    
5142                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5143                                            status, orderByComparator, false);
5144    
5145                            return array;
5146                    }
5147                    catch (Exception e) {
5148                            throw processException(e);
5149                    }
5150                    finally {
5151                            closeSession(session);
5152                    }
5153            }
5154    
5155            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5156                    BlogsEntry blogsEntry, long groupId, int status,
5157                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5158                    StringBundler query = null;
5159    
5160                    if (orderByComparator != null) {
5161                            query = new StringBundler(6 +
5162                                            (orderByComparator.getOrderByFields().length * 6));
5163                    }
5164                    else {
5165                            query = new StringBundler(3);
5166                    }
5167    
5168                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5169    
5170                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5171    
5172                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5173    
5174                    if (orderByComparator != null) {
5175                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5176    
5177                            if (orderByConditionFields.length > 0) {
5178                                    query.append(WHERE_AND);
5179                            }
5180    
5181                            for (int i = 0; i < orderByConditionFields.length; i++) {
5182                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5183                                    query.append(orderByConditionFields[i]);
5184    
5185                                    if ((i + 1) < orderByConditionFields.length) {
5186                                            if (orderByComparator.isAscending() ^ previous) {
5187                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5188                                            }
5189                                            else {
5190                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5191                                            }
5192                                    }
5193                                    else {
5194                                            if (orderByComparator.isAscending() ^ previous) {
5195                                                    query.append(WHERE_GREATER_THAN);
5196                                            }
5197                                            else {
5198                                                    query.append(WHERE_LESSER_THAN);
5199                                            }
5200                                    }
5201                            }
5202    
5203                            query.append(ORDER_BY_CLAUSE);
5204    
5205                            String[] orderByFields = orderByComparator.getOrderByFields();
5206    
5207                            for (int i = 0; i < orderByFields.length; i++) {
5208                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5209                                    query.append(orderByFields[i]);
5210    
5211                                    if ((i + 1) < orderByFields.length) {
5212                                            if (orderByComparator.isAscending() ^ previous) {
5213                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5214                                            }
5215                                            else {
5216                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5217                                            }
5218                                    }
5219                                    else {
5220                                            if (orderByComparator.isAscending() ^ previous) {
5221                                                    query.append(ORDER_BY_ASC);
5222                                            }
5223                                            else {
5224                                                    query.append(ORDER_BY_DESC);
5225                                            }
5226                                    }
5227                            }
5228                    }
5229                    else {
5230                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5231                    }
5232    
5233                    String sql = query.toString();
5234    
5235                    Query q = session.createQuery(sql);
5236    
5237                    q.setFirstResult(0);
5238                    q.setMaxResults(2);
5239    
5240                    QueryPos qPos = QueryPos.getInstance(q);
5241    
5242                    qPos.add(groupId);
5243    
5244                    qPos.add(status);
5245    
5246                    if (orderByComparator != null) {
5247                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5248    
5249                            for (Object value : values) {
5250                                    qPos.add(value);
5251                            }
5252                    }
5253    
5254                    List<BlogsEntry> list = q.list();
5255    
5256                    if (list.size() == 2) {
5257                            return list.get(1);
5258                    }
5259                    else {
5260                            return null;
5261                    }
5262            }
5263    
5264            /**
5265             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5266             *
5267             * @param groupId the group ID
5268             * @param status the status
5269             * @return the matching blogs entries that the user has permission to view
5270             */
5271            @Override
5272            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5273                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5274                            QueryUtil.ALL_POS, null);
5275            }
5276    
5277            /**
5278             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5279             *
5280             * <p>
5281             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5282             * </p>
5283             *
5284             * @param groupId the group ID
5285             * @param status the status
5286             * @param start the lower bound of the range of blogs entries
5287             * @param end the upper bound of the range of blogs entries (not inclusive)
5288             * @return the range of matching blogs entries that the user has permission to view
5289             */
5290            @Override
5291            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5292                    int start, int end) {
5293                    return filterFindByG_NotS(groupId, status, start, end, null);
5294            }
5295    
5296            /**
5297             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5298             *
5299             * <p>
5300             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5301             * </p>
5302             *
5303             * @param groupId the group ID
5304             * @param status the status
5305             * @param start the lower bound of the range of blogs entries
5306             * @param end the upper bound of the range of blogs entries (not inclusive)
5307             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5308             * @return the ordered range of matching blogs entries that the user has permission to view
5309             */
5310            @Override
5311            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5312                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5313                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5314                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5315                    }
5316    
5317                    StringBundler query = null;
5318    
5319                    if (orderByComparator != null) {
5320                            query = new StringBundler(4 +
5321                                            (orderByComparator.getOrderByFields().length * 3));
5322                    }
5323                    else {
5324                            query = new StringBundler(4);
5325                    }
5326    
5327                    if (getDB().isSupportsInlineDistinct()) {
5328                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5329                    }
5330                    else {
5331                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5332                    }
5333    
5334                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5335    
5336                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5337    
5338                    if (!getDB().isSupportsInlineDistinct()) {
5339                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5340                    }
5341    
5342                    if (orderByComparator != null) {
5343                            if (getDB().isSupportsInlineDistinct()) {
5344                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5345                                            orderByComparator, true);
5346                            }
5347                            else {
5348                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5349                                            orderByComparator, true);
5350                            }
5351                    }
5352                    else {
5353                            if (getDB().isSupportsInlineDistinct()) {
5354                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5355                            }
5356                            else {
5357                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5358                            }
5359                    }
5360    
5361                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5362                                    BlogsEntry.class.getName(),
5363                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5364    
5365                    Session session = null;
5366    
5367                    try {
5368                            session = openSession();
5369    
5370                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5371    
5372                            if (getDB().isSupportsInlineDistinct()) {
5373                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5374                            }
5375                            else {
5376                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5377                            }
5378    
5379                            QueryPos qPos = QueryPos.getInstance(q);
5380    
5381                            qPos.add(groupId);
5382    
5383                            qPos.add(status);
5384    
5385                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5386                    }
5387                    catch (Exception e) {
5388                            throw processException(e);
5389                    }
5390                    finally {
5391                            closeSession(session);
5392                    }
5393            }
5394    
5395            /**
5396             * 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;.
5397             *
5398             * @param entryId the primary key of the current blogs entry
5399             * @param groupId the group ID
5400             * @param status the status
5401             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5402             * @return the previous, current, and next blogs entry
5403             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
5404             */
5405            @Override
5406            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5407                    long groupId, int status,
5408                    OrderByComparator<BlogsEntry> orderByComparator)
5409                    throws NoSuchEntryException {
5410                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5411                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5412                                    orderByComparator);
5413                    }
5414    
5415                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5416    
5417                    Session session = null;
5418    
5419                    try {
5420                            session = openSession();
5421    
5422                            BlogsEntry[] array = new BlogsEntryImpl[3];
5423    
5424                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5425                                            groupId, status, orderByComparator, true);
5426    
5427                            array[1] = blogsEntry;
5428    
5429                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5430                                            groupId, status, orderByComparator, false);
5431    
5432                            return array;
5433                    }
5434                    catch (Exception e) {
5435                            throw processException(e);
5436                    }
5437                    finally {
5438                            closeSession(session);
5439                    }
5440            }
5441    
5442            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5443                    BlogsEntry blogsEntry, long groupId, int status,
5444                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5445                    StringBundler query = null;
5446    
5447                    if (orderByComparator != null) {
5448                            query = new StringBundler(6 +
5449                                            (orderByComparator.getOrderByFields().length * 6));
5450                    }
5451                    else {
5452                            query = new StringBundler(3);
5453                    }
5454    
5455                    if (getDB().isSupportsInlineDistinct()) {
5456                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5457                    }
5458                    else {
5459                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5460                    }
5461    
5462                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5463    
5464                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5465    
5466                    if (!getDB().isSupportsInlineDistinct()) {
5467                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5468                    }
5469    
5470                    if (orderByComparator != null) {
5471                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5472    
5473                            if (orderByConditionFields.length > 0) {
5474                                    query.append(WHERE_AND);
5475                            }
5476    
5477                            for (int i = 0; i < orderByConditionFields.length; i++) {
5478                                    if (getDB().isSupportsInlineDistinct()) {
5479                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5480                                    }
5481                                    else {
5482                                            query.append(_ORDER_BY_ENTITY_TABLE);
5483                                    }
5484    
5485                                    query.append(orderByConditionFields[i]);
5486    
5487                                    if ((i + 1) < orderByConditionFields.length) {
5488                                            if (orderByComparator.isAscending() ^ previous) {
5489                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5490                                            }
5491                                            else {
5492                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5493                                            }
5494                                    }
5495                                    else {
5496                                            if (orderByComparator.isAscending() ^ previous) {
5497                                                    query.append(WHERE_GREATER_THAN);
5498                                            }
5499                                            else {
5500                                                    query.append(WHERE_LESSER_THAN);
5501                                            }
5502                                    }
5503                            }
5504    
5505                            query.append(ORDER_BY_CLAUSE);
5506    
5507                            String[] orderByFields = orderByComparator.getOrderByFields();
5508    
5509                            for (int i = 0; i < orderByFields.length; i++) {
5510                                    if (getDB().isSupportsInlineDistinct()) {
5511                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5512                                    }
5513                                    else {
5514                                            query.append(_ORDER_BY_ENTITY_TABLE);
5515                                    }
5516    
5517                                    query.append(orderByFields[i]);
5518    
5519                                    if ((i + 1) < orderByFields.length) {
5520                                            if (orderByComparator.isAscending() ^ previous) {
5521                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5522                                            }
5523                                            else {
5524                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5525                                            }
5526                                    }
5527                                    else {
5528                                            if (orderByComparator.isAscending() ^ previous) {
5529                                                    query.append(ORDER_BY_ASC);
5530                                            }
5531                                            else {
5532                                                    query.append(ORDER_BY_DESC);
5533                                            }
5534                                    }
5535                            }
5536                    }
5537                    else {
5538                            if (getDB().isSupportsInlineDistinct()) {
5539                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5540                            }
5541                            else {
5542                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5543                            }
5544                    }
5545    
5546                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5547                                    BlogsEntry.class.getName(),
5548                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5549    
5550                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5551    
5552                    q.setFirstResult(0);
5553                    q.setMaxResults(2);
5554    
5555                    if (getDB().isSupportsInlineDistinct()) {
5556                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5557                    }
5558                    else {
5559                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5560                    }
5561    
5562                    QueryPos qPos = QueryPos.getInstance(q);
5563    
5564                    qPos.add(groupId);
5565    
5566                    qPos.add(status);
5567    
5568                    if (orderByComparator != null) {
5569                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5570    
5571                            for (Object value : values) {
5572                                    qPos.add(value);
5573                            }
5574                    }
5575    
5576                    List<BlogsEntry> list = q.list();
5577    
5578                    if (list.size() == 2) {
5579                            return list.get(1);
5580                    }
5581                    else {
5582                            return null;
5583                    }
5584            }
5585    
5586            /**
5587             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5588             *
5589             * @param groupId the group ID
5590             * @param status the status
5591             */
5592            @Override
5593            public void removeByG_NotS(long groupId, int status) {
5594                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5595                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5596                            remove(blogsEntry);
5597                    }
5598            }
5599    
5600            /**
5601             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5602             *
5603             * @param groupId the group ID
5604             * @param status the status
5605             * @return the number of matching blogs entries
5606             */
5607            @Override
5608            public int countByG_NotS(long groupId, int status) {
5609                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5610    
5611                    Object[] finderArgs = new Object[] { groupId, status };
5612    
5613                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5614                                    this);
5615    
5616                    if (count == null) {
5617                            StringBundler query = new StringBundler(3);
5618    
5619                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5620    
5621                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5622    
5623                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5624    
5625                            String sql = query.toString();
5626    
5627                            Session session = null;
5628    
5629                            try {
5630                                    session = openSession();
5631    
5632                                    Query q = session.createQuery(sql);
5633    
5634                                    QueryPos qPos = QueryPos.getInstance(q);
5635    
5636                                    qPos.add(groupId);
5637    
5638                                    qPos.add(status);
5639    
5640                                    count = (Long)q.uniqueResult();
5641    
5642                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5643                            }
5644                            catch (Exception e) {
5645                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5646    
5647                                    throw processException(e);
5648                            }
5649                            finally {
5650                                    closeSession(session);
5651                            }
5652                    }
5653    
5654                    return count.intValue();
5655            }
5656    
5657            /**
5658             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5659             *
5660             * @param groupId the group ID
5661             * @param status the status
5662             * @return the number of matching blogs entries that the user has permission to view
5663             */
5664            @Override
5665            public int filterCountByG_NotS(long groupId, int status) {
5666                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5667                            return countByG_NotS(groupId, status);
5668                    }
5669    
5670                    StringBundler query = new StringBundler(3);
5671    
5672                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5673    
5674                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5675    
5676                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5677    
5678                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5679                                    BlogsEntry.class.getName(),
5680                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5681    
5682                    Session session = null;
5683    
5684                    try {
5685                            session = openSession();
5686    
5687                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5688    
5689                            q.addScalar(COUNT_COLUMN_NAME,
5690                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5691    
5692                            QueryPos qPos = QueryPos.getInstance(q);
5693    
5694                            qPos.add(groupId);
5695    
5696                            qPos.add(status);
5697    
5698                            Long count = (Long)q.uniqueResult();
5699    
5700                            return count.intValue();
5701                    }
5702                    catch (Exception e) {
5703                            throw processException(e);
5704                    }
5705                    finally {
5706                            closeSession(session);
5707                    }
5708            }
5709    
5710            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5711            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5712            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5713                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5714                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5715                            new String[] {
5716                                    Long.class.getName(), Long.class.getName(),
5717                                    
5718                            Integer.class.getName(), Integer.class.getName(),
5719                                    OrderByComparator.class.getName()
5720                            });
5721            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5722                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5723                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5724                            new String[] { Long.class.getName(), Long.class.getName() },
5725                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5726                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5727                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5728                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5729            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5730                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5731                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5732                            new String[] { Long.class.getName(), Long.class.getName() });
5733    
5734            /**
5735             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5736             *
5737             * @param companyId the company ID
5738             * @param userId the user ID
5739             * @return the matching blogs entries
5740             */
5741            @Override
5742            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5743                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5744                            QueryUtil.ALL_POS, null);
5745            }
5746    
5747            /**
5748             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5749             *
5750             * <p>
5751             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5752             * </p>
5753             *
5754             * @param companyId the company ID
5755             * @param userId the user ID
5756             * @param start the lower bound of the range of blogs entries
5757             * @param end the upper bound of the range of blogs entries (not inclusive)
5758             * @return the range of matching blogs entries
5759             */
5760            @Override
5761            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5762                    int end) {
5763                    return findByC_U(companyId, userId, start, end, null);
5764            }
5765    
5766            /**
5767             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5768             *
5769             * <p>
5770             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
5771             * </p>
5772             *
5773             * @param companyId the company ID
5774             * @param userId the user ID
5775             * @param start the lower bound of the range of blogs entries
5776             * @param end the upper bound of the range of blogs entries (not inclusive)
5777             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5778             * @return the ordered range of matching blogs entries
5779             */
5780            @Override
5781            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5782                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5783                    boolean pagination = true;
5784                    FinderPath finderPath = null;
5785                    Object[] finderArgs = null;
5786    
5787                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5788                                    (orderByComparator == null)) {
5789                            pagination = false;
5790                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
5791                            finderArgs = new Object[] { companyId, userId };
5792                    }
5793                    else {
5794                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
5795                            finderArgs = new Object[] {
5796                                            companyId, userId,
5797                                            
5798                                            start, end, orderByComparator
5799                                    };
5800                    }
5801    
5802                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5803                                    finderArgs, this);
5804    
5805                    if ((list != null) && !list.isEmpty()) {
5806                            for (BlogsEntry blogsEntry : list) {
5807                                    if ((companyId != blogsEntry.getCompanyId()) ||
5808                                                    (userId != blogsEntry.getUserId())) {
5809                                            list = null;
5810    
5811                                            break;
5812                                    }
5813                            }
5814                    }
5815    
5816                    if (list == null) {
5817                            StringBundler query = null;
5818    
5819                            if (orderByComparator != null) {
5820                                    query = new StringBundler(4 +
5821                                                    (orderByComparator.getOrderByFields().length * 3));
5822                            }
5823                            else {
5824                                    query = new StringBundler(4);
5825                            }
5826    
5827                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5828    
5829                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
5830    
5831                            query.append(_FINDER_COLUMN_C_U_USERID_2);
5832    
5833                            if (orderByComparator != null) {
5834                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5835                                            orderByComparator);
5836                            }
5837                            else
5838                             if (pagination) {
5839                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5840                            }
5841    
5842                            String sql = query.toString();
5843    
5844                            Session session = null;
5845    
5846                            try {
5847                                    session = openSession();
5848    
5849                                    Query q = session.createQuery(sql);
5850    
5851                                    QueryPos qPos = QueryPos.getInstance(q);
5852    
5853                                    qPos.add(companyId);
5854    
5855                                    qPos.add(userId);
5856    
5857                                    if (!pagination) {
5858                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5859                                                            start, end, false);
5860    
5861                                            Collections.sort(list);
5862    
5863                                            list = Collections.unmodifiableList(list);
5864                                    }
5865                                    else {
5866                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5867                                                            start, end);
5868                                    }
5869    
5870                                    cacheResult(list);
5871    
5872                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5873                            }
5874                            catch (Exception e) {
5875                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5876    
5877                                    throw processException(e);
5878                            }
5879                            finally {
5880                                    closeSession(session);
5881                            }
5882                    }
5883    
5884                    return list;
5885            }
5886    
5887            /**
5888             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5889             *
5890             * @param companyId the company ID
5891             * @param userId the user ID
5892             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5893             * @return the first matching blogs entry
5894             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5895             */
5896            @Override
5897            public BlogsEntry findByC_U_First(long companyId, long userId,
5898                    OrderByComparator<BlogsEntry> orderByComparator)
5899                    throws NoSuchEntryException {
5900                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
5901                                    orderByComparator);
5902    
5903                    if (blogsEntry != null) {
5904                            return blogsEntry;
5905                    }
5906    
5907                    StringBundler msg = new StringBundler(6);
5908    
5909                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5910    
5911                    msg.append("companyId=");
5912                    msg.append(companyId);
5913    
5914                    msg.append(", userId=");
5915                    msg.append(userId);
5916    
5917                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5918    
5919                    throw new NoSuchEntryException(msg.toString());
5920            }
5921    
5922            /**
5923             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5924             *
5925             * @param companyId the company ID
5926             * @param userId the user ID
5927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5928             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5929             */
5930            @Override
5931            public BlogsEntry fetchByC_U_First(long companyId, long userId,
5932                    OrderByComparator<BlogsEntry> orderByComparator) {
5933                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
5934                                    orderByComparator);
5935    
5936                    if (!list.isEmpty()) {
5937                            return list.get(0);
5938                    }
5939    
5940                    return null;
5941            }
5942    
5943            /**
5944             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5945             *
5946             * @param companyId the company ID
5947             * @param userId the user ID
5948             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5949             * @return the last matching blogs entry
5950             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
5951             */
5952            @Override
5953            public BlogsEntry findByC_U_Last(long companyId, long userId,
5954                    OrderByComparator<BlogsEntry> orderByComparator)
5955                    throws NoSuchEntryException {
5956                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
5957                                    orderByComparator);
5958    
5959                    if (blogsEntry != null) {
5960                            return blogsEntry;
5961                    }
5962    
5963                    StringBundler msg = new StringBundler(6);
5964    
5965                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5966    
5967                    msg.append("companyId=");
5968                    msg.append(companyId);
5969    
5970                    msg.append(", userId=");
5971                    msg.append(userId);
5972    
5973                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5974    
5975                    throw new NoSuchEntryException(msg.toString());
5976            }
5977    
5978            /**
5979             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5980             *
5981             * @param companyId the company ID
5982             * @param userId the user ID
5983             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5984             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5985             */
5986            @Override
5987            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
5988                    OrderByComparator<BlogsEntry> orderByComparator) {
5989                    int count = countByC_U(companyId, userId);
5990    
5991                    if (count == 0) {
5992                            return null;
5993                    }
5994    
5995                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
5996                                    orderByComparator);
5997    
5998                    if (!list.isEmpty()) {
5999                            return list.get(0);
6000                    }
6001    
6002                    return null;
6003            }
6004    
6005            /**
6006             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6007             *
6008             * @param entryId the primary key of the current blogs entry
6009             * @param companyId the company ID
6010             * @param userId the user ID
6011             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6012             * @return the previous, current, and next blogs entry
6013             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6014             */
6015            @Override
6016            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6017                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6018                    throws NoSuchEntryException {
6019                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6020    
6021                    Session session = null;
6022    
6023                    try {
6024                            session = openSession();
6025    
6026                            BlogsEntry[] array = new BlogsEntryImpl[3];
6027    
6028                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6029                                            userId, orderByComparator, true);
6030    
6031                            array[1] = blogsEntry;
6032    
6033                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6034                                            userId, orderByComparator, false);
6035    
6036                            return array;
6037                    }
6038                    catch (Exception e) {
6039                            throw processException(e);
6040                    }
6041                    finally {
6042                            closeSession(session);
6043                    }
6044            }
6045    
6046            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6047                    BlogsEntry blogsEntry, long companyId, long userId,
6048                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6049                    StringBundler query = null;
6050    
6051                    if (orderByComparator != null) {
6052                            query = new StringBundler(6 +
6053                                            (orderByComparator.getOrderByFields().length * 6));
6054                    }
6055                    else {
6056                            query = new StringBundler(3);
6057                    }
6058    
6059                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6060    
6061                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6062    
6063                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6064    
6065                    if (orderByComparator != null) {
6066                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6067    
6068                            if (orderByConditionFields.length > 0) {
6069                                    query.append(WHERE_AND);
6070                            }
6071    
6072                            for (int i = 0; i < orderByConditionFields.length; i++) {
6073                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6074                                    query.append(orderByConditionFields[i]);
6075    
6076                                    if ((i + 1) < orderByConditionFields.length) {
6077                                            if (orderByComparator.isAscending() ^ previous) {
6078                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6079                                            }
6080                                            else {
6081                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6082                                            }
6083                                    }
6084                                    else {
6085                                            if (orderByComparator.isAscending() ^ previous) {
6086                                                    query.append(WHERE_GREATER_THAN);
6087                                            }
6088                                            else {
6089                                                    query.append(WHERE_LESSER_THAN);
6090                                            }
6091                                    }
6092                            }
6093    
6094                            query.append(ORDER_BY_CLAUSE);
6095    
6096                            String[] orderByFields = orderByComparator.getOrderByFields();
6097    
6098                            for (int i = 0; i < orderByFields.length; i++) {
6099                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6100                                    query.append(orderByFields[i]);
6101    
6102                                    if ((i + 1) < orderByFields.length) {
6103                                            if (orderByComparator.isAscending() ^ previous) {
6104                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6105                                            }
6106                                            else {
6107                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6108                                            }
6109                                    }
6110                                    else {
6111                                            if (orderByComparator.isAscending() ^ previous) {
6112                                                    query.append(ORDER_BY_ASC);
6113                                            }
6114                                            else {
6115                                                    query.append(ORDER_BY_DESC);
6116                                            }
6117                                    }
6118                            }
6119                    }
6120                    else {
6121                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6122                    }
6123    
6124                    String sql = query.toString();
6125    
6126                    Query q = session.createQuery(sql);
6127    
6128                    q.setFirstResult(0);
6129                    q.setMaxResults(2);
6130    
6131                    QueryPos qPos = QueryPos.getInstance(q);
6132    
6133                    qPos.add(companyId);
6134    
6135                    qPos.add(userId);
6136    
6137                    if (orderByComparator != null) {
6138                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6139    
6140                            for (Object value : values) {
6141                                    qPos.add(value);
6142                            }
6143                    }
6144    
6145                    List<BlogsEntry> list = q.list();
6146    
6147                    if (list.size() == 2) {
6148                            return list.get(1);
6149                    }
6150                    else {
6151                            return null;
6152                    }
6153            }
6154    
6155            /**
6156             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6157             *
6158             * @param companyId the company ID
6159             * @param userId the user ID
6160             */
6161            @Override
6162            public void removeByC_U(long companyId, long userId) {
6163                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6164                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6165                            remove(blogsEntry);
6166                    }
6167            }
6168    
6169            /**
6170             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6171             *
6172             * @param companyId the company ID
6173             * @param userId the user ID
6174             * @return the number of matching blogs entries
6175             */
6176            @Override
6177            public int countByC_U(long companyId, long userId) {
6178                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6179    
6180                    Object[] finderArgs = new Object[] { companyId, userId };
6181    
6182                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6183                                    this);
6184    
6185                    if (count == null) {
6186                            StringBundler query = new StringBundler(3);
6187    
6188                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6189    
6190                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6191    
6192                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6193    
6194                            String sql = query.toString();
6195    
6196                            Session session = null;
6197    
6198                            try {
6199                                    session = openSession();
6200    
6201                                    Query q = session.createQuery(sql);
6202    
6203                                    QueryPos qPos = QueryPos.getInstance(q);
6204    
6205                                    qPos.add(companyId);
6206    
6207                                    qPos.add(userId);
6208    
6209                                    count = (Long)q.uniqueResult();
6210    
6211                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6212                            }
6213                            catch (Exception e) {
6214                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6215    
6216                                    throw processException(e);
6217                            }
6218                            finally {
6219                                    closeSession(session);
6220                            }
6221                    }
6222    
6223                    return count.intValue();
6224            }
6225    
6226            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6227            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6228            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6229                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6230                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6231                            new String[] {
6232                                    Long.class.getName(), Date.class.getName(),
6233                                    
6234                            Integer.class.getName(), Integer.class.getName(),
6235                                    OrderByComparator.class.getName()
6236                            });
6237            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6238                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6239                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6240                            new String[] { Long.class.getName(), Date.class.getName() });
6241    
6242            /**
6243             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6244             *
6245             * @param companyId the company ID
6246             * @param displayDate the display date
6247             * @return the matching blogs entries
6248             */
6249            @Override
6250            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6251                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6252                            QueryUtil.ALL_POS, null);
6253            }
6254    
6255            /**
6256             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6257             *
6258             * <p>
6259             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
6260             * </p>
6261             *
6262             * @param companyId the company ID
6263             * @param displayDate the display date
6264             * @param start the lower bound of the range of blogs entries
6265             * @param end the upper bound of the range of blogs entries (not inclusive)
6266             * @return the range of matching blogs entries
6267             */
6268            @Override
6269            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6270                    int start, int end) {
6271                    return findByC_LtD(companyId, displayDate, start, end, null);
6272            }
6273    
6274            /**
6275             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6276             *
6277             * <p>
6278             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
6279             * </p>
6280             *
6281             * @param companyId the company ID
6282             * @param displayDate the display date
6283             * @param start the lower bound of the range of blogs entries
6284             * @param end the upper bound of the range of blogs entries (not inclusive)
6285             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6286             * @return the ordered range of matching blogs entries
6287             */
6288            @Override
6289            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6290                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6291                    boolean pagination = true;
6292                    FinderPath finderPath = null;
6293                    Object[] finderArgs = null;
6294    
6295                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6296                    finderArgs = new Object[] {
6297                                    companyId, displayDate,
6298                                    
6299                                    start, end, orderByComparator
6300                            };
6301    
6302                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6303                                    finderArgs, this);
6304    
6305                    if ((list != null) && !list.isEmpty()) {
6306                            for (BlogsEntry blogsEntry : list) {
6307                                    if ((companyId != blogsEntry.getCompanyId()) ||
6308                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
6309                                                                                                                                    .getTime())) {
6310                                            list = null;
6311    
6312                                            break;
6313                                    }
6314                            }
6315                    }
6316    
6317                    if (list == null) {
6318                            StringBundler query = null;
6319    
6320                            if (orderByComparator != null) {
6321                                    query = new StringBundler(4 +
6322                                                    (orderByComparator.getOrderByFields().length * 3));
6323                            }
6324                            else {
6325                                    query = new StringBundler(4);
6326                            }
6327    
6328                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6329    
6330                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6331    
6332                            boolean bindDisplayDate = false;
6333    
6334                            if (displayDate == null) {
6335                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6336                            }
6337                            else {
6338                                    bindDisplayDate = true;
6339    
6340                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6341                            }
6342    
6343                            if (orderByComparator != null) {
6344                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6345                                            orderByComparator);
6346                            }
6347                            else
6348                             if (pagination) {
6349                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6350                            }
6351    
6352                            String sql = query.toString();
6353    
6354                            Session session = null;
6355    
6356                            try {
6357                                    session = openSession();
6358    
6359                                    Query q = session.createQuery(sql);
6360    
6361                                    QueryPos qPos = QueryPos.getInstance(q);
6362    
6363                                    qPos.add(companyId);
6364    
6365                                    if (bindDisplayDate) {
6366                                            qPos.add(new Timestamp(displayDate.getTime()));
6367                                    }
6368    
6369                                    if (!pagination) {
6370                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6371                                                            start, end, false);
6372    
6373                                            Collections.sort(list);
6374    
6375                                            list = Collections.unmodifiableList(list);
6376                                    }
6377                                    else {
6378                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6379                                                            start, end);
6380                                    }
6381    
6382                                    cacheResult(list);
6383    
6384                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6385                            }
6386                            catch (Exception e) {
6387                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6388    
6389                                    throw processException(e);
6390                            }
6391                            finally {
6392                                    closeSession(session);
6393                            }
6394                    }
6395    
6396                    return list;
6397            }
6398    
6399            /**
6400             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6401             *
6402             * @param companyId the company ID
6403             * @param displayDate the display date
6404             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6405             * @return the first matching blogs entry
6406             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6407             */
6408            @Override
6409            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6410                    OrderByComparator<BlogsEntry> orderByComparator)
6411                    throws NoSuchEntryException {
6412                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6413                                    orderByComparator);
6414    
6415                    if (blogsEntry != null) {
6416                            return blogsEntry;
6417                    }
6418    
6419                    StringBundler msg = new StringBundler(6);
6420    
6421                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6422    
6423                    msg.append("companyId=");
6424                    msg.append(companyId);
6425    
6426                    msg.append(", displayDate=");
6427                    msg.append(displayDate);
6428    
6429                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6430    
6431                    throw new NoSuchEntryException(msg.toString());
6432            }
6433    
6434            /**
6435             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6436             *
6437             * @param companyId the company ID
6438             * @param displayDate the display date
6439             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6440             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6441             */
6442            @Override
6443            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6444                    OrderByComparator<BlogsEntry> orderByComparator) {
6445                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6446                                    orderByComparator);
6447    
6448                    if (!list.isEmpty()) {
6449                            return list.get(0);
6450                    }
6451    
6452                    return null;
6453            }
6454    
6455            /**
6456             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6457             *
6458             * @param companyId the company ID
6459             * @param displayDate the display date
6460             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6461             * @return the last matching blogs entry
6462             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6463             */
6464            @Override
6465            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6466                    OrderByComparator<BlogsEntry> orderByComparator)
6467                    throws NoSuchEntryException {
6468                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6469                                    orderByComparator);
6470    
6471                    if (blogsEntry != null) {
6472                            return blogsEntry;
6473                    }
6474    
6475                    StringBundler msg = new StringBundler(6);
6476    
6477                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6478    
6479                    msg.append("companyId=");
6480                    msg.append(companyId);
6481    
6482                    msg.append(", displayDate=");
6483                    msg.append(displayDate);
6484    
6485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6486    
6487                    throw new NoSuchEntryException(msg.toString());
6488            }
6489    
6490            /**
6491             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6492             *
6493             * @param companyId the company ID
6494             * @param displayDate the display date
6495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6496             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6497             */
6498            @Override
6499            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6500                    OrderByComparator<BlogsEntry> orderByComparator) {
6501                    int count = countByC_LtD(companyId, displayDate);
6502    
6503                    if (count == 0) {
6504                            return null;
6505                    }
6506    
6507                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6508                                    count, orderByComparator);
6509    
6510                    if (!list.isEmpty()) {
6511                            return list.get(0);
6512                    }
6513    
6514                    return null;
6515            }
6516    
6517            /**
6518             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6519             *
6520             * @param entryId the primary key of the current blogs entry
6521             * @param companyId the company ID
6522             * @param displayDate the display date
6523             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6524             * @return the previous, current, and next blogs entry
6525             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
6526             */
6527            @Override
6528            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6529                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6530                    throws NoSuchEntryException {
6531                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6532    
6533                    Session session = null;
6534    
6535                    try {
6536                            session = openSession();
6537    
6538                            BlogsEntry[] array = new BlogsEntryImpl[3];
6539    
6540                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6541                                            displayDate, orderByComparator, true);
6542    
6543                            array[1] = blogsEntry;
6544    
6545                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6546                                            displayDate, orderByComparator, false);
6547    
6548                            return array;
6549                    }
6550                    catch (Exception e) {
6551                            throw processException(e);
6552                    }
6553                    finally {
6554                            closeSession(session);
6555                    }
6556            }
6557    
6558            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6559                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6560                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6561                    StringBundler query = null;
6562    
6563                    if (orderByComparator != null) {
6564                            query = new StringBundler(6 +
6565                                            (orderByComparator.getOrderByFields().length * 6));
6566                    }
6567                    else {
6568                            query = new StringBundler(3);
6569                    }
6570    
6571                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6572    
6573                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6574    
6575                    boolean bindDisplayDate = false;
6576    
6577                    if (displayDate == null) {
6578                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6579                    }
6580                    else {
6581                            bindDisplayDate = true;
6582    
6583                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6584                    }
6585    
6586                    if (orderByComparator != null) {
6587                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6588    
6589                            if (orderByConditionFields.length > 0) {
6590                                    query.append(WHERE_AND);
6591                            }
6592    
6593                            for (int i = 0; i < orderByConditionFields.length; i++) {
6594                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6595                                    query.append(orderByConditionFields[i]);
6596    
6597                                    if ((i + 1) < orderByConditionFields.length) {
6598                                            if (orderByComparator.isAscending() ^ previous) {
6599                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6600                                            }
6601                                            else {
6602                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6603                                            }
6604                                    }
6605                                    else {
6606                                            if (orderByComparator.isAscending() ^ previous) {
6607                                                    query.append(WHERE_GREATER_THAN);
6608                                            }
6609                                            else {
6610                                                    query.append(WHERE_LESSER_THAN);
6611                                            }
6612                                    }
6613                            }
6614    
6615                            query.append(ORDER_BY_CLAUSE);
6616    
6617                            String[] orderByFields = orderByComparator.getOrderByFields();
6618    
6619                            for (int i = 0; i < orderByFields.length; i++) {
6620                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6621                                    query.append(orderByFields[i]);
6622    
6623                                    if ((i + 1) < orderByFields.length) {
6624                                            if (orderByComparator.isAscending() ^ previous) {
6625                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6626                                            }
6627                                            else {
6628                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6629                                            }
6630                                    }
6631                                    else {
6632                                            if (orderByComparator.isAscending() ^ previous) {
6633                                                    query.append(ORDER_BY_ASC);
6634                                            }
6635                                            else {
6636                                                    query.append(ORDER_BY_DESC);
6637                                            }
6638                                    }
6639                            }
6640                    }
6641                    else {
6642                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6643                    }
6644    
6645                    String sql = query.toString();
6646    
6647                    Query q = session.createQuery(sql);
6648    
6649                    q.setFirstResult(0);
6650                    q.setMaxResults(2);
6651    
6652                    QueryPos qPos = QueryPos.getInstance(q);
6653    
6654                    qPos.add(companyId);
6655    
6656                    if (bindDisplayDate) {
6657                            qPos.add(new Timestamp(displayDate.getTime()));
6658                    }
6659    
6660                    if (orderByComparator != null) {
6661                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6662    
6663                            for (Object value : values) {
6664                                    qPos.add(value);
6665                            }
6666                    }
6667    
6668                    List<BlogsEntry> list = q.list();
6669    
6670                    if (list.size() == 2) {
6671                            return list.get(1);
6672                    }
6673                    else {
6674                            return null;
6675                    }
6676            }
6677    
6678            /**
6679             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6680             *
6681             * @param companyId the company ID
6682             * @param displayDate the display date
6683             */
6684            @Override
6685            public void removeByC_LtD(long companyId, Date displayDate) {
6686                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6687                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6688                            remove(blogsEntry);
6689                    }
6690            }
6691    
6692            /**
6693             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6694             *
6695             * @param companyId the company ID
6696             * @param displayDate the display date
6697             * @return the number of matching blogs entries
6698             */
6699            @Override
6700            public int countByC_LtD(long companyId, Date displayDate) {
6701                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6702    
6703                    Object[] finderArgs = new Object[] { companyId, displayDate };
6704    
6705                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6706                                    this);
6707    
6708                    if (count == null) {
6709                            StringBundler query = new StringBundler(3);
6710    
6711                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6712    
6713                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6714    
6715                            boolean bindDisplayDate = false;
6716    
6717                            if (displayDate == null) {
6718                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6719                            }
6720                            else {
6721                                    bindDisplayDate = true;
6722    
6723                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6724                            }
6725    
6726                            String sql = query.toString();
6727    
6728                            Session session = null;
6729    
6730                            try {
6731                                    session = openSession();
6732    
6733                                    Query q = session.createQuery(sql);
6734    
6735                                    QueryPos qPos = QueryPos.getInstance(q);
6736    
6737                                    qPos.add(companyId);
6738    
6739                                    if (bindDisplayDate) {
6740                                            qPos.add(new Timestamp(displayDate.getTime()));
6741                                    }
6742    
6743                                    count = (Long)q.uniqueResult();
6744    
6745                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6746                            }
6747                            catch (Exception e) {
6748                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6749    
6750                                    throw processException(e);
6751                            }
6752                            finally {
6753                                    closeSession(session);
6754                            }
6755                    }
6756    
6757                    return count.intValue();
6758            }
6759    
6760            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6761            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
6762            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
6763            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6764                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6765                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
6766                            new String[] {
6767                                    Long.class.getName(), Integer.class.getName(),
6768                                    
6769                            Integer.class.getName(), Integer.class.getName(),
6770                                    OrderByComparator.class.getName()
6771                            });
6772            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6773                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6774                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
6775                            new String[] { Long.class.getName(), Integer.class.getName() },
6776                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
6777                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
6778                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
6779                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
6780            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6781                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6782                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
6783                            new String[] { Long.class.getName(), Integer.class.getName() });
6784    
6785            /**
6786             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
6787             *
6788             * @param companyId the company ID
6789             * @param status the status
6790             * @return the matching blogs entries
6791             */
6792            @Override
6793            public List<BlogsEntry> findByC_S(long companyId, int status) {
6794                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
6795                            QueryUtil.ALL_POS, null);
6796            }
6797    
6798            /**
6799             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
6800             *
6801             * <p>
6802             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
6803             * </p>
6804             *
6805             * @param companyId the company ID
6806             * @param status the status
6807             * @param start the lower bound of the range of blogs entries
6808             * @param end the upper bound of the range of blogs entries (not inclusive)
6809             * @return the range of matching blogs entries
6810             */
6811            @Override
6812            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
6813                    int end) {
6814                    return findByC_S(companyId, status, start, end, null);
6815            }
6816    
6817            /**
6818             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
6819             *
6820             * <p>
6821             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
6822             * </p>
6823             *
6824             * @param companyId the company ID
6825             * @param status the status
6826             * @param start the lower bound of the range of blogs entries
6827             * @param end the upper bound of the range of blogs entries (not inclusive)
6828             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6829             * @return the ordered range of matching blogs entries
6830             */
6831            @Override
6832            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
6833                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
6834                    boolean pagination = true;
6835                    FinderPath finderPath = null;
6836                    Object[] finderArgs = null;
6837    
6838                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6839                                    (orderByComparator == null)) {
6840                            pagination = false;
6841                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
6842                            finderArgs = new Object[] { companyId, status };
6843                    }
6844                    else {
6845                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
6846                            finderArgs = new Object[] {
6847                                            companyId, status,
6848                                            
6849                                            start, end, orderByComparator
6850                                    };
6851                    }
6852    
6853                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6854                                    finderArgs, this);
6855    
6856                    if ((list != null) && !list.isEmpty()) {
6857                            for (BlogsEntry blogsEntry : list) {
6858                                    if ((companyId != blogsEntry.getCompanyId()) ||
6859                                                    (status != blogsEntry.getStatus())) {
6860                                            list = null;
6861    
6862                                            break;
6863                                    }
6864                            }
6865                    }
6866    
6867                    if (list == null) {
6868                            StringBundler query = null;
6869    
6870                            if (orderByComparator != null) {
6871                                    query = new StringBundler(4 +
6872                                                    (orderByComparator.getOrderByFields().length * 3));
6873                            }
6874                            else {
6875                                    query = new StringBundler(4);
6876                            }
6877    
6878                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6879    
6880                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
6881    
6882                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
6883    
6884                            if (orderByComparator != null) {
6885                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6886                                            orderByComparator);
6887                            }
6888                            else
6889                             if (pagination) {
6890                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6891                            }
6892    
6893                            String sql = query.toString();
6894    
6895                            Session session = null;
6896    
6897                            try {
6898                                    session = openSession();
6899    
6900                                    Query q = session.createQuery(sql);
6901    
6902                                    QueryPos qPos = QueryPos.getInstance(q);
6903    
6904                                    qPos.add(companyId);
6905    
6906                                    qPos.add(status);
6907    
6908                                    if (!pagination) {
6909                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6910                                                            start, end, false);
6911    
6912                                            Collections.sort(list);
6913    
6914                                            list = Collections.unmodifiableList(list);
6915                                    }
6916                                    else {
6917                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6918                                                            start, end);
6919                                    }
6920    
6921                                    cacheResult(list);
6922    
6923                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6924                            }
6925                            catch (Exception e) {
6926                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6927    
6928                                    throw processException(e);
6929                            }
6930                            finally {
6931                                    closeSession(session);
6932                            }
6933                    }
6934    
6935                    return list;
6936            }
6937    
6938            /**
6939             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
6940             *
6941             * @param companyId the company ID
6942             * @param status the status
6943             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6944             * @return the first matching blogs entry
6945             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
6946             */
6947            @Override
6948            public BlogsEntry findByC_S_First(long companyId, int status,
6949                    OrderByComparator<BlogsEntry> orderByComparator)
6950                    throws NoSuchEntryException {
6951                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
6952                                    orderByComparator);
6953    
6954                    if (blogsEntry != null) {
6955                            return blogsEntry;
6956                    }
6957    
6958                    StringBundler msg = new StringBundler(6);
6959    
6960                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6961    
6962                    msg.append("companyId=");
6963                    msg.append(companyId);
6964    
6965                    msg.append(", status=");
6966                    msg.append(status);
6967    
6968                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6969    
6970                    throw new NoSuchEntryException(msg.toString());
6971            }
6972    
6973            /**
6974             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
6975             *
6976             * @param companyId the company ID
6977             * @param status the status
6978             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6979             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6980             */
6981            @Override
6982            public BlogsEntry fetchByC_S_First(long companyId, int status,
6983                    OrderByComparator<BlogsEntry> orderByComparator) {
6984                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
6985                                    orderByComparator);
6986    
6987                    if (!list.isEmpty()) {
6988                            return list.get(0);
6989                    }
6990    
6991                    return null;
6992            }
6993    
6994            /**
6995             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
6996             *
6997             * @param companyId the company ID
6998             * @param status the status
6999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7000             * @return the last matching blogs entry
7001             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7002             */
7003            @Override
7004            public BlogsEntry findByC_S_Last(long companyId, int status,
7005                    OrderByComparator<BlogsEntry> orderByComparator)
7006                    throws NoSuchEntryException {
7007                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7008                                    orderByComparator);
7009    
7010                    if (blogsEntry != null) {
7011                            return blogsEntry;
7012                    }
7013    
7014                    StringBundler msg = new StringBundler(6);
7015    
7016                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7017    
7018                    msg.append("companyId=");
7019                    msg.append(companyId);
7020    
7021                    msg.append(", status=");
7022                    msg.append(status);
7023    
7024                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7025    
7026                    throw new NoSuchEntryException(msg.toString());
7027            }
7028    
7029            /**
7030             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7031             *
7032             * @param companyId the company ID
7033             * @param status the status
7034             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7035             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7036             */
7037            @Override
7038            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7039                    OrderByComparator<BlogsEntry> orderByComparator) {
7040                    int count = countByC_S(companyId, status);
7041    
7042                    if (count == 0) {
7043                            return null;
7044                    }
7045    
7046                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7047                                    orderByComparator);
7048    
7049                    if (!list.isEmpty()) {
7050                            return list.get(0);
7051                    }
7052    
7053                    return null;
7054            }
7055    
7056            /**
7057             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7058             *
7059             * @param entryId the primary key of the current blogs entry
7060             * @param companyId the company ID
7061             * @param status the status
7062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7063             * @return the previous, current, and next blogs entry
7064             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7065             */
7066            @Override
7067            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7068                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7069                    throws NoSuchEntryException {
7070                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7071    
7072                    Session session = null;
7073    
7074                    try {
7075                            session = openSession();
7076    
7077                            BlogsEntry[] array = new BlogsEntryImpl[3];
7078    
7079                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7080                                            status, orderByComparator, true);
7081    
7082                            array[1] = blogsEntry;
7083    
7084                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7085                                            status, orderByComparator, false);
7086    
7087                            return array;
7088                    }
7089                    catch (Exception e) {
7090                            throw processException(e);
7091                    }
7092                    finally {
7093                            closeSession(session);
7094                    }
7095            }
7096    
7097            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7098                    BlogsEntry blogsEntry, long companyId, int status,
7099                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7100                    StringBundler query = null;
7101    
7102                    if (orderByComparator != null) {
7103                            query = new StringBundler(6 +
7104                                            (orderByComparator.getOrderByFields().length * 6));
7105                    }
7106                    else {
7107                            query = new StringBundler(3);
7108                    }
7109    
7110                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7111    
7112                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7113    
7114                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7115    
7116                    if (orderByComparator != null) {
7117                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7118    
7119                            if (orderByConditionFields.length > 0) {
7120                                    query.append(WHERE_AND);
7121                            }
7122    
7123                            for (int i = 0; i < orderByConditionFields.length; i++) {
7124                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7125                                    query.append(orderByConditionFields[i]);
7126    
7127                                    if ((i + 1) < orderByConditionFields.length) {
7128                                            if (orderByComparator.isAscending() ^ previous) {
7129                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7130                                            }
7131                                            else {
7132                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7133                                            }
7134                                    }
7135                                    else {
7136                                            if (orderByComparator.isAscending() ^ previous) {
7137                                                    query.append(WHERE_GREATER_THAN);
7138                                            }
7139                                            else {
7140                                                    query.append(WHERE_LESSER_THAN);
7141                                            }
7142                                    }
7143                            }
7144    
7145                            query.append(ORDER_BY_CLAUSE);
7146    
7147                            String[] orderByFields = orderByComparator.getOrderByFields();
7148    
7149                            for (int i = 0; i < orderByFields.length; i++) {
7150                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7151                                    query.append(orderByFields[i]);
7152    
7153                                    if ((i + 1) < orderByFields.length) {
7154                                            if (orderByComparator.isAscending() ^ previous) {
7155                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7156                                            }
7157                                            else {
7158                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7159                                            }
7160                                    }
7161                                    else {
7162                                            if (orderByComparator.isAscending() ^ previous) {
7163                                                    query.append(ORDER_BY_ASC);
7164                                            }
7165                                            else {
7166                                                    query.append(ORDER_BY_DESC);
7167                                            }
7168                                    }
7169                            }
7170                    }
7171                    else {
7172                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7173                    }
7174    
7175                    String sql = query.toString();
7176    
7177                    Query q = session.createQuery(sql);
7178    
7179                    q.setFirstResult(0);
7180                    q.setMaxResults(2);
7181    
7182                    QueryPos qPos = QueryPos.getInstance(q);
7183    
7184                    qPos.add(companyId);
7185    
7186                    qPos.add(status);
7187    
7188                    if (orderByComparator != null) {
7189                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7190    
7191                            for (Object value : values) {
7192                                    qPos.add(value);
7193                            }
7194                    }
7195    
7196                    List<BlogsEntry> list = q.list();
7197    
7198                    if (list.size() == 2) {
7199                            return list.get(1);
7200                    }
7201                    else {
7202                            return null;
7203                    }
7204            }
7205    
7206            /**
7207             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7208             *
7209             * @param companyId the company ID
7210             * @param status the status
7211             */
7212            @Override
7213            public void removeByC_S(long companyId, int status) {
7214                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7215                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7216                            remove(blogsEntry);
7217                    }
7218            }
7219    
7220            /**
7221             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7222             *
7223             * @param companyId the company ID
7224             * @param status the status
7225             * @return the number of matching blogs entries
7226             */
7227            @Override
7228            public int countByC_S(long companyId, int status) {
7229                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7230    
7231                    Object[] finderArgs = new Object[] { companyId, status };
7232    
7233                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7234                                    this);
7235    
7236                    if (count == null) {
7237                            StringBundler query = new StringBundler(3);
7238    
7239                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7240    
7241                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7242    
7243                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7244    
7245                            String sql = query.toString();
7246    
7247                            Session session = null;
7248    
7249                            try {
7250                                    session = openSession();
7251    
7252                                    Query q = session.createQuery(sql);
7253    
7254                                    QueryPos qPos = QueryPos.getInstance(q);
7255    
7256                                    qPos.add(companyId);
7257    
7258                                    qPos.add(status);
7259    
7260                                    count = (Long)q.uniqueResult();
7261    
7262                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7263                            }
7264                            catch (Exception e) {
7265                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7266    
7267                                    throw processException(e);
7268                            }
7269                            finally {
7270                                    closeSession(session);
7271                            }
7272                    }
7273    
7274                    return count.intValue();
7275            }
7276    
7277            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7278            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7279            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7280                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7281                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7282                            new String[] {
7283                                    Long.class.getName(), Integer.class.getName(),
7284                                    
7285                            Integer.class.getName(), Integer.class.getName(),
7286                                    OrderByComparator.class.getName()
7287                            });
7288            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7289                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7290                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7291                            new String[] { Long.class.getName(), Integer.class.getName() });
7292    
7293            /**
7294             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7295             *
7296             * @param companyId the company ID
7297             * @param status the status
7298             * @return the matching blogs entries
7299             */
7300            @Override
7301            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7302                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7303                            QueryUtil.ALL_POS, null);
7304            }
7305    
7306            /**
7307             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7308             *
7309             * <p>
7310             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7311             * </p>
7312             *
7313             * @param companyId the company ID
7314             * @param status the status
7315             * @param start the lower bound of the range of blogs entries
7316             * @param end the upper bound of the range of blogs entries (not inclusive)
7317             * @return the range of matching blogs entries
7318             */
7319            @Override
7320            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7321                    int end) {
7322                    return findByC_NotS(companyId, status, start, end, null);
7323            }
7324    
7325            /**
7326             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7327             *
7328             * <p>
7329             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7330             * </p>
7331             *
7332             * @param companyId the company ID
7333             * @param status the status
7334             * @param start the lower bound of the range of blogs entries
7335             * @param end the upper bound of the range of blogs entries (not inclusive)
7336             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7337             * @return the ordered range of matching blogs entries
7338             */
7339            @Override
7340            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7341                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7342                    boolean pagination = true;
7343                    FinderPath finderPath = null;
7344                    Object[] finderArgs = null;
7345    
7346                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7347                    finderArgs = new Object[] {
7348                                    companyId, status,
7349                                    
7350                                    start, end, orderByComparator
7351                            };
7352    
7353                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7354                                    finderArgs, this);
7355    
7356                    if ((list != null) && !list.isEmpty()) {
7357                            for (BlogsEntry blogsEntry : list) {
7358                                    if ((companyId != blogsEntry.getCompanyId()) ||
7359                                                    (status == blogsEntry.getStatus())) {
7360                                            list = null;
7361    
7362                                            break;
7363                                    }
7364                            }
7365                    }
7366    
7367                    if (list == null) {
7368                            StringBundler query = null;
7369    
7370                            if (orderByComparator != null) {
7371                                    query = new StringBundler(4 +
7372                                                    (orderByComparator.getOrderByFields().length * 3));
7373                            }
7374                            else {
7375                                    query = new StringBundler(4);
7376                            }
7377    
7378                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7379    
7380                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7381    
7382                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7383    
7384                            if (orderByComparator != null) {
7385                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7386                                            orderByComparator);
7387                            }
7388                            else
7389                             if (pagination) {
7390                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7391                            }
7392    
7393                            String sql = query.toString();
7394    
7395                            Session session = null;
7396    
7397                            try {
7398                                    session = openSession();
7399    
7400                                    Query q = session.createQuery(sql);
7401    
7402                                    QueryPos qPos = QueryPos.getInstance(q);
7403    
7404                                    qPos.add(companyId);
7405    
7406                                    qPos.add(status);
7407    
7408                                    if (!pagination) {
7409                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7410                                                            start, end, false);
7411    
7412                                            Collections.sort(list);
7413    
7414                                            list = Collections.unmodifiableList(list);
7415                                    }
7416                                    else {
7417                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7418                                                            start, end);
7419                                    }
7420    
7421                                    cacheResult(list);
7422    
7423                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7424                            }
7425                            catch (Exception e) {
7426                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7427    
7428                                    throw processException(e);
7429                            }
7430                            finally {
7431                                    closeSession(session);
7432                            }
7433                    }
7434    
7435                    return list;
7436            }
7437    
7438            /**
7439             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7440             *
7441             * @param companyId the company ID
7442             * @param status the status
7443             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7444             * @return the first matching blogs entry
7445             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7446             */
7447            @Override
7448            public BlogsEntry findByC_NotS_First(long companyId, int status,
7449                    OrderByComparator<BlogsEntry> orderByComparator)
7450                    throws NoSuchEntryException {
7451                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7452                                    orderByComparator);
7453    
7454                    if (blogsEntry != null) {
7455                            return blogsEntry;
7456                    }
7457    
7458                    StringBundler msg = new StringBundler(6);
7459    
7460                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7461    
7462                    msg.append("companyId=");
7463                    msg.append(companyId);
7464    
7465                    msg.append(", status=");
7466                    msg.append(status);
7467    
7468                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7469    
7470                    throw new NoSuchEntryException(msg.toString());
7471            }
7472    
7473            /**
7474             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7475             *
7476             * @param companyId the company ID
7477             * @param status the status
7478             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7479             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7480             */
7481            @Override
7482            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7483                    OrderByComparator<BlogsEntry> orderByComparator) {
7484                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7485                                    orderByComparator);
7486    
7487                    if (!list.isEmpty()) {
7488                            return list.get(0);
7489                    }
7490    
7491                    return null;
7492            }
7493    
7494            /**
7495             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7496             *
7497             * @param companyId the company ID
7498             * @param status the status
7499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7500             * @return the last matching blogs entry
7501             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7502             */
7503            @Override
7504            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7505                    OrderByComparator<BlogsEntry> orderByComparator)
7506                    throws NoSuchEntryException {
7507                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7508                                    orderByComparator);
7509    
7510                    if (blogsEntry != null) {
7511                            return blogsEntry;
7512                    }
7513    
7514                    StringBundler msg = new StringBundler(6);
7515    
7516                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7517    
7518                    msg.append("companyId=");
7519                    msg.append(companyId);
7520    
7521                    msg.append(", status=");
7522                    msg.append(status);
7523    
7524                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7525    
7526                    throw new NoSuchEntryException(msg.toString());
7527            }
7528    
7529            /**
7530             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7531             *
7532             * @param companyId the company ID
7533             * @param status the status
7534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7535             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7536             */
7537            @Override
7538            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7539                    OrderByComparator<BlogsEntry> orderByComparator) {
7540                    int count = countByC_NotS(companyId, status);
7541    
7542                    if (count == 0) {
7543                            return null;
7544                    }
7545    
7546                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7547                                    count, orderByComparator);
7548    
7549                    if (!list.isEmpty()) {
7550                            return list.get(0);
7551                    }
7552    
7553                    return null;
7554            }
7555    
7556            /**
7557             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7558             *
7559             * @param entryId the primary key of the current blogs entry
7560             * @param companyId the company ID
7561             * @param status the status
7562             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7563             * @return the previous, current, and next blogs entry
7564             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
7565             */
7566            @Override
7567            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7568                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7569                    throws NoSuchEntryException {
7570                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7571    
7572                    Session session = null;
7573    
7574                    try {
7575                            session = openSession();
7576    
7577                            BlogsEntry[] array = new BlogsEntryImpl[3];
7578    
7579                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7580                                            status, orderByComparator, true);
7581    
7582                            array[1] = blogsEntry;
7583    
7584                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7585                                            status, orderByComparator, false);
7586    
7587                            return array;
7588                    }
7589                    catch (Exception e) {
7590                            throw processException(e);
7591                    }
7592                    finally {
7593                            closeSession(session);
7594                    }
7595            }
7596    
7597            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7598                    BlogsEntry blogsEntry, long companyId, int status,
7599                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7600                    StringBundler query = null;
7601    
7602                    if (orderByComparator != null) {
7603                            query = new StringBundler(6 +
7604                                            (orderByComparator.getOrderByFields().length * 6));
7605                    }
7606                    else {
7607                            query = new StringBundler(3);
7608                    }
7609    
7610                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7611    
7612                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7613    
7614                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7615    
7616                    if (orderByComparator != null) {
7617                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7618    
7619                            if (orderByConditionFields.length > 0) {
7620                                    query.append(WHERE_AND);
7621                            }
7622    
7623                            for (int i = 0; i < orderByConditionFields.length; i++) {
7624                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7625                                    query.append(orderByConditionFields[i]);
7626    
7627                                    if ((i + 1) < orderByConditionFields.length) {
7628                                            if (orderByComparator.isAscending() ^ previous) {
7629                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7630                                            }
7631                                            else {
7632                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7633                                            }
7634                                    }
7635                                    else {
7636                                            if (orderByComparator.isAscending() ^ previous) {
7637                                                    query.append(WHERE_GREATER_THAN);
7638                                            }
7639                                            else {
7640                                                    query.append(WHERE_LESSER_THAN);
7641                                            }
7642                                    }
7643                            }
7644    
7645                            query.append(ORDER_BY_CLAUSE);
7646    
7647                            String[] orderByFields = orderByComparator.getOrderByFields();
7648    
7649                            for (int i = 0; i < orderByFields.length; i++) {
7650                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7651                                    query.append(orderByFields[i]);
7652    
7653                                    if ((i + 1) < orderByFields.length) {
7654                                            if (orderByComparator.isAscending() ^ previous) {
7655                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7656                                            }
7657                                            else {
7658                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7659                                            }
7660                                    }
7661                                    else {
7662                                            if (orderByComparator.isAscending() ^ previous) {
7663                                                    query.append(ORDER_BY_ASC);
7664                                            }
7665                                            else {
7666                                                    query.append(ORDER_BY_DESC);
7667                                            }
7668                                    }
7669                            }
7670                    }
7671                    else {
7672                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7673                    }
7674    
7675                    String sql = query.toString();
7676    
7677                    Query q = session.createQuery(sql);
7678    
7679                    q.setFirstResult(0);
7680                    q.setMaxResults(2);
7681    
7682                    QueryPos qPos = QueryPos.getInstance(q);
7683    
7684                    qPos.add(companyId);
7685    
7686                    qPos.add(status);
7687    
7688                    if (orderByComparator != null) {
7689                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7690    
7691                            for (Object value : values) {
7692                                    qPos.add(value);
7693                            }
7694                    }
7695    
7696                    List<BlogsEntry> list = q.list();
7697    
7698                    if (list.size() == 2) {
7699                            return list.get(1);
7700                    }
7701                    else {
7702                            return null;
7703                    }
7704            }
7705    
7706            /**
7707             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
7708             *
7709             * @param companyId the company ID
7710             * @param status the status
7711             */
7712            @Override
7713            public void removeByC_NotS(long companyId, int status) {
7714                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
7715                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7716                            remove(blogsEntry);
7717                    }
7718            }
7719    
7720            /**
7721             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
7722             *
7723             * @param companyId the company ID
7724             * @param status the status
7725             * @return the number of matching blogs entries
7726             */
7727            @Override
7728            public int countByC_NotS(long companyId, int status) {
7729                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
7730    
7731                    Object[] finderArgs = new Object[] { companyId, status };
7732    
7733                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7734                                    this);
7735    
7736                    if (count == null) {
7737                            StringBundler query = new StringBundler(3);
7738    
7739                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7740    
7741                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7742    
7743                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7744    
7745                            String sql = query.toString();
7746    
7747                            Session session = null;
7748    
7749                            try {
7750                                    session = openSession();
7751    
7752                                    Query q = session.createQuery(sql);
7753    
7754                                    QueryPos qPos = QueryPos.getInstance(q);
7755    
7756                                    qPos.add(companyId);
7757    
7758                                    qPos.add(status);
7759    
7760                                    count = (Long)q.uniqueResult();
7761    
7762                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7763                            }
7764                            catch (Exception e) {
7765                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7766    
7767                                    throw processException(e);
7768                            }
7769                            finally {
7770                                    closeSession(session);
7771                            }
7772                    }
7773    
7774                    return count.intValue();
7775            }
7776    
7777            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7778            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
7779            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7780                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7781                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
7782                            new String[] {
7783                                    Date.class.getName(), Integer.class.getName(),
7784                                    
7785                            Integer.class.getName(), Integer.class.getName(),
7786                                    OrderByComparator.class.getName()
7787                            });
7788            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7789                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7790                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
7791                            new String[] { Date.class.getName(), Integer.class.getName() });
7792    
7793            /**
7794             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7795             *
7796             * @param displayDate the display date
7797             * @param status the status
7798             * @return the matching blogs entries
7799             */
7800            @Override
7801            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
7802                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
7803                            QueryUtil.ALL_POS, null);
7804            }
7805    
7806            /**
7807             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7808             *
7809             * <p>
7810             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7811             * </p>
7812             *
7813             * @param displayDate the display date
7814             * @param status the status
7815             * @param start the lower bound of the range of blogs entries
7816             * @param end the upper bound of the range of blogs entries (not inclusive)
7817             * @return the range of matching blogs entries
7818             */
7819            @Override
7820            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7821                    int start, int end) {
7822                    return findByLtD_S(displayDate, status, start, end, null);
7823            }
7824    
7825            /**
7826             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7827             *
7828             * <p>
7829             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
7830             * </p>
7831             *
7832             * @param displayDate the display date
7833             * @param status the status
7834             * @param start the lower bound of the range of blogs entries
7835             * @param end the upper bound of the range of blogs entries (not inclusive)
7836             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7837             * @return the ordered range of matching blogs entries
7838             */
7839            @Override
7840            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7841                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
7842                    boolean pagination = true;
7843                    FinderPath finderPath = null;
7844                    Object[] finderArgs = null;
7845    
7846                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
7847                    finderArgs = new Object[] {
7848                                    displayDate, status,
7849                                    
7850                                    start, end, orderByComparator
7851                            };
7852    
7853                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7854                                    finderArgs, this);
7855    
7856                    if ((list != null) && !list.isEmpty()) {
7857                            for (BlogsEntry blogsEntry : list) {
7858                                    if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
7859                                                                                                                            .getTime()) ||
7860                                                    (status != blogsEntry.getStatus())) {
7861                                            list = null;
7862    
7863                                            break;
7864                                    }
7865                            }
7866                    }
7867    
7868                    if (list == null) {
7869                            StringBundler query = null;
7870    
7871                            if (orderByComparator != null) {
7872                                    query = new StringBundler(4 +
7873                                                    (orderByComparator.getOrderByFields().length * 3));
7874                            }
7875                            else {
7876                                    query = new StringBundler(4);
7877                            }
7878    
7879                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7880    
7881                            boolean bindDisplayDate = false;
7882    
7883                            if (displayDate == null) {
7884                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
7885                            }
7886                            else {
7887                                    bindDisplayDate = true;
7888    
7889                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
7890                            }
7891    
7892                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
7893    
7894                            if (orderByComparator != null) {
7895                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7896                                            orderByComparator);
7897                            }
7898                            else
7899                             if (pagination) {
7900                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7901                            }
7902    
7903                            String sql = query.toString();
7904    
7905                            Session session = null;
7906    
7907                            try {
7908                                    session = openSession();
7909    
7910                                    Query q = session.createQuery(sql);
7911    
7912                                    QueryPos qPos = QueryPos.getInstance(q);
7913    
7914                                    if (bindDisplayDate) {
7915                                            qPos.add(new Timestamp(displayDate.getTime()));
7916                                    }
7917    
7918                                    qPos.add(status);
7919    
7920                                    if (!pagination) {
7921                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7922                                                            start, end, false);
7923    
7924                                            Collections.sort(list);
7925    
7926                                            list = Collections.unmodifiableList(list);
7927                                    }
7928                                    else {
7929                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7930                                                            start, end);
7931                                    }
7932    
7933                                    cacheResult(list);
7934    
7935                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7936                            }
7937                            catch (Exception e) {
7938                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7939    
7940                                    throw processException(e);
7941                            }
7942                            finally {
7943                                    closeSession(session);
7944                            }
7945                    }
7946    
7947                    return list;
7948            }
7949    
7950            /**
7951             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7952             *
7953             * @param displayDate the display date
7954             * @param status the status
7955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7956             * @return the first matching blogs entry
7957             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
7958             */
7959            @Override
7960            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
7961                    OrderByComparator<BlogsEntry> orderByComparator)
7962                    throws NoSuchEntryException {
7963                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
7964                                    orderByComparator);
7965    
7966                    if (blogsEntry != null) {
7967                            return blogsEntry;
7968                    }
7969    
7970                    StringBundler msg = new StringBundler(6);
7971    
7972                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7973    
7974                    msg.append("displayDate=");
7975                    msg.append(displayDate);
7976    
7977                    msg.append(", status=");
7978                    msg.append(status);
7979    
7980                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7981    
7982                    throw new NoSuchEntryException(msg.toString());
7983            }
7984    
7985            /**
7986             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7987             *
7988             * @param displayDate the display date
7989             * @param status the status
7990             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7991             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7992             */
7993            @Override
7994            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
7995                    OrderByComparator<BlogsEntry> orderByComparator) {
7996                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
7997                                    orderByComparator);
7998    
7999                    if (!list.isEmpty()) {
8000                            return list.get(0);
8001                    }
8002    
8003                    return null;
8004            }
8005    
8006            /**
8007             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8008             *
8009             * @param displayDate the display date
8010             * @param status the status
8011             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8012             * @return the last matching blogs entry
8013             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8014             */
8015            @Override
8016            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8017                    OrderByComparator<BlogsEntry> orderByComparator)
8018                    throws NoSuchEntryException {
8019                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8020                                    orderByComparator);
8021    
8022                    if (blogsEntry != null) {
8023                            return blogsEntry;
8024                    }
8025    
8026                    StringBundler msg = new StringBundler(6);
8027    
8028                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8029    
8030                    msg.append("displayDate=");
8031                    msg.append(displayDate);
8032    
8033                    msg.append(", status=");
8034                    msg.append(status);
8035    
8036                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8037    
8038                    throw new NoSuchEntryException(msg.toString());
8039            }
8040    
8041            /**
8042             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8043             *
8044             * @param displayDate the display date
8045             * @param status the status
8046             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8047             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8048             */
8049            @Override
8050            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8051                    OrderByComparator<BlogsEntry> orderByComparator) {
8052                    int count = countByLtD_S(displayDate, status);
8053    
8054                    if (count == 0) {
8055                            return null;
8056                    }
8057    
8058                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8059                                    count, orderByComparator);
8060    
8061                    if (!list.isEmpty()) {
8062                            return list.get(0);
8063                    }
8064    
8065                    return null;
8066            }
8067    
8068            /**
8069             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8070             *
8071             * @param entryId the primary key of the current blogs entry
8072             * @param displayDate the display date
8073             * @param status the status
8074             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8075             * @return the previous, current, and next blogs entry
8076             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8077             */
8078            @Override
8079            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8080                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8081                    throws NoSuchEntryException {
8082                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8083    
8084                    Session session = null;
8085    
8086                    try {
8087                            session = openSession();
8088    
8089                            BlogsEntry[] array = new BlogsEntryImpl[3];
8090    
8091                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8092                                            status, orderByComparator, true);
8093    
8094                            array[1] = blogsEntry;
8095    
8096                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8097                                            status, orderByComparator, false);
8098    
8099                            return array;
8100                    }
8101                    catch (Exception e) {
8102                            throw processException(e);
8103                    }
8104                    finally {
8105                            closeSession(session);
8106                    }
8107            }
8108    
8109            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8110                    BlogsEntry blogsEntry, Date displayDate, int status,
8111                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8112                    StringBundler query = null;
8113    
8114                    if (orderByComparator != null) {
8115                            query = new StringBundler(6 +
8116                                            (orderByComparator.getOrderByFields().length * 6));
8117                    }
8118                    else {
8119                            query = new StringBundler(3);
8120                    }
8121    
8122                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8123    
8124                    boolean bindDisplayDate = false;
8125    
8126                    if (displayDate == null) {
8127                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8128                    }
8129                    else {
8130                            bindDisplayDate = true;
8131    
8132                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8133                    }
8134    
8135                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8136    
8137                    if (orderByComparator != null) {
8138                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8139    
8140                            if (orderByConditionFields.length > 0) {
8141                                    query.append(WHERE_AND);
8142                            }
8143    
8144                            for (int i = 0; i < orderByConditionFields.length; i++) {
8145                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8146                                    query.append(orderByConditionFields[i]);
8147    
8148                                    if ((i + 1) < orderByConditionFields.length) {
8149                                            if (orderByComparator.isAscending() ^ previous) {
8150                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8151                                            }
8152                                            else {
8153                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8154                                            }
8155                                    }
8156                                    else {
8157                                            if (orderByComparator.isAscending() ^ previous) {
8158                                                    query.append(WHERE_GREATER_THAN);
8159                                            }
8160                                            else {
8161                                                    query.append(WHERE_LESSER_THAN);
8162                                            }
8163                                    }
8164                            }
8165    
8166                            query.append(ORDER_BY_CLAUSE);
8167    
8168                            String[] orderByFields = orderByComparator.getOrderByFields();
8169    
8170                            for (int i = 0; i < orderByFields.length; i++) {
8171                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8172                                    query.append(orderByFields[i]);
8173    
8174                                    if ((i + 1) < orderByFields.length) {
8175                                            if (orderByComparator.isAscending() ^ previous) {
8176                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8177                                            }
8178                                            else {
8179                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8180                                            }
8181                                    }
8182                                    else {
8183                                            if (orderByComparator.isAscending() ^ previous) {
8184                                                    query.append(ORDER_BY_ASC);
8185                                            }
8186                                            else {
8187                                                    query.append(ORDER_BY_DESC);
8188                                            }
8189                                    }
8190                            }
8191                    }
8192                    else {
8193                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8194                    }
8195    
8196                    String sql = query.toString();
8197    
8198                    Query q = session.createQuery(sql);
8199    
8200                    q.setFirstResult(0);
8201                    q.setMaxResults(2);
8202    
8203                    QueryPos qPos = QueryPos.getInstance(q);
8204    
8205                    if (bindDisplayDate) {
8206                            qPos.add(new Timestamp(displayDate.getTime()));
8207                    }
8208    
8209                    qPos.add(status);
8210    
8211                    if (orderByComparator != null) {
8212                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8213    
8214                            for (Object value : values) {
8215                                    qPos.add(value);
8216                            }
8217                    }
8218    
8219                    List<BlogsEntry> list = q.list();
8220    
8221                    if (list.size() == 2) {
8222                            return list.get(1);
8223                    }
8224                    else {
8225                            return null;
8226                    }
8227            }
8228    
8229            /**
8230             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8231             *
8232             * @param displayDate the display date
8233             * @param status the status
8234             */
8235            @Override
8236            public void removeByLtD_S(Date displayDate, int status) {
8237                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8238                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8239                            remove(blogsEntry);
8240                    }
8241            }
8242    
8243            /**
8244             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8245             *
8246             * @param displayDate the display date
8247             * @param status the status
8248             * @return the number of matching blogs entries
8249             */
8250            @Override
8251            public int countByLtD_S(Date displayDate, int status) {
8252                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8253    
8254                    Object[] finderArgs = new Object[] { displayDate, status };
8255    
8256                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8257                                    this);
8258    
8259                    if (count == null) {
8260                            StringBundler query = new StringBundler(3);
8261    
8262                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8263    
8264                            boolean bindDisplayDate = false;
8265    
8266                            if (displayDate == null) {
8267                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8268                            }
8269                            else {
8270                                    bindDisplayDate = true;
8271    
8272                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8273                            }
8274    
8275                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8276    
8277                            String sql = query.toString();
8278    
8279                            Session session = null;
8280    
8281                            try {
8282                                    session = openSession();
8283    
8284                                    Query q = session.createQuery(sql);
8285    
8286                                    QueryPos qPos = QueryPos.getInstance(q);
8287    
8288                                    if (bindDisplayDate) {
8289                                            qPos.add(new Timestamp(displayDate.getTime()));
8290                                    }
8291    
8292                                    qPos.add(status);
8293    
8294                                    count = (Long)q.uniqueResult();
8295    
8296                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8297                            }
8298                            catch (Exception e) {
8299                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8300    
8301                                    throw processException(e);
8302                            }
8303                            finally {
8304                                    closeSession(session);
8305                            }
8306                    }
8307    
8308                    return count.intValue();
8309            }
8310    
8311            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
8312            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8313            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8314            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8315                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8316                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8317                            new String[] {
8318                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8319                                    
8320                            Integer.class.getName(), Integer.class.getName(),
8321                                    OrderByComparator.class.getName()
8322                            });
8323            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8324                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8325                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8326                            new String[] {
8327                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8328                            });
8329    
8330            /**
8331             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8332             *
8333             * @param groupId the group ID
8334             * @param userId the user ID
8335             * @param displayDate the display date
8336             * @return the matching blogs entries
8337             */
8338            @Override
8339            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8340                    Date displayDate) {
8341                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8342                            QueryUtil.ALL_POS, null);
8343            }
8344    
8345            /**
8346             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8347             *
8348             * <p>
8349             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8350             * </p>
8351             *
8352             * @param groupId the group ID
8353             * @param userId the user ID
8354             * @param displayDate the display date
8355             * @param start the lower bound of the range of blogs entries
8356             * @param end the upper bound of the range of blogs entries (not inclusive)
8357             * @return the range of matching blogs entries
8358             */
8359            @Override
8360            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8361                    Date displayDate, int start, int end) {
8362                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8363            }
8364    
8365            /**
8366             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8367             *
8368             * <p>
8369             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8370             * </p>
8371             *
8372             * @param groupId the group ID
8373             * @param userId the user ID
8374             * @param displayDate the display date
8375             * @param start the lower bound of the range of blogs entries
8376             * @param end the upper bound of the range of blogs entries (not inclusive)
8377             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8378             * @return the ordered range of matching blogs entries
8379             */
8380            @Override
8381            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8382                    Date displayDate, int start, int end,
8383                    OrderByComparator<BlogsEntry> orderByComparator) {
8384                    boolean pagination = true;
8385                    FinderPath finderPath = null;
8386                    Object[] finderArgs = null;
8387    
8388                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8389                    finderArgs = new Object[] {
8390                                    groupId, userId, displayDate,
8391                                    
8392                                    start, end, orderByComparator
8393                            };
8394    
8395                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8396                                    finderArgs, this);
8397    
8398                    if ((list != null) && !list.isEmpty()) {
8399                            for (BlogsEntry blogsEntry : list) {
8400                                    if ((groupId != blogsEntry.getGroupId()) ||
8401                                                    (userId != blogsEntry.getUserId()) ||
8402                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
8403                                                                                                                                    .getTime())) {
8404                                            list = null;
8405    
8406                                            break;
8407                                    }
8408                            }
8409                    }
8410    
8411                    if (list == null) {
8412                            StringBundler query = null;
8413    
8414                            if (orderByComparator != null) {
8415                                    query = new StringBundler(5 +
8416                                                    (orderByComparator.getOrderByFields().length * 3));
8417                            }
8418                            else {
8419                                    query = new StringBundler(5);
8420                            }
8421    
8422                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8423    
8424                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8425    
8426                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8427    
8428                            boolean bindDisplayDate = false;
8429    
8430                            if (displayDate == null) {
8431                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8432                            }
8433                            else {
8434                                    bindDisplayDate = true;
8435    
8436                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8437                            }
8438    
8439                            if (orderByComparator != null) {
8440                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8441                                            orderByComparator);
8442                            }
8443                            else
8444                             if (pagination) {
8445                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8446                            }
8447    
8448                            String sql = query.toString();
8449    
8450                            Session session = null;
8451    
8452                            try {
8453                                    session = openSession();
8454    
8455                                    Query q = session.createQuery(sql);
8456    
8457                                    QueryPos qPos = QueryPos.getInstance(q);
8458    
8459                                    qPos.add(groupId);
8460    
8461                                    qPos.add(userId);
8462    
8463                                    if (bindDisplayDate) {
8464                                            qPos.add(new Timestamp(displayDate.getTime()));
8465                                    }
8466    
8467                                    if (!pagination) {
8468                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8469                                                            start, end, false);
8470    
8471                                            Collections.sort(list);
8472    
8473                                            list = Collections.unmodifiableList(list);
8474                                    }
8475                                    else {
8476                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8477                                                            start, end);
8478                                    }
8479    
8480                                    cacheResult(list);
8481    
8482                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8483                            }
8484                            catch (Exception e) {
8485                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8486    
8487                                    throw processException(e);
8488                            }
8489                            finally {
8490                                    closeSession(session);
8491                            }
8492                    }
8493    
8494                    return list;
8495            }
8496    
8497            /**
8498             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8499             *
8500             * @param groupId the group ID
8501             * @param userId the user ID
8502             * @param displayDate the display date
8503             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8504             * @return the first matching blogs entry
8505             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8506             */
8507            @Override
8508            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8509                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8510                    throws NoSuchEntryException {
8511                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8512                                    displayDate, orderByComparator);
8513    
8514                    if (blogsEntry != null) {
8515                            return blogsEntry;
8516                    }
8517    
8518                    StringBundler msg = new StringBundler(8);
8519    
8520                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8521    
8522                    msg.append("groupId=");
8523                    msg.append(groupId);
8524    
8525                    msg.append(", userId=");
8526                    msg.append(userId);
8527    
8528                    msg.append(", displayDate=");
8529                    msg.append(displayDate);
8530    
8531                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8532    
8533                    throw new NoSuchEntryException(msg.toString());
8534            }
8535    
8536            /**
8537             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8538             *
8539             * @param groupId the group ID
8540             * @param userId the user ID
8541             * @param displayDate the display date
8542             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8543             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8544             */
8545            @Override
8546            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8547                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8548                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8549                                    1, orderByComparator);
8550    
8551                    if (!list.isEmpty()) {
8552                            return list.get(0);
8553                    }
8554    
8555                    return null;
8556            }
8557    
8558            /**
8559             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8560             *
8561             * @param groupId the group ID
8562             * @param userId the user ID
8563             * @param displayDate the display date
8564             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8565             * @return the last matching blogs entry
8566             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
8567             */
8568            @Override
8569            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8570                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8571                    throws NoSuchEntryException {
8572                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8573                                    displayDate, orderByComparator);
8574    
8575                    if (blogsEntry != null) {
8576                            return blogsEntry;
8577                    }
8578    
8579                    StringBundler msg = new StringBundler(8);
8580    
8581                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8582    
8583                    msg.append("groupId=");
8584                    msg.append(groupId);
8585    
8586                    msg.append(", userId=");
8587                    msg.append(userId);
8588    
8589                    msg.append(", displayDate=");
8590                    msg.append(displayDate);
8591    
8592                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8593    
8594                    throw new NoSuchEntryException(msg.toString());
8595            }
8596    
8597            /**
8598             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8599             *
8600             * @param groupId the group ID
8601             * @param userId the user ID
8602             * @param displayDate the display date
8603             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8604             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8605             */
8606            @Override
8607            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8608                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8609                    int count = countByG_U_LtD(groupId, userId, displayDate);
8610    
8611                    if (count == 0) {
8612                            return null;
8613                    }
8614    
8615                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8616                                    count - 1, count, orderByComparator);
8617    
8618                    if (!list.isEmpty()) {
8619                            return list.get(0);
8620                    }
8621    
8622                    return null;
8623            }
8624    
8625            /**
8626             * 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;.
8627             *
8628             * @param entryId the primary key of the current blogs entry
8629             * @param groupId the group ID
8630             * @param userId the user ID
8631             * @param displayDate the display date
8632             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8633             * @return the previous, current, and next blogs entry
8634             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8635             */
8636            @Override
8637            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8638                    long userId, Date displayDate,
8639                    OrderByComparator<BlogsEntry> orderByComparator)
8640                    throws NoSuchEntryException {
8641                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8642    
8643                    Session session = null;
8644    
8645                    try {
8646                            session = openSession();
8647    
8648                            BlogsEntry[] array = new BlogsEntryImpl[3];
8649    
8650                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8651                                            userId, displayDate, orderByComparator, true);
8652    
8653                            array[1] = blogsEntry;
8654    
8655                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8656                                            userId, displayDate, orderByComparator, false);
8657    
8658                            return array;
8659                    }
8660                    catch (Exception e) {
8661                            throw processException(e);
8662                    }
8663                    finally {
8664                            closeSession(session);
8665                    }
8666            }
8667    
8668            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
8669                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
8670                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8671                    StringBundler query = null;
8672    
8673                    if (orderByComparator != null) {
8674                            query = new StringBundler(6 +
8675                                            (orderByComparator.getOrderByFields().length * 6));
8676                    }
8677                    else {
8678                            query = new StringBundler(3);
8679                    }
8680    
8681                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8682    
8683                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8684    
8685                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8686    
8687                    boolean bindDisplayDate = false;
8688    
8689                    if (displayDate == null) {
8690                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8691                    }
8692                    else {
8693                            bindDisplayDate = true;
8694    
8695                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8696                    }
8697    
8698                    if (orderByComparator != null) {
8699                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8700    
8701                            if (orderByConditionFields.length > 0) {
8702                                    query.append(WHERE_AND);
8703                            }
8704    
8705                            for (int i = 0; i < orderByConditionFields.length; i++) {
8706                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8707                                    query.append(orderByConditionFields[i]);
8708    
8709                                    if ((i + 1) < orderByConditionFields.length) {
8710                                            if (orderByComparator.isAscending() ^ previous) {
8711                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8712                                            }
8713                                            else {
8714                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8715                                            }
8716                                    }
8717                                    else {
8718                                            if (orderByComparator.isAscending() ^ previous) {
8719                                                    query.append(WHERE_GREATER_THAN);
8720                                            }
8721                                            else {
8722                                                    query.append(WHERE_LESSER_THAN);
8723                                            }
8724                                    }
8725                            }
8726    
8727                            query.append(ORDER_BY_CLAUSE);
8728    
8729                            String[] orderByFields = orderByComparator.getOrderByFields();
8730    
8731                            for (int i = 0; i < orderByFields.length; i++) {
8732                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8733                                    query.append(orderByFields[i]);
8734    
8735                                    if ((i + 1) < orderByFields.length) {
8736                                            if (orderByComparator.isAscending() ^ previous) {
8737                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8738                                            }
8739                                            else {
8740                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8741                                            }
8742                                    }
8743                                    else {
8744                                            if (orderByComparator.isAscending() ^ previous) {
8745                                                    query.append(ORDER_BY_ASC);
8746                                            }
8747                                            else {
8748                                                    query.append(ORDER_BY_DESC);
8749                                            }
8750                                    }
8751                            }
8752                    }
8753                    else {
8754                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8755                    }
8756    
8757                    String sql = query.toString();
8758    
8759                    Query q = session.createQuery(sql);
8760    
8761                    q.setFirstResult(0);
8762                    q.setMaxResults(2);
8763    
8764                    QueryPos qPos = QueryPos.getInstance(q);
8765    
8766                    qPos.add(groupId);
8767    
8768                    qPos.add(userId);
8769    
8770                    if (bindDisplayDate) {
8771                            qPos.add(new Timestamp(displayDate.getTime()));
8772                    }
8773    
8774                    if (orderByComparator != null) {
8775                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8776    
8777                            for (Object value : values) {
8778                                    qPos.add(value);
8779                            }
8780                    }
8781    
8782                    List<BlogsEntry> list = q.list();
8783    
8784                    if (list.size() == 2) {
8785                            return list.get(1);
8786                    }
8787                    else {
8788                            return null;
8789                    }
8790            }
8791    
8792            /**
8793             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8794             *
8795             * @param groupId the group ID
8796             * @param userId the user ID
8797             * @param displayDate the display date
8798             * @return the matching blogs entries that the user has permission to view
8799             */
8800            @Override
8801            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
8802                    Date displayDate) {
8803                    return filterFindByG_U_LtD(groupId, userId, displayDate,
8804                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8805            }
8806    
8807            /**
8808             * 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;.
8809             *
8810             * <p>
8811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8812             * </p>
8813             *
8814             * @param groupId the group ID
8815             * @param userId the user ID
8816             * @param displayDate the display date
8817             * @param start the lower bound of the range of blogs entries
8818             * @param end the upper bound of the range of blogs entries (not inclusive)
8819             * @return the range of matching blogs entries that the user has permission to view
8820             */
8821            @Override
8822            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
8823                    Date displayDate, int start, int end) {
8824                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
8825                            null);
8826            }
8827    
8828            /**
8829             * 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;.
8830             *
8831             * <p>
8832             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
8833             * </p>
8834             *
8835             * @param groupId the group ID
8836             * @param userId the user ID
8837             * @param displayDate the display date
8838             * @param start the lower bound of the range of blogs entries
8839             * @param end the upper bound of the range of blogs entries (not inclusive)
8840             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8841             * @return the ordered range of matching blogs entries that the user has permission to view
8842             */
8843            @Override
8844            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
8845                    Date displayDate, int start, int end,
8846                    OrderByComparator<BlogsEntry> orderByComparator) {
8847                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8848                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
8849                                    orderByComparator);
8850                    }
8851    
8852                    StringBundler query = null;
8853    
8854                    if (orderByComparator != null) {
8855                            query = new StringBundler(5 +
8856                                            (orderByComparator.getOrderByFields().length * 3));
8857                    }
8858                    else {
8859                            query = new StringBundler(5);
8860                    }
8861    
8862                    if (getDB().isSupportsInlineDistinct()) {
8863                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
8864                    }
8865                    else {
8866                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
8867                    }
8868    
8869                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8870    
8871                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8872    
8873                    boolean bindDisplayDate = false;
8874    
8875                    if (displayDate == null) {
8876                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8877                    }
8878                    else {
8879                            bindDisplayDate = true;
8880    
8881                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8882                    }
8883    
8884                    if (!getDB().isSupportsInlineDistinct()) {
8885                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
8886                    }
8887    
8888                    if (orderByComparator != null) {
8889                            if (getDB().isSupportsInlineDistinct()) {
8890                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8891                                            orderByComparator, true);
8892                            }
8893                            else {
8894                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8895                                            orderByComparator, true);
8896                            }
8897                    }
8898                    else {
8899                            if (getDB().isSupportsInlineDistinct()) {
8900                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8901                            }
8902                            else {
8903                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
8904                            }
8905                    }
8906    
8907                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8908                                    BlogsEntry.class.getName(),
8909                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8910    
8911                    Session session = null;
8912    
8913                    try {
8914                            session = openSession();
8915    
8916                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8917    
8918                            if (getDB().isSupportsInlineDistinct()) {
8919                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
8920                            }
8921                            else {
8922                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
8923                            }
8924    
8925                            QueryPos qPos = QueryPos.getInstance(q);
8926    
8927                            qPos.add(groupId);
8928    
8929                            qPos.add(userId);
8930    
8931                            if (bindDisplayDate) {
8932                                    qPos.add(new Timestamp(displayDate.getTime()));
8933                            }
8934    
8935                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
8936                    }
8937                    catch (Exception e) {
8938                            throw processException(e);
8939                    }
8940                    finally {
8941                            closeSession(session);
8942                    }
8943            }
8944    
8945            /**
8946             * 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;.
8947             *
8948             * @param entryId the primary key of the current blogs entry
8949             * @param groupId the group ID
8950             * @param userId the user ID
8951             * @param displayDate the display date
8952             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8953             * @return the previous, current, and next blogs entry
8954             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
8955             */
8956            @Override
8957            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
8958                    long groupId, long userId, Date displayDate,
8959                    OrderByComparator<BlogsEntry> orderByComparator)
8960                    throws NoSuchEntryException {
8961                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8962                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
8963                                    displayDate, orderByComparator);
8964                    }
8965    
8966                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8967    
8968                    Session session = null;
8969    
8970                    try {
8971                            session = openSession();
8972    
8973                            BlogsEntry[] array = new BlogsEntryImpl[3];
8974    
8975                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
8976                                            groupId, userId, displayDate, orderByComparator, true);
8977    
8978                            array[1] = blogsEntry;
8979    
8980                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
8981                                            groupId, userId, displayDate, orderByComparator, false);
8982    
8983                            return array;
8984                    }
8985                    catch (Exception e) {
8986                            throw processException(e);
8987                    }
8988                    finally {
8989                            closeSession(session);
8990                    }
8991            }
8992    
8993            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
8994                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
8995                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8996                    StringBundler query = null;
8997    
8998                    if (orderByComparator != null) {
8999                            query = new StringBundler(6 +
9000                                            (orderByComparator.getOrderByFields().length * 6));
9001                    }
9002                    else {
9003                            query = new StringBundler(3);
9004                    }
9005    
9006                    if (getDB().isSupportsInlineDistinct()) {
9007                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9008                    }
9009                    else {
9010                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9011                    }
9012    
9013                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9014    
9015                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9016    
9017                    boolean bindDisplayDate = false;
9018    
9019                    if (displayDate == null) {
9020                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9021                    }
9022                    else {
9023                            bindDisplayDate = true;
9024    
9025                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9026                    }
9027    
9028                    if (!getDB().isSupportsInlineDistinct()) {
9029                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9030                    }
9031    
9032                    if (orderByComparator != null) {
9033                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9034    
9035                            if (orderByConditionFields.length > 0) {
9036                                    query.append(WHERE_AND);
9037                            }
9038    
9039                            for (int i = 0; i < orderByConditionFields.length; i++) {
9040                                    if (getDB().isSupportsInlineDistinct()) {
9041                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9042                                    }
9043                                    else {
9044                                            query.append(_ORDER_BY_ENTITY_TABLE);
9045                                    }
9046    
9047                                    query.append(orderByConditionFields[i]);
9048    
9049                                    if ((i + 1) < orderByConditionFields.length) {
9050                                            if (orderByComparator.isAscending() ^ previous) {
9051                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9052                                            }
9053                                            else {
9054                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9055                                            }
9056                                    }
9057                                    else {
9058                                            if (orderByComparator.isAscending() ^ previous) {
9059                                                    query.append(WHERE_GREATER_THAN);
9060                                            }
9061                                            else {
9062                                                    query.append(WHERE_LESSER_THAN);
9063                                            }
9064                                    }
9065                            }
9066    
9067                            query.append(ORDER_BY_CLAUSE);
9068    
9069                            String[] orderByFields = orderByComparator.getOrderByFields();
9070    
9071                            for (int i = 0; i < orderByFields.length; i++) {
9072                                    if (getDB().isSupportsInlineDistinct()) {
9073                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9074                                    }
9075                                    else {
9076                                            query.append(_ORDER_BY_ENTITY_TABLE);
9077                                    }
9078    
9079                                    query.append(orderByFields[i]);
9080    
9081                                    if ((i + 1) < orderByFields.length) {
9082                                            if (orderByComparator.isAscending() ^ previous) {
9083                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9084                                            }
9085                                            else {
9086                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9087                                            }
9088                                    }
9089                                    else {
9090                                            if (orderByComparator.isAscending() ^ previous) {
9091                                                    query.append(ORDER_BY_ASC);
9092                                            }
9093                                            else {
9094                                                    query.append(ORDER_BY_DESC);
9095                                            }
9096                                    }
9097                            }
9098                    }
9099                    else {
9100                            if (getDB().isSupportsInlineDistinct()) {
9101                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9102                            }
9103                            else {
9104                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9105                            }
9106                    }
9107    
9108                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9109                                    BlogsEntry.class.getName(),
9110                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9111    
9112                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9113    
9114                    q.setFirstResult(0);
9115                    q.setMaxResults(2);
9116    
9117                    if (getDB().isSupportsInlineDistinct()) {
9118                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9119                    }
9120                    else {
9121                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9122                    }
9123    
9124                    QueryPos qPos = QueryPos.getInstance(q);
9125    
9126                    qPos.add(groupId);
9127    
9128                    qPos.add(userId);
9129    
9130                    if (bindDisplayDate) {
9131                            qPos.add(new Timestamp(displayDate.getTime()));
9132                    }
9133    
9134                    if (orderByComparator != null) {
9135                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9136    
9137                            for (Object value : values) {
9138                                    qPos.add(value);
9139                            }
9140                    }
9141    
9142                    List<BlogsEntry> list = q.list();
9143    
9144                    if (list.size() == 2) {
9145                            return list.get(1);
9146                    }
9147                    else {
9148                            return null;
9149                    }
9150            }
9151    
9152            /**
9153             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9154             *
9155             * @param groupId the group ID
9156             * @param userId the user ID
9157             * @param displayDate the display date
9158             */
9159            @Override
9160            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9161                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9162                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9163                            remove(blogsEntry);
9164                    }
9165            }
9166    
9167            /**
9168             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9169             *
9170             * @param groupId the group ID
9171             * @param userId the user ID
9172             * @param displayDate the display date
9173             * @return the number of matching blogs entries
9174             */
9175            @Override
9176            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9177                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9178    
9179                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9180    
9181                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9182                                    this);
9183    
9184                    if (count == null) {
9185                            StringBundler query = new StringBundler(4);
9186    
9187                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9188    
9189                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9190    
9191                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9192    
9193                            boolean bindDisplayDate = false;
9194    
9195                            if (displayDate == null) {
9196                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9197                            }
9198                            else {
9199                                    bindDisplayDate = true;
9200    
9201                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9202                            }
9203    
9204                            String sql = query.toString();
9205    
9206                            Session session = null;
9207    
9208                            try {
9209                                    session = openSession();
9210    
9211                                    Query q = session.createQuery(sql);
9212    
9213                                    QueryPos qPos = QueryPos.getInstance(q);
9214    
9215                                    qPos.add(groupId);
9216    
9217                                    qPos.add(userId);
9218    
9219                                    if (bindDisplayDate) {
9220                                            qPos.add(new Timestamp(displayDate.getTime()));
9221                                    }
9222    
9223                                    count = (Long)q.uniqueResult();
9224    
9225                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9226                            }
9227                            catch (Exception e) {
9228                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9229    
9230                                    throw processException(e);
9231                            }
9232                            finally {
9233                                    closeSession(session);
9234                            }
9235                    }
9236    
9237                    return count.intValue();
9238            }
9239    
9240            /**
9241             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9242             *
9243             * @param groupId the group ID
9244             * @param userId the user ID
9245             * @param displayDate the display date
9246             * @return the number of matching blogs entries that the user has permission to view
9247             */
9248            @Override
9249            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9250                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9251                            return countByG_U_LtD(groupId, userId, displayDate);
9252                    }
9253    
9254                    StringBundler query = new StringBundler(4);
9255    
9256                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9257    
9258                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9259    
9260                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9261    
9262                    boolean bindDisplayDate = false;
9263    
9264                    if (displayDate == null) {
9265                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9266                    }
9267                    else {
9268                            bindDisplayDate = true;
9269    
9270                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9271                    }
9272    
9273                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9274                                    BlogsEntry.class.getName(),
9275                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9276    
9277                    Session session = null;
9278    
9279                    try {
9280                            session = openSession();
9281    
9282                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9283    
9284                            q.addScalar(COUNT_COLUMN_NAME,
9285                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9286    
9287                            QueryPos qPos = QueryPos.getInstance(q);
9288    
9289                            qPos.add(groupId);
9290    
9291                            qPos.add(userId);
9292    
9293                            if (bindDisplayDate) {
9294                                    qPos.add(new Timestamp(displayDate.getTime()));
9295                            }
9296    
9297                            Long count = (Long)q.uniqueResult();
9298    
9299                            return count.intValue();
9300                    }
9301                    catch (Exception e) {
9302                            throw processException(e);
9303                    }
9304                    finally {
9305                            closeSession(session);
9306                    }
9307            }
9308    
9309            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9310            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9311            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
9312            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9313            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9314                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9315                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9316                            new String[] {
9317                                    Long.class.getName(), Long.class.getName(),
9318                                    Integer.class.getName(),
9319                                    
9320                            Integer.class.getName(), Integer.class.getName(),
9321                                    OrderByComparator.class.getName()
9322                            });
9323            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9324                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9325                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9326                            new String[] {
9327                                    Long.class.getName(), Long.class.getName(),
9328                                    Integer.class.getName()
9329                            },
9330                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9331                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9332                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9333                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9334                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9335            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9336                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9337                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9338                            new String[] {
9339                                    Long.class.getName(), Long.class.getName(),
9340                                    Integer.class.getName()
9341                            });
9342    
9343            /**
9344             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9345             *
9346             * @param groupId the group ID
9347             * @param userId the user ID
9348             * @param status the status
9349             * @return the matching blogs entries
9350             */
9351            @Override
9352            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9353                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9354                            QueryUtil.ALL_POS, null);
9355            }
9356    
9357            /**
9358             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9359             *
9360             * <p>
9361             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9362             * </p>
9363             *
9364             * @param groupId the group ID
9365             * @param userId the user ID
9366             * @param status the status
9367             * @param start the lower bound of the range of blogs entries
9368             * @param end the upper bound of the range of blogs entries (not inclusive)
9369             * @return the range of matching blogs entries
9370             */
9371            @Override
9372            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9373                    int start, int end) {
9374                    return findByG_U_S(groupId, userId, status, start, end, null);
9375            }
9376    
9377            /**
9378             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9379             *
9380             * <p>
9381             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9382             * </p>
9383             *
9384             * @param groupId the group ID
9385             * @param userId the user ID
9386             * @param status the status
9387             * @param start the lower bound of the range of blogs entries
9388             * @param end the upper bound of the range of blogs entries (not inclusive)
9389             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9390             * @return the ordered range of matching blogs entries
9391             */
9392            @Override
9393            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9394                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9395                    boolean pagination = true;
9396                    FinderPath finderPath = null;
9397                    Object[] finderArgs = null;
9398    
9399                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9400                                    (orderByComparator == null)) {
9401                            pagination = false;
9402                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9403                            finderArgs = new Object[] { groupId, userId, status };
9404                    }
9405                    else {
9406                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9407                            finderArgs = new Object[] {
9408                                            groupId, userId, status,
9409                                            
9410                                            start, end, orderByComparator
9411                                    };
9412                    }
9413    
9414                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9415                                    finderArgs, this);
9416    
9417                    if ((list != null) && !list.isEmpty()) {
9418                            for (BlogsEntry blogsEntry : list) {
9419                                    if ((groupId != blogsEntry.getGroupId()) ||
9420                                                    (userId != blogsEntry.getUserId()) ||
9421                                                    (status != blogsEntry.getStatus())) {
9422                                            list = null;
9423    
9424                                            break;
9425                                    }
9426                            }
9427                    }
9428    
9429                    if (list == null) {
9430                            StringBundler query = null;
9431    
9432                            if (orderByComparator != null) {
9433                                    query = new StringBundler(5 +
9434                                                    (orderByComparator.getOrderByFields().length * 3));
9435                            }
9436                            else {
9437                                    query = new StringBundler(5);
9438                            }
9439    
9440                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9441    
9442                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9443    
9444                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9445    
9446                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9447    
9448                            if (orderByComparator != null) {
9449                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9450                                            orderByComparator);
9451                            }
9452                            else
9453                             if (pagination) {
9454                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9455                            }
9456    
9457                            String sql = query.toString();
9458    
9459                            Session session = null;
9460    
9461                            try {
9462                                    session = openSession();
9463    
9464                                    Query q = session.createQuery(sql);
9465    
9466                                    QueryPos qPos = QueryPos.getInstance(q);
9467    
9468                                    qPos.add(groupId);
9469    
9470                                    qPos.add(userId);
9471    
9472                                    qPos.add(status);
9473    
9474                                    if (!pagination) {
9475                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9476                                                            start, end, false);
9477    
9478                                            Collections.sort(list);
9479    
9480                                            list = Collections.unmodifiableList(list);
9481                                    }
9482                                    else {
9483                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9484                                                            start, end);
9485                                    }
9486    
9487                                    cacheResult(list);
9488    
9489                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9490                            }
9491                            catch (Exception e) {
9492                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9493    
9494                                    throw processException(e);
9495                            }
9496                            finally {
9497                                    closeSession(session);
9498                            }
9499                    }
9500    
9501                    return list;
9502            }
9503    
9504            /**
9505             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9506             *
9507             * @param groupId the group ID
9508             * @param userId the user ID
9509             * @param status the status
9510             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9511             * @return the first matching blogs entry
9512             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9513             */
9514            @Override
9515            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9516                    OrderByComparator<BlogsEntry> orderByComparator)
9517                    throws NoSuchEntryException {
9518                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9519                                    orderByComparator);
9520    
9521                    if (blogsEntry != null) {
9522                            return blogsEntry;
9523                    }
9524    
9525                    StringBundler msg = new StringBundler(8);
9526    
9527                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9528    
9529                    msg.append("groupId=");
9530                    msg.append(groupId);
9531    
9532                    msg.append(", userId=");
9533                    msg.append(userId);
9534    
9535                    msg.append(", status=");
9536                    msg.append(status);
9537    
9538                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9539    
9540                    throw new NoSuchEntryException(msg.toString());
9541            }
9542    
9543            /**
9544             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9545             *
9546             * @param groupId the group ID
9547             * @param userId the user ID
9548             * @param status the status
9549             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9550             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9551             */
9552            @Override
9553            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9554                    OrderByComparator<BlogsEntry> orderByComparator) {
9555                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9556                                    orderByComparator);
9557    
9558                    if (!list.isEmpty()) {
9559                            return list.get(0);
9560                    }
9561    
9562                    return null;
9563            }
9564    
9565            /**
9566             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9567             *
9568             * @param groupId the group ID
9569             * @param userId the user ID
9570             * @param status the status
9571             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9572             * @return the last matching blogs entry
9573             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
9574             */
9575            @Override
9576            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9577                    OrderByComparator<BlogsEntry> orderByComparator)
9578                    throws NoSuchEntryException {
9579                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9580                                    orderByComparator);
9581    
9582                    if (blogsEntry != null) {
9583                            return blogsEntry;
9584                    }
9585    
9586                    StringBundler msg = new StringBundler(8);
9587    
9588                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9589    
9590                    msg.append("groupId=");
9591                    msg.append(groupId);
9592    
9593                    msg.append(", userId=");
9594                    msg.append(userId);
9595    
9596                    msg.append(", status=");
9597                    msg.append(status);
9598    
9599                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9600    
9601                    throw new NoSuchEntryException(msg.toString());
9602            }
9603    
9604            /**
9605             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9606             *
9607             * @param groupId the group ID
9608             * @param userId the user ID
9609             * @param status the status
9610             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9611             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9612             */
9613            @Override
9614            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
9615                    OrderByComparator<BlogsEntry> orderByComparator) {
9616                    int count = countByG_U_S(groupId, userId, status);
9617    
9618                    if (count == 0) {
9619                            return null;
9620                    }
9621    
9622                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
9623                                    count, orderByComparator);
9624    
9625                    if (!list.isEmpty()) {
9626                            return list.get(0);
9627                    }
9628    
9629                    return null;
9630            }
9631    
9632            /**
9633             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9634             *
9635             * @param entryId the primary key of the current blogs entry
9636             * @param groupId the group ID
9637             * @param userId the user ID
9638             * @param status the status
9639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9640             * @return the previous, current, and next blogs entry
9641             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9642             */
9643            @Override
9644            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
9645                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
9646                    throws NoSuchEntryException {
9647                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9648    
9649                    Session session = null;
9650    
9651                    try {
9652                            session = openSession();
9653    
9654                            BlogsEntry[] array = new BlogsEntryImpl[3];
9655    
9656                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
9657                                            userId, status, orderByComparator, true);
9658    
9659                            array[1] = blogsEntry;
9660    
9661                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
9662                                            userId, status, orderByComparator, false);
9663    
9664                            return array;
9665                    }
9666                    catch (Exception e) {
9667                            throw processException(e);
9668                    }
9669                    finally {
9670                            closeSession(session);
9671                    }
9672            }
9673    
9674            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
9675                    BlogsEntry blogsEntry, long groupId, long userId, int status,
9676                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9677                    StringBundler query = null;
9678    
9679                    if (orderByComparator != null) {
9680                            query = new StringBundler(6 +
9681                                            (orderByComparator.getOrderByFields().length * 6));
9682                    }
9683                    else {
9684                            query = new StringBundler(3);
9685                    }
9686    
9687                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9688    
9689                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9690    
9691                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9692    
9693                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9694    
9695                    if (orderByComparator != null) {
9696                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9697    
9698                            if (orderByConditionFields.length > 0) {
9699                                    query.append(WHERE_AND);
9700                            }
9701    
9702                            for (int i = 0; i < orderByConditionFields.length; i++) {
9703                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9704                                    query.append(orderByConditionFields[i]);
9705    
9706                                    if ((i + 1) < orderByConditionFields.length) {
9707                                            if (orderByComparator.isAscending() ^ previous) {
9708                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9709                                            }
9710                                            else {
9711                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9712                                            }
9713                                    }
9714                                    else {
9715                                            if (orderByComparator.isAscending() ^ previous) {
9716                                                    query.append(WHERE_GREATER_THAN);
9717                                            }
9718                                            else {
9719                                                    query.append(WHERE_LESSER_THAN);
9720                                            }
9721                                    }
9722                            }
9723    
9724                            query.append(ORDER_BY_CLAUSE);
9725    
9726                            String[] orderByFields = orderByComparator.getOrderByFields();
9727    
9728                            for (int i = 0; i < orderByFields.length; i++) {
9729                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9730                                    query.append(orderByFields[i]);
9731    
9732                                    if ((i + 1) < orderByFields.length) {
9733                                            if (orderByComparator.isAscending() ^ previous) {
9734                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9735                                            }
9736                                            else {
9737                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9738                                            }
9739                                    }
9740                                    else {
9741                                            if (orderByComparator.isAscending() ^ previous) {
9742                                                    query.append(ORDER_BY_ASC);
9743                                            }
9744                                            else {
9745                                                    query.append(ORDER_BY_DESC);
9746                                            }
9747                                    }
9748                            }
9749                    }
9750                    else {
9751                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9752                    }
9753    
9754                    String sql = query.toString();
9755    
9756                    Query q = session.createQuery(sql);
9757    
9758                    q.setFirstResult(0);
9759                    q.setMaxResults(2);
9760    
9761                    QueryPos qPos = QueryPos.getInstance(q);
9762    
9763                    qPos.add(groupId);
9764    
9765                    qPos.add(userId);
9766    
9767                    qPos.add(status);
9768    
9769                    if (orderByComparator != null) {
9770                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9771    
9772                            for (Object value : values) {
9773                                    qPos.add(value);
9774                            }
9775                    }
9776    
9777                    List<BlogsEntry> list = q.list();
9778    
9779                    if (list.size() == 2) {
9780                            return list.get(1);
9781                    }
9782                    else {
9783                            return null;
9784                    }
9785            }
9786    
9787            /**
9788             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
9789             *
9790             * @param groupId the group ID
9791             * @param userId the user ID
9792             * @param status the status
9793             * @return the matching blogs entries that the user has permission to view
9794             */
9795            @Override
9796            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
9797                    int status) {
9798                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9799                            QueryUtil.ALL_POS, null);
9800            }
9801    
9802            /**
9803             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
9804             *
9805             * <p>
9806             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9807             * </p>
9808             *
9809             * @param groupId the group ID
9810             * @param userId the user ID
9811             * @param status the status
9812             * @param start the lower bound of the range of blogs entries
9813             * @param end the upper bound of the range of blogs entries (not inclusive)
9814             * @return the range of matching blogs entries that the user has permission to view
9815             */
9816            @Override
9817            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
9818                    int status, int start, int end) {
9819                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
9820            }
9821    
9822            /**
9823             * 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;.
9824             *
9825             * <p>
9826             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
9827             * </p>
9828             *
9829             * @param groupId the group ID
9830             * @param userId the user ID
9831             * @param status the status
9832             * @param start the lower bound of the range of blogs entries
9833             * @param end the upper bound of the range of blogs entries (not inclusive)
9834             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9835             * @return the ordered range of matching blogs entries that the user has permission to view
9836             */
9837            @Override
9838            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
9839                    int status, int start, int end,
9840                    OrderByComparator<BlogsEntry> orderByComparator) {
9841                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9842                            return findByG_U_S(groupId, userId, status, start, end,
9843                                    orderByComparator);
9844                    }
9845    
9846                    StringBundler query = null;
9847    
9848                    if (orderByComparator != null) {
9849                            query = new StringBundler(5 +
9850                                            (orderByComparator.getOrderByFields().length * 3));
9851                    }
9852                    else {
9853                            query = new StringBundler(5);
9854                    }
9855    
9856                    if (getDB().isSupportsInlineDistinct()) {
9857                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9858                    }
9859                    else {
9860                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9861                    }
9862    
9863                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9864    
9865                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9866    
9867                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9868    
9869                    if (!getDB().isSupportsInlineDistinct()) {
9870                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9871                    }
9872    
9873                    if (orderByComparator != null) {
9874                            if (getDB().isSupportsInlineDistinct()) {
9875                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9876                                            orderByComparator, true);
9877                            }
9878                            else {
9879                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9880                                            orderByComparator, true);
9881                            }
9882                    }
9883                    else {
9884                            if (getDB().isSupportsInlineDistinct()) {
9885                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9886                            }
9887                            else {
9888                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9889                            }
9890                    }
9891    
9892                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9893                                    BlogsEntry.class.getName(),
9894                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9895    
9896                    Session session = null;
9897    
9898                    try {
9899                            session = openSession();
9900    
9901                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9902    
9903                            if (getDB().isSupportsInlineDistinct()) {
9904                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9905                            }
9906                            else {
9907                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9908                            }
9909    
9910                            QueryPos qPos = QueryPos.getInstance(q);
9911    
9912                            qPos.add(groupId);
9913    
9914                            qPos.add(userId);
9915    
9916                            qPos.add(status);
9917    
9918                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9919                    }
9920                    catch (Exception e) {
9921                            throw processException(e);
9922                    }
9923                    finally {
9924                            closeSession(session);
9925                    }
9926            }
9927    
9928            /**
9929             * 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;.
9930             *
9931             * @param entryId the primary key of the current blogs entry
9932             * @param groupId the group ID
9933             * @param userId the user ID
9934             * @param status the status
9935             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9936             * @return the previous, current, and next blogs entry
9937             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
9938             */
9939            @Override
9940            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
9941                    long groupId, long userId, int status,
9942                    OrderByComparator<BlogsEntry> orderByComparator)
9943                    throws NoSuchEntryException {
9944                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9945                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
9946                                    orderByComparator);
9947                    }
9948    
9949                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9950    
9951                    Session session = null;
9952    
9953                    try {
9954                            session = openSession();
9955    
9956                            BlogsEntry[] array = new BlogsEntryImpl[3];
9957    
9958                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
9959                                            groupId, userId, status, orderByComparator, true);
9960    
9961                            array[1] = blogsEntry;
9962    
9963                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
9964                                            groupId, userId, status, orderByComparator, false);
9965    
9966                            return array;
9967                    }
9968                    catch (Exception e) {
9969                            throw processException(e);
9970                    }
9971                    finally {
9972                            closeSession(session);
9973                    }
9974            }
9975    
9976            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
9977                    BlogsEntry blogsEntry, long groupId, long userId, int status,
9978                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9979                    StringBundler query = null;
9980    
9981                    if (orderByComparator != null) {
9982                            query = new StringBundler(6 +
9983                                            (orderByComparator.getOrderByFields().length * 6));
9984                    }
9985                    else {
9986                            query = new StringBundler(3);
9987                    }
9988    
9989                    if (getDB().isSupportsInlineDistinct()) {
9990                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9991                    }
9992                    else {
9993                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9994                    }
9995    
9996                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9997    
9998                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9999    
10000                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10001    
10002                    if (!getDB().isSupportsInlineDistinct()) {
10003                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10004                    }
10005    
10006                    if (orderByComparator != null) {
10007                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10008    
10009                            if (orderByConditionFields.length > 0) {
10010                                    query.append(WHERE_AND);
10011                            }
10012    
10013                            for (int i = 0; i < orderByConditionFields.length; i++) {
10014                                    if (getDB().isSupportsInlineDistinct()) {
10015                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10016                                    }
10017                                    else {
10018                                            query.append(_ORDER_BY_ENTITY_TABLE);
10019                                    }
10020    
10021                                    query.append(orderByConditionFields[i]);
10022    
10023                                    if ((i + 1) < orderByConditionFields.length) {
10024                                            if (orderByComparator.isAscending() ^ previous) {
10025                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10026                                            }
10027                                            else {
10028                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10029                                            }
10030                                    }
10031                                    else {
10032                                            if (orderByComparator.isAscending() ^ previous) {
10033                                                    query.append(WHERE_GREATER_THAN);
10034                                            }
10035                                            else {
10036                                                    query.append(WHERE_LESSER_THAN);
10037                                            }
10038                                    }
10039                            }
10040    
10041                            query.append(ORDER_BY_CLAUSE);
10042    
10043                            String[] orderByFields = orderByComparator.getOrderByFields();
10044    
10045                            for (int i = 0; i < orderByFields.length; i++) {
10046                                    if (getDB().isSupportsInlineDistinct()) {
10047                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10048                                    }
10049                                    else {
10050                                            query.append(_ORDER_BY_ENTITY_TABLE);
10051                                    }
10052    
10053                                    query.append(orderByFields[i]);
10054    
10055                                    if ((i + 1) < orderByFields.length) {
10056                                            if (orderByComparator.isAscending() ^ previous) {
10057                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10058                                            }
10059                                            else {
10060                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10061                                            }
10062                                    }
10063                                    else {
10064                                            if (orderByComparator.isAscending() ^ previous) {
10065                                                    query.append(ORDER_BY_ASC);
10066                                            }
10067                                            else {
10068                                                    query.append(ORDER_BY_DESC);
10069                                            }
10070                                    }
10071                            }
10072                    }
10073                    else {
10074                            if (getDB().isSupportsInlineDistinct()) {
10075                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10076                            }
10077                            else {
10078                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10079                            }
10080                    }
10081    
10082                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10083                                    BlogsEntry.class.getName(),
10084                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10085    
10086                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10087    
10088                    q.setFirstResult(0);
10089                    q.setMaxResults(2);
10090    
10091                    if (getDB().isSupportsInlineDistinct()) {
10092                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10093                    }
10094                    else {
10095                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10096                    }
10097    
10098                    QueryPos qPos = QueryPos.getInstance(q);
10099    
10100                    qPos.add(groupId);
10101    
10102                    qPos.add(userId);
10103    
10104                    qPos.add(status);
10105    
10106                    if (orderByComparator != null) {
10107                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10108    
10109                            for (Object value : values) {
10110                                    qPos.add(value);
10111                            }
10112                    }
10113    
10114                    List<BlogsEntry> list = q.list();
10115    
10116                    if (list.size() == 2) {
10117                            return list.get(1);
10118                    }
10119                    else {
10120                            return null;
10121                    }
10122            }
10123    
10124            /**
10125             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10126             *
10127             * @param groupId the group ID
10128             * @param userId the user ID
10129             * @param status the status
10130             */
10131            @Override
10132            public void removeByG_U_S(long groupId, long userId, int status) {
10133                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10134                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10135                            remove(blogsEntry);
10136                    }
10137            }
10138    
10139            /**
10140             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10141             *
10142             * @param groupId the group ID
10143             * @param userId the user ID
10144             * @param status the status
10145             * @return the number of matching blogs entries
10146             */
10147            @Override
10148            public int countByG_U_S(long groupId, long userId, int status) {
10149                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10150    
10151                    Object[] finderArgs = new Object[] { groupId, userId, status };
10152    
10153                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10154                                    this);
10155    
10156                    if (count == null) {
10157                            StringBundler query = new StringBundler(4);
10158    
10159                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10160    
10161                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10162    
10163                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10164    
10165                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10166    
10167                            String sql = query.toString();
10168    
10169                            Session session = null;
10170    
10171                            try {
10172                                    session = openSession();
10173    
10174                                    Query q = session.createQuery(sql);
10175    
10176                                    QueryPos qPos = QueryPos.getInstance(q);
10177    
10178                                    qPos.add(groupId);
10179    
10180                                    qPos.add(userId);
10181    
10182                                    qPos.add(status);
10183    
10184                                    count = (Long)q.uniqueResult();
10185    
10186                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10187                            }
10188                            catch (Exception e) {
10189                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10190    
10191                                    throw processException(e);
10192                            }
10193                            finally {
10194                                    closeSession(session);
10195                            }
10196                    }
10197    
10198                    return count.intValue();
10199            }
10200    
10201            /**
10202             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10203             *
10204             * @param groupId the group ID
10205             * @param userId the user ID
10206             * @param status the status
10207             * @return the number of matching blogs entries that the user has permission to view
10208             */
10209            @Override
10210            public int filterCountByG_U_S(long groupId, long userId, int status) {
10211                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10212                            return countByG_U_S(groupId, userId, status);
10213                    }
10214    
10215                    StringBundler query = new StringBundler(4);
10216    
10217                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
10218    
10219                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10220    
10221                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10222    
10223                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10224    
10225                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10226                                    BlogsEntry.class.getName(),
10227                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10228    
10229                    Session session = null;
10230    
10231                    try {
10232                            session = openSession();
10233    
10234                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10235    
10236                            q.addScalar(COUNT_COLUMN_NAME,
10237                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10238    
10239                            QueryPos qPos = QueryPos.getInstance(q);
10240    
10241                            qPos.add(groupId);
10242    
10243                            qPos.add(userId);
10244    
10245                            qPos.add(status);
10246    
10247                            Long count = (Long)q.uniqueResult();
10248    
10249                            return count.intValue();
10250                    }
10251                    catch (Exception e) {
10252                            throw processException(e);
10253                    }
10254                    finally {
10255                            closeSession(session);
10256                    }
10257            }
10258    
10259            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
10260            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
10261            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
10262            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10263                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10264                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
10265                            new String[] {
10266                                    Long.class.getName(), Long.class.getName(),
10267                                    Integer.class.getName(),
10268                                    
10269                            Integer.class.getName(), Integer.class.getName(),
10270                                    OrderByComparator.class.getName()
10271                            });
10272            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
10273                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10274                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10275                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
10276                            new String[] {
10277                                    Long.class.getName(), Long.class.getName(),
10278                                    Integer.class.getName()
10279                            });
10280    
10281            /**
10282             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10283             *
10284             * @param groupId the group ID
10285             * @param userId the user ID
10286             * @param status the status
10287             * @return the matching blogs entries
10288             */
10289            @Override
10290            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
10291                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
10292                            QueryUtil.ALL_POS, null);
10293            }
10294    
10295            /**
10296             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10297             *
10298             * <p>
10299             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10300             * </p>
10301             *
10302             * @param groupId the group ID
10303             * @param userId the user ID
10304             * @param status the status
10305             * @param start the lower bound of the range of blogs entries
10306             * @param end the upper bound of the range of blogs entries (not inclusive)
10307             * @return the range of matching blogs entries
10308             */
10309            @Override
10310            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10311                    int status, int start, int end) {
10312                    return findByG_U_NotS(groupId, userId, status, start, end, null);
10313            }
10314    
10315            /**
10316             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10317             *
10318             * <p>
10319             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10320             * </p>
10321             *
10322             * @param groupId the group ID
10323             * @param userId the user ID
10324             * @param status the status
10325             * @param start the lower bound of the range of blogs entries
10326             * @param end the upper bound of the range of blogs entries (not inclusive)
10327             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10328             * @return the ordered range of matching blogs entries
10329             */
10330            @Override
10331            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10332                    int status, int start, int end,
10333                    OrderByComparator<BlogsEntry> orderByComparator) {
10334                    boolean pagination = true;
10335                    FinderPath finderPath = null;
10336                    Object[] finderArgs = null;
10337    
10338                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
10339                    finderArgs = new Object[] {
10340                                    groupId, userId, status,
10341                                    
10342                                    start, end, orderByComparator
10343                            };
10344    
10345                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10346                                    finderArgs, this);
10347    
10348                    if ((list != null) && !list.isEmpty()) {
10349                            for (BlogsEntry blogsEntry : list) {
10350                                    if ((groupId != blogsEntry.getGroupId()) ||
10351                                                    (userId != blogsEntry.getUserId()) ||
10352                                                    (status == blogsEntry.getStatus())) {
10353                                            list = null;
10354    
10355                                            break;
10356                                    }
10357                            }
10358                    }
10359    
10360                    if (list == null) {
10361                            StringBundler query = null;
10362    
10363                            if (orderByComparator != null) {
10364                                    query = new StringBundler(5 +
10365                                                    (orderByComparator.getOrderByFields().length * 3));
10366                            }
10367                            else {
10368                                    query = new StringBundler(5);
10369                            }
10370    
10371                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10372    
10373                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10374    
10375                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10376    
10377                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10378    
10379                            if (orderByComparator != null) {
10380                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10381                                            orderByComparator);
10382                            }
10383                            else
10384                             if (pagination) {
10385                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10386                            }
10387    
10388                            String sql = query.toString();
10389    
10390                            Session session = null;
10391    
10392                            try {
10393                                    session = openSession();
10394    
10395                                    Query q = session.createQuery(sql);
10396    
10397                                    QueryPos qPos = QueryPos.getInstance(q);
10398    
10399                                    qPos.add(groupId);
10400    
10401                                    qPos.add(userId);
10402    
10403                                    qPos.add(status);
10404    
10405                                    if (!pagination) {
10406                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10407                                                            start, end, false);
10408    
10409                                            Collections.sort(list);
10410    
10411                                            list = Collections.unmodifiableList(list);
10412                                    }
10413                                    else {
10414                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10415                                                            start, end);
10416                                    }
10417    
10418                                    cacheResult(list);
10419    
10420                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10421                            }
10422                            catch (Exception e) {
10423                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10424    
10425                                    throw processException(e);
10426                            }
10427                            finally {
10428                                    closeSession(session);
10429                            }
10430                    }
10431    
10432                    return list;
10433            }
10434    
10435            /**
10436             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10437             *
10438             * @param groupId the group ID
10439             * @param userId the user ID
10440             * @param status the status
10441             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10442             * @return the first matching blogs entry
10443             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10444             */
10445            @Override
10446            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
10447                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10448                    throws NoSuchEntryException {
10449                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
10450                                    orderByComparator);
10451    
10452                    if (blogsEntry != null) {
10453                            return blogsEntry;
10454                    }
10455    
10456                    StringBundler msg = new StringBundler(8);
10457    
10458                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10459    
10460                    msg.append("groupId=");
10461                    msg.append(groupId);
10462    
10463                    msg.append(", userId=");
10464                    msg.append(userId);
10465    
10466                    msg.append(", status=");
10467                    msg.append(status);
10468    
10469                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10470    
10471                    throw new NoSuchEntryException(msg.toString());
10472            }
10473    
10474            /**
10475             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10476             *
10477             * @param groupId the group ID
10478             * @param userId the user ID
10479             * @param status the status
10480             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10481             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10482             */
10483            @Override
10484            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
10485                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10486                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
10487                                    orderByComparator);
10488    
10489                    if (!list.isEmpty()) {
10490                            return list.get(0);
10491                    }
10492    
10493                    return null;
10494            }
10495    
10496            /**
10497             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10498             *
10499             * @param groupId the group ID
10500             * @param userId the user ID
10501             * @param status the status
10502             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10503             * @return the last matching blogs entry
10504             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
10505             */
10506            @Override
10507            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
10508                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10509                    throws NoSuchEntryException {
10510                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
10511                                    orderByComparator);
10512    
10513                    if (blogsEntry != null) {
10514                            return blogsEntry;
10515                    }
10516    
10517                    StringBundler msg = new StringBundler(8);
10518    
10519                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10520    
10521                    msg.append("groupId=");
10522                    msg.append(groupId);
10523    
10524                    msg.append(", userId=");
10525                    msg.append(userId);
10526    
10527                    msg.append(", status=");
10528                    msg.append(status);
10529    
10530                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10531    
10532                    throw new NoSuchEntryException(msg.toString());
10533            }
10534    
10535            /**
10536             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10537             *
10538             * @param groupId the group ID
10539             * @param userId the user ID
10540             * @param status the status
10541             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10542             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10543             */
10544            @Override
10545            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
10546                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10547                    int count = countByG_U_NotS(groupId, userId, status);
10548    
10549                    if (count == 0) {
10550                            return null;
10551                    }
10552    
10553                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
10554                                    count - 1, count, orderByComparator);
10555    
10556                    if (!list.isEmpty()) {
10557                            return list.get(0);
10558                    }
10559    
10560                    return null;
10561            }
10562    
10563            /**
10564             * 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;.
10565             *
10566             * @param entryId the primary key of the current blogs entry
10567             * @param groupId the group ID
10568             * @param userId the user ID
10569             * @param status the status
10570             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10571             * @return the previous, current, and next blogs entry
10572             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10573             */
10574            @Override
10575            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
10576                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10577                    throws NoSuchEntryException {
10578                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10579    
10580                    Session session = null;
10581    
10582                    try {
10583                            session = openSession();
10584    
10585                            BlogsEntry[] array = new BlogsEntryImpl[3];
10586    
10587                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10588                                            userId, status, orderByComparator, true);
10589    
10590                            array[1] = blogsEntry;
10591    
10592                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10593                                            userId, status, orderByComparator, false);
10594    
10595                            return array;
10596                    }
10597                    catch (Exception e) {
10598                            throw processException(e);
10599                    }
10600                    finally {
10601                            closeSession(session);
10602                    }
10603            }
10604    
10605            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
10606                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10607                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10608                    StringBundler query = null;
10609    
10610                    if (orderByComparator != null) {
10611                            query = new StringBundler(6 +
10612                                            (orderByComparator.getOrderByFields().length * 6));
10613                    }
10614                    else {
10615                            query = new StringBundler(3);
10616                    }
10617    
10618                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10619    
10620                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10621    
10622                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10623    
10624                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10625    
10626                    if (orderByComparator != null) {
10627                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10628    
10629                            if (orderByConditionFields.length > 0) {
10630                                    query.append(WHERE_AND);
10631                            }
10632    
10633                            for (int i = 0; i < orderByConditionFields.length; i++) {
10634                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10635                                    query.append(orderByConditionFields[i]);
10636    
10637                                    if ((i + 1) < orderByConditionFields.length) {
10638                                            if (orderByComparator.isAscending() ^ previous) {
10639                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10640                                            }
10641                                            else {
10642                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10643                                            }
10644                                    }
10645                                    else {
10646                                            if (orderByComparator.isAscending() ^ previous) {
10647                                                    query.append(WHERE_GREATER_THAN);
10648                                            }
10649                                            else {
10650                                                    query.append(WHERE_LESSER_THAN);
10651                                            }
10652                                    }
10653                            }
10654    
10655                            query.append(ORDER_BY_CLAUSE);
10656    
10657                            String[] orderByFields = orderByComparator.getOrderByFields();
10658    
10659                            for (int i = 0; i < orderByFields.length; i++) {
10660                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10661                                    query.append(orderByFields[i]);
10662    
10663                                    if ((i + 1) < orderByFields.length) {
10664                                            if (orderByComparator.isAscending() ^ previous) {
10665                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10666                                            }
10667                                            else {
10668                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10669                                            }
10670                                    }
10671                                    else {
10672                                            if (orderByComparator.isAscending() ^ previous) {
10673                                                    query.append(ORDER_BY_ASC);
10674                                            }
10675                                            else {
10676                                                    query.append(ORDER_BY_DESC);
10677                                            }
10678                                    }
10679                            }
10680                    }
10681                    else {
10682                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10683                    }
10684    
10685                    String sql = query.toString();
10686    
10687                    Query q = session.createQuery(sql);
10688    
10689                    q.setFirstResult(0);
10690                    q.setMaxResults(2);
10691    
10692                    QueryPos qPos = QueryPos.getInstance(q);
10693    
10694                    qPos.add(groupId);
10695    
10696                    qPos.add(userId);
10697    
10698                    qPos.add(status);
10699    
10700                    if (orderByComparator != null) {
10701                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10702    
10703                            for (Object value : values) {
10704                                    qPos.add(value);
10705                            }
10706                    }
10707    
10708                    List<BlogsEntry> list = q.list();
10709    
10710                    if (list.size() == 2) {
10711                            return list.get(1);
10712                    }
10713                    else {
10714                            return null;
10715                    }
10716            }
10717    
10718            /**
10719             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10720             *
10721             * @param groupId the group ID
10722             * @param userId the user ID
10723             * @param status the status
10724             * @return the matching blogs entries that the user has permission to view
10725             */
10726            @Override
10727            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
10728                    int status) {
10729                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
10730                            QueryUtil.ALL_POS, null);
10731            }
10732    
10733            /**
10734             * 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;.
10735             *
10736             * <p>
10737             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10738             * </p>
10739             *
10740             * @param groupId the group ID
10741             * @param userId the user ID
10742             * @param status the status
10743             * @param start the lower bound of the range of blogs entries
10744             * @param end the upper bound of the range of blogs entries (not inclusive)
10745             * @return the range of matching blogs entries that the user has permission to view
10746             */
10747            @Override
10748            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
10749                    int status, int start, int end) {
10750                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
10751            }
10752    
10753            /**
10754             * 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;.
10755             *
10756             * <p>
10757             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
10758             * </p>
10759             *
10760             * @param groupId the group ID
10761             * @param userId the user ID
10762             * @param status the status
10763             * @param start the lower bound of the range of blogs entries
10764             * @param end the upper bound of the range of blogs entries (not inclusive)
10765             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10766             * @return the ordered range of matching blogs entries that the user has permission to view
10767             */
10768            @Override
10769            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
10770                    int status, int start, int end,
10771                    OrderByComparator<BlogsEntry> orderByComparator) {
10772                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10773                            return findByG_U_NotS(groupId, userId, status, start, end,
10774                                    orderByComparator);
10775                    }
10776    
10777                    StringBundler query = null;
10778    
10779                    if (orderByComparator != null) {
10780                            query = new StringBundler(5 +
10781                                            (orderByComparator.getOrderByFields().length * 3));
10782                    }
10783                    else {
10784                            query = new StringBundler(5);
10785                    }
10786    
10787                    if (getDB().isSupportsInlineDistinct()) {
10788                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10789                    }
10790                    else {
10791                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10792                    }
10793    
10794                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10795    
10796                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10797    
10798                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10799    
10800                    if (!getDB().isSupportsInlineDistinct()) {
10801                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10802                    }
10803    
10804                    if (orderByComparator != null) {
10805                            if (getDB().isSupportsInlineDistinct()) {
10806                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10807                                            orderByComparator, true);
10808                            }
10809                            else {
10810                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10811                                            orderByComparator, true);
10812                            }
10813                    }
10814                    else {
10815                            if (getDB().isSupportsInlineDistinct()) {
10816                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10817                            }
10818                            else {
10819                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10820                            }
10821                    }
10822    
10823                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10824                                    BlogsEntry.class.getName(),
10825                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10826    
10827                    Session session = null;
10828    
10829                    try {
10830                            session = openSession();
10831    
10832                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10833    
10834                            if (getDB().isSupportsInlineDistinct()) {
10835                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10836                            }
10837                            else {
10838                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10839                            }
10840    
10841                            QueryPos qPos = QueryPos.getInstance(q);
10842    
10843                            qPos.add(groupId);
10844    
10845                            qPos.add(userId);
10846    
10847                            qPos.add(status);
10848    
10849                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10850                    }
10851                    catch (Exception e) {
10852                            throw processException(e);
10853                    }
10854                    finally {
10855                            closeSession(session);
10856                    }
10857            }
10858    
10859            /**
10860             * 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;.
10861             *
10862             * @param entryId the primary key of the current blogs entry
10863             * @param groupId the group ID
10864             * @param userId the user ID
10865             * @param status the status
10866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10867             * @return the previous, current, and next blogs entry
10868             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
10869             */
10870            @Override
10871            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
10872                    long groupId, long userId, int status,
10873                    OrderByComparator<BlogsEntry> orderByComparator)
10874                    throws NoSuchEntryException {
10875                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10876                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
10877                                    orderByComparator);
10878                    }
10879    
10880                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10881    
10882                    Session session = null;
10883    
10884                    try {
10885                            session = openSession();
10886    
10887                            BlogsEntry[] array = new BlogsEntryImpl[3];
10888    
10889                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
10890                                            groupId, userId, status, orderByComparator, true);
10891    
10892                            array[1] = blogsEntry;
10893    
10894                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
10895                                            groupId, userId, status, orderByComparator, false);
10896    
10897                            return array;
10898                    }
10899                    catch (Exception e) {
10900                            throw processException(e);
10901                    }
10902                    finally {
10903                            closeSession(session);
10904                    }
10905            }
10906    
10907            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
10908                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10909                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10910                    StringBundler query = null;
10911    
10912                    if (orderByComparator != null) {
10913                            query = new StringBundler(6 +
10914                                            (orderByComparator.getOrderByFields().length * 6));
10915                    }
10916                    else {
10917                            query = new StringBundler(3);
10918                    }
10919    
10920                    if (getDB().isSupportsInlineDistinct()) {
10921                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10922                    }
10923                    else {
10924                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10925                    }
10926    
10927                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10928    
10929                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10930    
10931                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10932    
10933                    if (!getDB().isSupportsInlineDistinct()) {
10934                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10935                    }
10936    
10937                    if (orderByComparator != null) {
10938                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10939    
10940                            if (orderByConditionFields.length > 0) {
10941                                    query.append(WHERE_AND);
10942                            }
10943    
10944                            for (int i = 0; i < orderByConditionFields.length; i++) {
10945                                    if (getDB().isSupportsInlineDistinct()) {
10946                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10947                                    }
10948                                    else {
10949                                            query.append(_ORDER_BY_ENTITY_TABLE);
10950                                    }
10951    
10952                                    query.append(orderByConditionFields[i]);
10953    
10954                                    if ((i + 1) < orderByConditionFields.length) {
10955                                            if (orderByComparator.isAscending() ^ previous) {
10956                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10957                                            }
10958                                            else {
10959                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10960                                            }
10961                                    }
10962                                    else {
10963                                            if (orderByComparator.isAscending() ^ previous) {
10964                                                    query.append(WHERE_GREATER_THAN);
10965                                            }
10966                                            else {
10967                                                    query.append(WHERE_LESSER_THAN);
10968                                            }
10969                                    }
10970                            }
10971    
10972                            query.append(ORDER_BY_CLAUSE);
10973    
10974                            String[] orderByFields = orderByComparator.getOrderByFields();
10975    
10976                            for (int i = 0; i < orderByFields.length; i++) {
10977                                    if (getDB().isSupportsInlineDistinct()) {
10978                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10979                                    }
10980                                    else {
10981                                            query.append(_ORDER_BY_ENTITY_TABLE);
10982                                    }
10983    
10984                                    query.append(orderByFields[i]);
10985    
10986                                    if ((i + 1) < orderByFields.length) {
10987                                            if (orderByComparator.isAscending() ^ previous) {
10988                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10989                                            }
10990                                            else {
10991                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10992                                            }
10993                                    }
10994                                    else {
10995                                            if (orderByComparator.isAscending() ^ previous) {
10996                                                    query.append(ORDER_BY_ASC);
10997                                            }
10998                                            else {
10999                                                    query.append(ORDER_BY_DESC);
11000                                            }
11001                                    }
11002                            }
11003                    }
11004                    else {
11005                            if (getDB().isSupportsInlineDistinct()) {
11006                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11007                            }
11008                            else {
11009                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11010                            }
11011                    }
11012    
11013                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11014                                    BlogsEntry.class.getName(),
11015                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11016    
11017                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11018    
11019                    q.setFirstResult(0);
11020                    q.setMaxResults(2);
11021    
11022                    if (getDB().isSupportsInlineDistinct()) {
11023                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11024                    }
11025                    else {
11026                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11027                    }
11028    
11029                    QueryPos qPos = QueryPos.getInstance(q);
11030    
11031                    qPos.add(groupId);
11032    
11033                    qPos.add(userId);
11034    
11035                    qPos.add(status);
11036    
11037                    if (orderByComparator != null) {
11038                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11039    
11040                            for (Object value : values) {
11041                                    qPos.add(value);
11042                            }
11043                    }
11044    
11045                    List<BlogsEntry> list = q.list();
11046    
11047                    if (list.size() == 2) {
11048                            return list.get(1);
11049                    }
11050                    else {
11051                            return null;
11052                    }
11053            }
11054    
11055            /**
11056             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
11057             *
11058             * @param groupId the group ID
11059             * @param userId the user ID
11060             * @param status the status
11061             */
11062            @Override
11063            public void removeByG_U_NotS(long groupId, long userId, int status) {
11064                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
11065                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11066                            remove(blogsEntry);
11067                    }
11068            }
11069    
11070            /**
11071             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11072             *
11073             * @param groupId the group ID
11074             * @param userId the user ID
11075             * @param status the status
11076             * @return the number of matching blogs entries
11077             */
11078            @Override
11079            public int countByG_U_NotS(long groupId, long userId, int status) {
11080                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
11081    
11082                    Object[] finderArgs = new Object[] { groupId, userId, status };
11083    
11084                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11085                                    this);
11086    
11087                    if (count == null) {
11088                            StringBundler query = new StringBundler(4);
11089    
11090                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11091    
11092                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11093    
11094                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11095    
11096                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11097    
11098                            String sql = query.toString();
11099    
11100                            Session session = null;
11101    
11102                            try {
11103                                    session = openSession();
11104    
11105                                    Query q = session.createQuery(sql);
11106    
11107                                    QueryPos qPos = QueryPos.getInstance(q);
11108    
11109                                    qPos.add(groupId);
11110    
11111                                    qPos.add(userId);
11112    
11113                                    qPos.add(status);
11114    
11115                                    count = (Long)q.uniqueResult();
11116    
11117                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11118                            }
11119                            catch (Exception e) {
11120                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11121    
11122                                    throw processException(e);
11123                            }
11124                            finally {
11125                                    closeSession(session);
11126                            }
11127                    }
11128    
11129                    return count.intValue();
11130            }
11131    
11132            /**
11133             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11134             *
11135             * @param groupId the group ID
11136             * @param userId the user ID
11137             * @param status the status
11138             * @return the number of matching blogs entries that the user has permission to view
11139             */
11140            @Override
11141            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
11142                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11143                            return countByG_U_NotS(groupId, userId, status);
11144                    }
11145    
11146                    StringBundler query = new StringBundler(4);
11147    
11148                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11149    
11150                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11151    
11152                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11153    
11154                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11155    
11156                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11157                                    BlogsEntry.class.getName(),
11158                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11159    
11160                    Session session = null;
11161    
11162                    try {
11163                            session = openSession();
11164    
11165                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11166    
11167                            q.addScalar(COUNT_COLUMN_NAME,
11168                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11169    
11170                            QueryPos qPos = QueryPos.getInstance(q);
11171    
11172                            qPos.add(groupId);
11173    
11174                            qPos.add(userId);
11175    
11176                            qPos.add(status);
11177    
11178                            Long count = (Long)q.uniqueResult();
11179    
11180                            return count.intValue();
11181                    }
11182                    catch (Exception e) {
11183                            throw processException(e);
11184                    }
11185                    finally {
11186                            closeSession(session);
11187                    }
11188            }
11189    
11190            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11191            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
11192            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
11193            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11194                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11195                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
11196                            new String[] {
11197                                    Long.class.getName(), Date.class.getName(),
11198                                    Integer.class.getName(),
11199                                    
11200                            Integer.class.getName(), Integer.class.getName(),
11201                                    OrderByComparator.class.getName()
11202                            });
11203            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11204                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11205                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
11206                            new String[] {
11207                                    Long.class.getName(), Date.class.getName(),
11208                                    Integer.class.getName()
11209                            });
11210    
11211            /**
11212             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11213             *
11214             * @param groupId the group ID
11215             * @param displayDate the display date
11216             * @param status the status
11217             * @return the matching blogs entries
11218             */
11219            @Override
11220            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11221                    int status) {
11222                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
11223                            QueryUtil.ALL_POS, null);
11224            }
11225    
11226            /**
11227             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11228             *
11229             * <p>
11230             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11231             * </p>
11232             *
11233             * @param groupId the group ID
11234             * @param displayDate the display date
11235             * @param status the status
11236             * @param start the lower bound of the range of blogs entries
11237             * @param end the upper bound of the range of blogs entries (not inclusive)
11238             * @return the range of matching blogs entries
11239             */
11240            @Override
11241            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11242                    int status, int start, int end) {
11243                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
11244            }
11245    
11246            /**
11247             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11248             *
11249             * <p>
11250             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11251             * </p>
11252             *
11253             * @param groupId the group ID
11254             * @param displayDate the display date
11255             * @param status the status
11256             * @param start the lower bound of the range of blogs entries
11257             * @param end the upper bound of the range of blogs entries (not inclusive)
11258             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11259             * @return the ordered range of matching blogs entries
11260             */
11261            @Override
11262            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11263                    int status, int start, int end,
11264                    OrderByComparator<BlogsEntry> orderByComparator) {
11265                    boolean pagination = true;
11266                    FinderPath finderPath = null;
11267                    Object[] finderArgs = null;
11268    
11269                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
11270                    finderArgs = new Object[] {
11271                                    groupId, displayDate, status,
11272                                    
11273                                    start, end, orderByComparator
11274                            };
11275    
11276                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11277                                    finderArgs, this);
11278    
11279                    if ((list != null) && !list.isEmpty()) {
11280                            for (BlogsEntry blogsEntry : list) {
11281                                    if ((groupId != blogsEntry.getGroupId()) ||
11282                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
11283                                                                                                                                    .getTime()) ||
11284                                                    (status != blogsEntry.getStatus())) {
11285                                            list = null;
11286    
11287                                            break;
11288                                    }
11289                            }
11290                    }
11291    
11292                    if (list == null) {
11293                            StringBundler query = null;
11294    
11295                            if (orderByComparator != null) {
11296                                    query = new StringBundler(5 +
11297                                                    (orderByComparator.getOrderByFields().length * 3));
11298                            }
11299                            else {
11300                                    query = new StringBundler(5);
11301                            }
11302    
11303                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11304    
11305                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11306    
11307                            boolean bindDisplayDate = false;
11308    
11309                            if (displayDate == null) {
11310                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11311                            }
11312                            else {
11313                                    bindDisplayDate = true;
11314    
11315                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11316                            }
11317    
11318                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11319    
11320                            if (orderByComparator != null) {
11321                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11322                                            orderByComparator);
11323                            }
11324                            else
11325                             if (pagination) {
11326                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11327                            }
11328    
11329                            String sql = query.toString();
11330    
11331                            Session session = null;
11332    
11333                            try {
11334                                    session = openSession();
11335    
11336                                    Query q = session.createQuery(sql);
11337    
11338                                    QueryPos qPos = QueryPos.getInstance(q);
11339    
11340                                    qPos.add(groupId);
11341    
11342                                    if (bindDisplayDate) {
11343                                            qPos.add(new Timestamp(displayDate.getTime()));
11344                                    }
11345    
11346                                    qPos.add(status);
11347    
11348                                    if (!pagination) {
11349                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11350                                                            start, end, false);
11351    
11352                                            Collections.sort(list);
11353    
11354                                            list = Collections.unmodifiableList(list);
11355                                    }
11356                                    else {
11357                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11358                                                            start, end);
11359                                    }
11360    
11361                                    cacheResult(list);
11362    
11363                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11364                            }
11365                            catch (Exception e) {
11366                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11367    
11368                                    throw processException(e);
11369                            }
11370                            finally {
11371                                    closeSession(session);
11372                            }
11373                    }
11374    
11375                    return list;
11376            }
11377    
11378            /**
11379             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11380             *
11381             * @param groupId the group ID
11382             * @param displayDate the display date
11383             * @param status the status
11384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11385             * @return the first matching blogs entry
11386             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11387             */
11388            @Override
11389            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
11390                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11391                    throws NoSuchEntryException {
11392                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
11393                                    status, orderByComparator);
11394    
11395                    if (blogsEntry != null) {
11396                            return blogsEntry;
11397                    }
11398    
11399                    StringBundler msg = new StringBundler(8);
11400    
11401                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11402    
11403                    msg.append("groupId=");
11404                    msg.append(groupId);
11405    
11406                    msg.append(", displayDate=");
11407                    msg.append(displayDate);
11408    
11409                    msg.append(", status=");
11410                    msg.append(status);
11411    
11412                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11413    
11414                    throw new NoSuchEntryException(msg.toString());
11415            }
11416    
11417            /**
11418             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11419             *
11420             * @param groupId the group ID
11421             * @param displayDate the display date
11422             * @param status the status
11423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11424             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11425             */
11426            @Override
11427            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
11428                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11429                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
11430                                    1, orderByComparator);
11431    
11432                    if (!list.isEmpty()) {
11433                            return list.get(0);
11434                    }
11435    
11436                    return null;
11437            }
11438    
11439            /**
11440             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11441             *
11442             * @param groupId the group ID
11443             * @param displayDate the display date
11444             * @param status the status
11445             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11446             * @return the last matching blogs entry
11447             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
11448             */
11449            @Override
11450            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
11451                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11452                    throws NoSuchEntryException {
11453                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
11454                                    status, orderByComparator);
11455    
11456                    if (blogsEntry != null) {
11457                            return blogsEntry;
11458                    }
11459    
11460                    StringBundler msg = new StringBundler(8);
11461    
11462                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11463    
11464                    msg.append("groupId=");
11465                    msg.append(groupId);
11466    
11467                    msg.append(", displayDate=");
11468                    msg.append(displayDate);
11469    
11470                    msg.append(", status=");
11471                    msg.append(status);
11472    
11473                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11474    
11475                    throw new NoSuchEntryException(msg.toString());
11476            }
11477    
11478            /**
11479             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11480             *
11481             * @param groupId the group ID
11482             * @param displayDate the display date
11483             * @param status the status
11484             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11485             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11486             */
11487            @Override
11488            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
11489                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11490                    int count = countByG_LtD_S(groupId, displayDate, status);
11491    
11492                    if (count == 0) {
11493                            return null;
11494                    }
11495    
11496                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
11497                                    count - 1, count, orderByComparator);
11498    
11499                    if (!list.isEmpty()) {
11500                            return list.get(0);
11501                    }
11502    
11503                    return null;
11504            }
11505    
11506            /**
11507             * 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;.
11508             *
11509             * @param entryId the primary key of the current blogs entry
11510             * @param groupId the group ID
11511             * @param displayDate the display date
11512             * @param status the status
11513             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11514             * @return the previous, current, and next blogs entry
11515             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11516             */
11517            @Override
11518            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
11519                    Date displayDate, int status,
11520                    OrderByComparator<BlogsEntry> orderByComparator)
11521                    throws NoSuchEntryException {
11522                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11523    
11524                    Session session = null;
11525    
11526                    try {
11527                            session = openSession();
11528    
11529                            BlogsEntry[] array = new BlogsEntryImpl[3];
11530    
11531                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11532                                            displayDate, status, orderByComparator, true);
11533    
11534                            array[1] = blogsEntry;
11535    
11536                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11537                                            displayDate, status, orderByComparator, false);
11538    
11539                            return array;
11540                    }
11541                    catch (Exception e) {
11542                            throw processException(e);
11543                    }
11544                    finally {
11545                            closeSession(session);
11546                    }
11547            }
11548    
11549            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
11550                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
11551                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11552                    StringBundler query = null;
11553    
11554                    if (orderByComparator != null) {
11555                            query = new StringBundler(6 +
11556                                            (orderByComparator.getOrderByFields().length * 6));
11557                    }
11558                    else {
11559                            query = new StringBundler(3);
11560                    }
11561    
11562                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11563    
11564                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11565    
11566                    boolean bindDisplayDate = false;
11567    
11568                    if (displayDate == null) {
11569                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11570                    }
11571                    else {
11572                            bindDisplayDate = true;
11573    
11574                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11575                    }
11576    
11577                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11578    
11579                    if (orderByComparator != null) {
11580                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11581    
11582                            if (orderByConditionFields.length > 0) {
11583                                    query.append(WHERE_AND);
11584                            }
11585    
11586                            for (int i = 0; i < orderByConditionFields.length; i++) {
11587                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11588                                    query.append(orderByConditionFields[i]);
11589    
11590                                    if ((i + 1) < orderByConditionFields.length) {
11591                                            if (orderByComparator.isAscending() ^ previous) {
11592                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11593                                            }
11594                                            else {
11595                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11596                                            }
11597                                    }
11598                                    else {
11599                                            if (orderByComparator.isAscending() ^ previous) {
11600                                                    query.append(WHERE_GREATER_THAN);
11601                                            }
11602                                            else {
11603                                                    query.append(WHERE_LESSER_THAN);
11604                                            }
11605                                    }
11606                            }
11607    
11608                            query.append(ORDER_BY_CLAUSE);
11609    
11610                            String[] orderByFields = orderByComparator.getOrderByFields();
11611    
11612                            for (int i = 0; i < orderByFields.length; i++) {
11613                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11614                                    query.append(orderByFields[i]);
11615    
11616                                    if ((i + 1) < orderByFields.length) {
11617                                            if (orderByComparator.isAscending() ^ previous) {
11618                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11619                                            }
11620                                            else {
11621                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11622                                            }
11623                                    }
11624                                    else {
11625                                            if (orderByComparator.isAscending() ^ previous) {
11626                                                    query.append(ORDER_BY_ASC);
11627                                            }
11628                                            else {
11629                                                    query.append(ORDER_BY_DESC);
11630                                            }
11631                                    }
11632                            }
11633                    }
11634                    else {
11635                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11636                    }
11637    
11638                    String sql = query.toString();
11639    
11640                    Query q = session.createQuery(sql);
11641    
11642                    q.setFirstResult(0);
11643                    q.setMaxResults(2);
11644    
11645                    QueryPos qPos = QueryPos.getInstance(q);
11646    
11647                    qPos.add(groupId);
11648    
11649                    if (bindDisplayDate) {
11650                            qPos.add(new Timestamp(displayDate.getTime()));
11651                    }
11652    
11653                    qPos.add(status);
11654    
11655                    if (orderByComparator != null) {
11656                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11657    
11658                            for (Object value : values) {
11659                                    qPos.add(value);
11660                            }
11661                    }
11662    
11663                    List<BlogsEntry> list = q.list();
11664    
11665                    if (list.size() == 2) {
11666                            return list.get(1);
11667                    }
11668                    else {
11669                            return null;
11670                    }
11671            }
11672    
11673            /**
11674             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11675             *
11676             * @param groupId the group ID
11677             * @param displayDate the display date
11678             * @param status the status
11679             * @return the matching blogs entries that the user has permission to view
11680             */
11681            @Override
11682            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
11683                    int status) {
11684                    return filterFindByG_LtD_S(groupId, displayDate, status,
11685                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11686            }
11687    
11688            /**
11689             * 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;.
11690             *
11691             * <p>
11692             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11693             * </p>
11694             *
11695             * @param groupId the group ID
11696             * @param displayDate the display date
11697             * @param status the status
11698             * @param start the lower bound of the range of blogs entries
11699             * @param end the upper bound of the range of blogs entries (not inclusive)
11700             * @return the range of matching blogs entries that the user has permission to view
11701             */
11702            @Override
11703            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
11704                    int status, int start, int end) {
11705                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
11706                            null);
11707            }
11708    
11709            /**
11710             * 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;.
11711             *
11712             * <p>
11713             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
11714             * </p>
11715             *
11716             * @param groupId the group ID
11717             * @param displayDate the display date
11718             * @param status the status
11719             * @param start the lower bound of the range of blogs entries
11720             * @param end the upper bound of the range of blogs entries (not inclusive)
11721             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11722             * @return the ordered range of matching blogs entries that the user has permission to view
11723             */
11724            @Override
11725            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
11726                    int status, int start, int end,
11727                    OrderByComparator<BlogsEntry> orderByComparator) {
11728                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11729                            return findByG_LtD_S(groupId, displayDate, status, start, end,
11730                                    orderByComparator);
11731                    }
11732    
11733                    StringBundler query = null;
11734    
11735                    if (orderByComparator != null) {
11736                            query = new StringBundler(5 +
11737                                            (orderByComparator.getOrderByFields().length * 3));
11738                    }
11739                    else {
11740                            query = new StringBundler(5);
11741                    }
11742    
11743                    if (getDB().isSupportsInlineDistinct()) {
11744                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11745                    }
11746                    else {
11747                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11748                    }
11749    
11750                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11751    
11752                    boolean bindDisplayDate = false;
11753    
11754                    if (displayDate == null) {
11755                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11756                    }
11757                    else {
11758                            bindDisplayDate = true;
11759    
11760                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11761                    }
11762    
11763                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11764    
11765                    if (!getDB().isSupportsInlineDistinct()) {
11766                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11767                    }
11768    
11769                    if (orderByComparator != null) {
11770                            if (getDB().isSupportsInlineDistinct()) {
11771                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11772                                            orderByComparator, true);
11773                            }
11774                            else {
11775                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11776                                            orderByComparator, true);
11777                            }
11778                    }
11779                    else {
11780                            if (getDB().isSupportsInlineDistinct()) {
11781                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11782                            }
11783                            else {
11784                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11785                            }
11786                    }
11787    
11788                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11789                                    BlogsEntry.class.getName(),
11790                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11791    
11792                    Session session = null;
11793    
11794                    try {
11795                            session = openSession();
11796    
11797                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11798    
11799                            if (getDB().isSupportsInlineDistinct()) {
11800                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11801                            }
11802                            else {
11803                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11804                            }
11805    
11806                            QueryPos qPos = QueryPos.getInstance(q);
11807    
11808                            qPos.add(groupId);
11809    
11810                            if (bindDisplayDate) {
11811                                    qPos.add(new Timestamp(displayDate.getTime()));
11812                            }
11813    
11814                            qPos.add(status);
11815    
11816                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11817                    }
11818                    catch (Exception e) {
11819                            throw processException(e);
11820                    }
11821                    finally {
11822                            closeSession(session);
11823                    }
11824            }
11825    
11826            /**
11827             * 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;.
11828             *
11829             * @param entryId the primary key of the current blogs entry
11830             * @param groupId the group ID
11831             * @param displayDate the display date
11832             * @param status the status
11833             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11834             * @return the previous, current, and next blogs entry
11835             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
11836             */
11837            @Override
11838            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
11839                    long groupId, Date displayDate, int status,
11840                    OrderByComparator<BlogsEntry> orderByComparator)
11841                    throws NoSuchEntryException {
11842                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11843                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
11844                                    status, orderByComparator);
11845                    }
11846    
11847                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11848    
11849                    Session session = null;
11850    
11851                    try {
11852                            session = openSession();
11853    
11854                            BlogsEntry[] array = new BlogsEntryImpl[3];
11855    
11856                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
11857                                            groupId, displayDate, status, orderByComparator, true);
11858    
11859                            array[1] = blogsEntry;
11860    
11861                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
11862                                            groupId, displayDate, status, orderByComparator, false);
11863    
11864                            return array;
11865                    }
11866                    catch (Exception e) {
11867                            throw processException(e);
11868                    }
11869                    finally {
11870                            closeSession(session);
11871                    }
11872            }
11873    
11874            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
11875                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
11876                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11877                    StringBundler query = null;
11878    
11879                    if (orderByComparator != null) {
11880                            query = new StringBundler(6 +
11881                                            (orderByComparator.getOrderByFields().length * 6));
11882                    }
11883                    else {
11884                            query = new StringBundler(3);
11885                    }
11886    
11887                    if (getDB().isSupportsInlineDistinct()) {
11888                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11889                    }
11890                    else {
11891                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11892                    }
11893    
11894                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11895    
11896                    boolean bindDisplayDate = false;
11897    
11898                    if (displayDate == null) {
11899                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11900                    }
11901                    else {
11902                            bindDisplayDate = true;
11903    
11904                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11905                    }
11906    
11907                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11908    
11909                    if (!getDB().isSupportsInlineDistinct()) {
11910                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11911                    }
11912    
11913                    if (orderByComparator != null) {
11914                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11915    
11916                            if (orderByConditionFields.length > 0) {
11917                                    query.append(WHERE_AND);
11918                            }
11919    
11920                            for (int i = 0; i < orderByConditionFields.length; i++) {
11921                                    if (getDB().isSupportsInlineDistinct()) {
11922                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11923                                    }
11924                                    else {
11925                                            query.append(_ORDER_BY_ENTITY_TABLE);
11926                                    }
11927    
11928                                    query.append(orderByConditionFields[i]);
11929    
11930                                    if ((i + 1) < orderByConditionFields.length) {
11931                                            if (orderByComparator.isAscending() ^ previous) {
11932                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11933                                            }
11934                                            else {
11935                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11936                                            }
11937                                    }
11938                                    else {
11939                                            if (orderByComparator.isAscending() ^ previous) {
11940                                                    query.append(WHERE_GREATER_THAN);
11941                                            }
11942                                            else {
11943                                                    query.append(WHERE_LESSER_THAN);
11944                                            }
11945                                    }
11946                            }
11947    
11948                            query.append(ORDER_BY_CLAUSE);
11949    
11950                            String[] orderByFields = orderByComparator.getOrderByFields();
11951    
11952                            for (int i = 0; i < orderByFields.length; i++) {
11953                                    if (getDB().isSupportsInlineDistinct()) {
11954                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11955                                    }
11956                                    else {
11957                                            query.append(_ORDER_BY_ENTITY_TABLE);
11958                                    }
11959    
11960                                    query.append(orderByFields[i]);
11961    
11962                                    if ((i + 1) < orderByFields.length) {
11963                                            if (orderByComparator.isAscending() ^ previous) {
11964                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11965                                            }
11966                                            else {
11967                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11968                                            }
11969                                    }
11970                                    else {
11971                                            if (orderByComparator.isAscending() ^ previous) {
11972                                                    query.append(ORDER_BY_ASC);
11973                                            }
11974                                            else {
11975                                                    query.append(ORDER_BY_DESC);
11976                                            }
11977                                    }
11978                            }
11979                    }
11980                    else {
11981                            if (getDB().isSupportsInlineDistinct()) {
11982                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11983                            }
11984                            else {
11985                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11986                            }
11987                    }
11988    
11989                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11990                                    BlogsEntry.class.getName(),
11991                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11992    
11993                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11994    
11995                    q.setFirstResult(0);
11996                    q.setMaxResults(2);
11997    
11998                    if (getDB().isSupportsInlineDistinct()) {
11999                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12000                    }
12001                    else {
12002                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12003                    }
12004    
12005                    QueryPos qPos = QueryPos.getInstance(q);
12006    
12007                    qPos.add(groupId);
12008    
12009                    if (bindDisplayDate) {
12010                            qPos.add(new Timestamp(displayDate.getTime()));
12011                    }
12012    
12013                    qPos.add(status);
12014    
12015                    if (orderByComparator != null) {
12016                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12017    
12018                            for (Object value : values) {
12019                                    qPos.add(value);
12020                            }
12021                    }
12022    
12023                    List<BlogsEntry> list = q.list();
12024    
12025                    if (list.size() == 2) {
12026                            return list.get(1);
12027                    }
12028                    else {
12029                            return null;
12030                    }
12031            }
12032    
12033            /**
12034             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
12035             *
12036             * @param groupId the group ID
12037             * @param displayDate the display date
12038             * @param status the status
12039             */
12040            @Override
12041            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
12042                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
12043                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12044                            remove(blogsEntry);
12045                    }
12046            }
12047    
12048            /**
12049             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12050             *
12051             * @param groupId the group ID
12052             * @param displayDate the display date
12053             * @param status the status
12054             * @return the number of matching blogs entries
12055             */
12056            @Override
12057            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
12058                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
12059    
12060                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
12061    
12062                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12063                                    this);
12064    
12065                    if (count == null) {
12066                            StringBundler query = new StringBundler(4);
12067    
12068                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12069    
12070                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12071    
12072                            boolean bindDisplayDate = false;
12073    
12074                            if (displayDate == null) {
12075                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12076                            }
12077                            else {
12078                                    bindDisplayDate = true;
12079    
12080                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12081                            }
12082    
12083                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12084    
12085                            String sql = query.toString();
12086    
12087                            Session session = null;
12088    
12089                            try {
12090                                    session = openSession();
12091    
12092                                    Query q = session.createQuery(sql);
12093    
12094                                    QueryPos qPos = QueryPos.getInstance(q);
12095    
12096                                    qPos.add(groupId);
12097    
12098                                    if (bindDisplayDate) {
12099                                            qPos.add(new Timestamp(displayDate.getTime()));
12100                                    }
12101    
12102                                    qPos.add(status);
12103    
12104                                    count = (Long)q.uniqueResult();
12105    
12106                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12107                            }
12108                            catch (Exception e) {
12109                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12110    
12111                                    throw processException(e);
12112                            }
12113                            finally {
12114                                    closeSession(session);
12115                            }
12116                    }
12117    
12118                    return count.intValue();
12119            }
12120    
12121            /**
12122             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12123             *
12124             * @param groupId the group ID
12125             * @param displayDate the display date
12126             * @param status the status
12127             * @return the number of matching blogs entries that the user has permission to view
12128             */
12129            @Override
12130            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
12131                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12132                            return countByG_LtD_S(groupId, displayDate, status);
12133                    }
12134    
12135                    StringBundler query = new StringBundler(4);
12136    
12137                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12138    
12139                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12140    
12141                    boolean bindDisplayDate = false;
12142    
12143                    if (displayDate == null) {
12144                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12145                    }
12146                    else {
12147                            bindDisplayDate = true;
12148    
12149                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12150                    }
12151    
12152                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12153    
12154                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12155                                    BlogsEntry.class.getName(),
12156                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12157    
12158                    Session session = null;
12159    
12160                    try {
12161                            session = openSession();
12162    
12163                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12164    
12165                            q.addScalar(COUNT_COLUMN_NAME,
12166                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12167    
12168                            QueryPos qPos = QueryPos.getInstance(q);
12169    
12170                            qPos.add(groupId);
12171    
12172                            if (bindDisplayDate) {
12173                                    qPos.add(new Timestamp(displayDate.getTime()));
12174                            }
12175    
12176                            qPos.add(status);
12177    
12178                            Long count = (Long)q.uniqueResult();
12179    
12180                            return count.intValue();
12181                    }
12182                    catch (Exception e) {
12183                            throw processException(e);
12184                    }
12185                    finally {
12186                            closeSession(session);
12187                    }
12188            }
12189    
12190            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12191            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
12192            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12193            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12194            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
12195                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12196                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12197                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
12198                            new String[] {
12199                                    Long.class.getName(), Date.class.getName(),
12200                                    Integer.class.getName(),
12201                                    
12202                            Integer.class.getName(), Integer.class.getName(),
12203                                    OrderByComparator.class.getName()
12204                            });
12205            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
12206                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12207                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12208                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
12209                            new String[] {
12210                                    Long.class.getName(), Date.class.getName(),
12211                                    Integer.class.getName()
12212                            });
12213    
12214            /**
12215             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12216             *
12217             * @param groupId the group ID
12218             * @param displayDate the display date
12219             * @param status the status
12220             * @return the matching blogs entries
12221             */
12222            @Override
12223            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12224                    int status) {
12225                    return findByG_LtD_NotS(groupId, displayDate, status,
12226                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12227            }
12228    
12229            /**
12230             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12231             *
12232             * <p>
12233             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12234             * </p>
12235             *
12236             * @param groupId the group ID
12237             * @param displayDate the display date
12238             * @param status the status
12239             * @param start the lower bound of the range of blogs entries
12240             * @param end the upper bound of the range of blogs entries (not inclusive)
12241             * @return the range of matching blogs entries
12242             */
12243            @Override
12244            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12245                    int status, int start, int end) {
12246                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
12247            }
12248    
12249            /**
12250             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12251             *
12252             * <p>
12253             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12254             * </p>
12255             *
12256             * @param groupId the group ID
12257             * @param displayDate the display date
12258             * @param status the status
12259             * @param start the lower bound of the range of blogs entries
12260             * @param end the upper bound of the range of blogs entries (not inclusive)
12261             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12262             * @return the ordered range of matching blogs entries
12263             */
12264            @Override
12265            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12266                    int status, int start, int end,
12267                    OrderByComparator<BlogsEntry> orderByComparator) {
12268                    boolean pagination = true;
12269                    FinderPath finderPath = null;
12270                    Object[] finderArgs = null;
12271    
12272                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
12273                    finderArgs = new Object[] {
12274                                    groupId, displayDate, status,
12275                                    
12276                                    start, end, orderByComparator
12277                            };
12278    
12279                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
12280                                    finderArgs, this);
12281    
12282                    if ((list != null) && !list.isEmpty()) {
12283                            for (BlogsEntry blogsEntry : list) {
12284                                    if ((groupId != blogsEntry.getGroupId()) ||
12285                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
12286                                                                                                                                    .getTime()) ||
12287                                                    (status == blogsEntry.getStatus())) {
12288                                            list = null;
12289    
12290                                            break;
12291                                    }
12292                            }
12293                    }
12294    
12295                    if (list == null) {
12296                            StringBundler query = null;
12297    
12298                            if (orderByComparator != null) {
12299                                    query = new StringBundler(5 +
12300                                                    (orderByComparator.getOrderByFields().length * 3));
12301                            }
12302                            else {
12303                                    query = new StringBundler(5);
12304                            }
12305    
12306                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12307    
12308                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12309    
12310                            boolean bindDisplayDate = false;
12311    
12312                            if (displayDate == null) {
12313                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12314                            }
12315                            else {
12316                                    bindDisplayDate = true;
12317    
12318                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12319                            }
12320    
12321                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12322    
12323                            if (orderByComparator != null) {
12324                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12325                                            orderByComparator);
12326                            }
12327                            else
12328                             if (pagination) {
12329                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12330                            }
12331    
12332                            String sql = query.toString();
12333    
12334                            Session session = null;
12335    
12336                            try {
12337                                    session = openSession();
12338    
12339                                    Query q = session.createQuery(sql);
12340    
12341                                    QueryPos qPos = QueryPos.getInstance(q);
12342    
12343                                    qPos.add(groupId);
12344    
12345                                    if (bindDisplayDate) {
12346                                            qPos.add(new Timestamp(displayDate.getTime()));
12347                                    }
12348    
12349                                    qPos.add(status);
12350    
12351                                    if (!pagination) {
12352                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12353                                                            start, end, false);
12354    
12355                                            Collections.sort(list);
12356    
12357                                            list = Collections.unmodifiableList(list);
12358                                    }
12359                                    else {
12360                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12361                                                            start, end);
12362                                    }
12363    
12364                                    cacheResult(list);
12365    
12366                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12367                            }
12368                            catch (Exception e) {
12369                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12370    
12371                                    throw processException(e);
12372                            }
12373                            finally {
12374                                    closeSession(session);
12375                            }
12376                    }
12377    
12378                    return list;
12379            }
12380    
12381            /**
12382             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12383             *
12384             * @param groupId the group ID
12385             * @param displayDate the display date
12386             * @param status the status
12387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12388             * @return the first matching blogs entry
12389             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12390             */
12391            @Override
12392            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
12393                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12394                    throws NoSuchEntryException {
12395                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
12396                                    status, orderByComparator);
12397    
12398                    if (blogsEntry != null) {
12399                            return blogsEntry;
12400                    }
12401    
12402                    StringBundler msg = new StringBundler(8);
12403    
12404                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12405    
12406                    msg.append("groupId=");
12407                    msg.append(groupId);
12408    
12409                    msg.append(", displayDate=");
12410                    msg.append(displayDate);
12411    
12412                    msg.append(", status=");
12413                    msg.append(status);
12414    
12415                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12416    
12417                    throw new NoSuchEntryException(msg.toString());
12418            }
12419    
12420            /**
12421             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12422             *
12423             * @param groupId the group ID
12424             * @param displayDate the display date
12425             * @param status the status
12426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12427             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12428             */
12429            @Override
12430            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
12431                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12432                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12433                                    0, 1, orderByComparator);
12434    
12435                    if (!list.isEmpty()) {
12436                            return list.get(0);
12437                    }
12438    
12439                    return null;
12440            }
12441    
12442            /**
12443             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12444             *
12445             * @param groupId the group ID
12446             * @param displayDate the display date
12447             * @param status the status
12448             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12449             * @return the last matching blogs entry
12450             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
12451             */
12452            @Override
12453            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
12454                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12455                    throws NoSuchEntryException {
12456                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
12457                                    status, orderByComparator);
12458    
12459                    if (blogsEntry != null) {
12460                            return blogsEntry;
12461                    }
12462    
12463                    StringBundler msg = new StringBundler(8);
12464    
12465                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12466    
12467                    msg.append("groupId=");
12468                    msg.append(groupId);
12469    
12470                    msg.append(", displayDate=");
12471                    msg.append(displayDate);
12472    
12473                    msg.append(", status=");
12474                    msg.append(status);
12475    
12476                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12477    
12478                    throw new NoSuchEntryException(msg.toString());
12479            }
12480    
12481            /**
12482             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12483             *
12484             * @param groupId the group ID
12485             * @param displayDate the display date
12486             * @param status the status
12487             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12488             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12489             */
12490            @Override
12491            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
12492                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12493                    int count = countByG_LtD_NotS(groupId, displayDate, status);
12494    
12495                    if (count == 0) {
12496                            return null;
12497                    }
12498    
12499                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12500                                    count - 1, count, orderByComparator);
12501    
12502                    if (!list.isEmpty()) {
12503                            return list.get(0);
12504                    }
12505    
12506                    return null;
12507            }
12508    
12509            /**
12510             * 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;.
12511             *
12512             * @param entryId the primary key of the current blogs entry
12513             * @param groupId the group ID
12514             * @param displayDate the display date
12515             * @param status the status
12516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12517             * @return the previous, current, and next blogs entry
12518             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12519             */
12520            @Override
12521            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
12522                    long groupId, Date displayDate, int status,
12523                    OrderByComparator<BlogsEntry> orderByComparator)
12524                    throws NoSuchEntryException {
12525                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12526    
12527                    Session session = null;
12528    
12529                    try {
12530                            session = openSession();
12531    
12532                            BlogsEntry[] array = new BlogsEntryImpl[3];
12533    
12534                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12535                                            groupId, displayDate, status, orderByComparator, true);
12536    
12537                            array[1] = blogsEntry;
12538    
12539                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12540                                            groupId, displayDate, status, orderByComparator, false);
12541    
12542                            return array;
12543                    }
12544                    catch (Exception e) {
12545                            throw processException(e);
12546                    }
12547                    finally {
12548                            closeSession(session);
12549                    }
12550            }
12551    
12552            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
12553                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12554                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12555                    StringBundler query = null;
12556    
12557                    if (orderByComparator != null) {
12558                            query = new StringBundler(6 +
12559                                            (orderByComparator.getOrderByFields().length * 6));
12560                    }
12561                    else {
12562                            query = new StringBundler(3);
12563                    }
12564    
12565                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12566    
12567                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12568    
12569                    boolean bindDisplayDate = false;
12570    
12571                    if (displayDate == null) {
12572                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12573                    }
12574                    else {
12575                            bindDisplayDate = true;
12576    
12577                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12578                    }
12579    
12580                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12581    
12582                    if (orderByComparator != null) {
12583                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12584    
12585                            if (orderByConditionFields.length > 0) {
12586                                    query.append(WHERE_AND);
12587                            }
12588    
12589                            for (int i = 0; i < orderByConditionFields.length; i++) {
12590                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12591                                    query.append(orderByConditionFields[i]);
12592    
12593                                    if ((i + 1) < orderByConditionFields.length) {
12594                                            if (orderByComparator.isAscending() ^ previous) {
12595                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12596                                            }
12597                                            else {
12598                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12599                                            }
12600                                    }
12601                                    else {
12602                                            if (orderByComparator.isAscending() ^ previous) {
12603                                                    query.append(WHERE_GREATER_THAN);
12604                                            }
12605                                            else {
12606                                                    query.append(WHERE_LESSER_THAN);
12607                                            }
12608                                    }
12609                            }
12610    
12611                            query.append(ORDER_BY_CLAUSE);
12612    
12613                            String[] orderByFields = orderByComparator.getOrderByFields();
12614    
12615                            for (int i = 0; i < orderByFields.length; i++) {
12616                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12617                                    query.append(orderByFields[i]);
12618    
12619                                    if ((i + 1) < orderByFields.length) {
12620                                            if (orderByComparator.isAscending() ^ previous) {
12621                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12622                                            }
12623                                            else {
12624                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12625                                            }
12626                                    }
12627                                    else {
12628                                            if (orderByComparator.isAscending() ^ previous) {
12629                                                    query.append(ORDER_BY_ASC);
12630                                            }
12631                                            else {
12632                                                    query.append(ORDER_BY_DESC);
12633                                            }
12634                                    }
12635                            }
12636                    }
12637                    else {
12638                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12639                    }
12640    
12641                    String sql = query.toString();
12642    
12643                    Query q = session.createQuery(sql);
12644    
12645                    q.setFirstResult(0);
12646                    q.setMaxResults(2);
12647    
12648                    QueryPos qPos = QueryPos.getInstance(q);
12649    
12650                    qPos.add(groupId);
12651    
12652                    if (bindDisplayDate) {
12653                            qPos.add(new Timestamp(displayDate.getTime()));
12654                    }
12655    
12656                    qPos.add(status);
12657    
12658                    if (orderByComparator != null) {
12659                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12660    
12661                            for (Object value : values) {
12662                                    qPos.add(value);
12663                            }
12664                    }
12665    
12666                    List<BlogsEntry> list = q.list();
12667    
12668                    if (list.size() == 2) {
12669                            return list.get(1);
12670                    }
12671                    else {
12672                            return null;
12673                    }
12674            }
12675    
12676            /**
12677             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12678             *
12679             * @param groupId the group ID
12680             * @param displayDate the display date
12681             * @param status the status
12682             * @return the matching blogs entries that the user has permission to view
12683             */
12684            @Override
12685            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
12686                    Date displayDate, int status) {
12687                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
12688                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12689            }
12690    
12691            /**
12692             * 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;.
12693             *
12694             * <p>
12695             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12696             * </p>
12697             *
12698             * @param groupId the group ID
12699             * @param displayDate the display date
12700             * @param status the status
12701             * @param start the lower bound of the range of blogs entries
12702             * @param end the upper bound of the range of blogs entries (not inclusive)
12703             * @return the range of matching blogs entries that the user has permission to view
12704             */
12705            @Override
12706            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
12707                    Date displayDate, int status, int start, int end) {
12708                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
12709                            null);
12710            }
12711    
12712            /**
12713             * 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;.
12714             *
12715             * <p>
12716             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
12717             * </p>
12718             *
12719             * @param groupId the group ID
12720             * @param displayDate the display date
12721             * @param status the status
12722             * @param start the lower bound of the range of blogs entries
12723             * @param end the upper bound of the range of blogs entries (not inclusive)
12724             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12725             * @return the ordered range of matching blogs entries that the user has permission to view
12726             */
12727            @Override
12728            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
12729                    Date displayDate, int status, int start, int end,
12730                    OrderByComparator<BlogsEntry> orderByComparator) {
12731                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12732                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
12733                                    orderByComparator);
12734                    }
12735    
12736                    StringBundler query = null;
12737    
12738                    if (orderByComparator != null) {
12739                            query = new StringBundler(5 +
12740                                            (orderByComparator.getOrderByFields().length * 3));
12741                    }
12742                    else {
12743                            query = new StringBundler(5);
12744                    }
12745    
12746                    if (getDB().isSupportsInlineDistinct()) {
12747                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12748                    }
12749                    else {
12750                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12751                    }
12752    
12753                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12754    
12755                    boolean bindDisplayDate = false;
12756    
12757                    if (displayDate == null) {
12758                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12759                    }
12760                    else {
12761                            bindDisplayDate = true;
12762    
12763                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12764                    }
12765    
12766                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12767    
12768                    if (!getDB().isSupportsInlineDistinct()) {
12769                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12770                    }
12771    
12772                    if (orderByComparator != null) {
12773                            if (getDB().isSupportsInlineDistinct()) {
12774                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12775                                            orderByComparator, true);
12776                            }
12777                            else {
12778                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12779                                            orderByComparator, true);
12780                            }
12781                    }
12782                    else {
12783                            if (getDB().isSupportsInlineDistinct()) {
12784                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12785                            }
12786                            else {
12787                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12788                            }
12789                    }
12790    
12791                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12792                                    BlogsEntry.class.getName(),
12793                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12794    
12795                    Session session = null;
12796    
12797                    try {
12798                            session = openSession();
12799    
12800                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12801    
12802                            if (getDB().isSupportsInlineDistinct()) {
12803                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12804                            }
12805                            else {
12806                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12807                            }
12808    
12809                            QueryPos qPos = QueryPos.getInstance(q);
12810    
12811                            qPos.add(groupId);
12812    
12813                            if (bindDisplayDate) {
12814                                    qPos.add(new Timestamp(displayDate.getTime()));
12815                            }
12816    
12817                            qPos.add(status);
12818    
12819                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12820                    }
12821                    catch (Exception e) {
12822                            throw processException(e);
12823                    }
12824                    finally {
12825                            closeSession(session);
12826                    }
12827            }
12828    
12829            /**
12830             * 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;.
12831             *
12832             * @param entryId the primary key of the current blogs entry
12833             * @param groupId the group ID
12834             * @param displayDate the display date
12835             * @param status the status
12836             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12837             * @return the previous, current, and next blogs entry
12838             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
12839             */
12840            @Override
12841            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
12842                    long groupId, Date displayDate, int status,
12843                    OrderByComparator<BlogsEntry> orderByComparator)
12844                    throws NoSuchEntryException {
12845                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12846                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
12847                                    status, orderByComparator);
12848                    }
12849    
12850                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12851    
12852                    Session session = null;
12853    
12854                    try {
12855                            session = openSession();
12856    
12857                            BlogsEntry[] array = new BlogsEntryImpl[3];
12858    
12859                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12860                                            groupId, displayDate, status, orderByComparator, true);
12861    
12862                            array[1] = blogsEntry;
12863    
12864                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12865                                            groupId, displayDate, status, orderByComparator, false);
12866    
12867                            return array;
12868                    }
12869                    catch (Exception e) {
12870                            throw processException(e);
12871                    }
12872                    finally {
12873                            closeSession(session);
12874                    }
12875            }
12876    
12877            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
12878                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12879                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12880                    StringBundler query = null;
12881    
12882                    if (orderByComparator != null) {
12883                            query = new StringBundler(6 +
12884                                            (orderByComparator.getOrderByFields().length * 6));
12885                    }
12886                    else {
12887                            query = new StringBundler(3);
12888                    }
12889    
12890                    if (getDB().isSupportsInlineDistinct()) {
12891                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12892                    }
12893                    else {
12894                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12895                    }
12896    
12897                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12898    
12899                    boolean bindDisplayDate = false;
12900    
12901                    if (displayDate == null) {
12902                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12903                    }
12904                    else {
12905                            bindDisplayDate = true;
12906    
12907                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12908                    }
12909    
12910                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12911    
12912                    if (!getDB().isSupportsInlineDistinct()) {
12913                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12914                    }
12915    
12916                    if (orderByComparator != null) {
12917                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12918    
12919                            if (orderByConditionFields.length > 0) {
12920                                    query.append(WHERE_AND);
12921                            }
12922    
12923                            for (int i = 0; i < orderByConditionFields.length; i++) {
12924                                    if (getDB().isSupportsInlineDistinct()) {
12925                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12926                                    }
12927                                    else {
12928                                            query.append(_ORDER_BY_ENTITY_TABLE);
12929                                    }
12930    
12931                                    query.append(orderByConditionFields[i]);
12932    
12933                                    if ((i + 1) < orderByConditionFields.length) {
12934                                            if (orderByComparator.isAscending() ^ previous) {
12935                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12936                                            }
12937                                            else {
12938                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12939                                            }
12940                                    }
12941                                    else {
12942                                            if (orderByComparator.isAscending() ^ previous) {
12943                                                    query.append(WHERE_GREATER_THAN);
12944                                            }
12945                                            else {
12946                                                    query.append(WHERE_LESSER_THAN);
12947                                            }
12948                                    }
12949                            }
12950    
12951                            query.append(ORDER_BY_CLAUSE);
12952    
12953                            String[] orderByFields = orderByComparator.getOrderByFields();
12954    
12955                            for (int i = 0; i < orderByFields.length; i++) {
12956                                    if (getDB().isSupportsInlineDistinct()) {
12957                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12958                                    }
12959                                    else {
12960                                            query.append(_ORDER_BY_ENTITY_TABLE);
12961                                    }
12962    
12963                                    query.append(orderByFields[i]);
12964    
12965                                    if ((i + 1) < orderByFields.length) {
12966                                            if (orderByComparator.isAscending() ^ previous) {
12967                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12968                                            }
12969                                            else {
12970                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12971                                            }
12972                                    }
12973                                    else {
12974                                            if (orderByComparator.isAscending() ^ previous) {
12975                                                    query.append(ORDER_BY_ASC);
12976                                            }
12977                                            else {
12978                                                    query.append(ORDER_BY_DESC);
12979                                            }
12980                                    }
12981                            }
12982                    }
12983                    else {
12984                            if (getDB().isSupportsInlineDistinct()) {
12985                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12986                            }
12987                            else {
12988                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12989                            }
12990                    }
12991    
12992                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12993                                    BlogsEntry.class.getName(),
12994                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12995    
12996                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12997    
12998                    q.setFirstResult(0);
12999                    q.setMaxResults(2);
13000    
13001                    if (getDB().isSupportsInlineDistinct()) {
13002                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13003                    }
13004                    else {
13005                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13006                    }
13007    
13008                    QueryPos qPos = QueryPos.getInstance(q);
13009    
13010                    qPos.add(groupId);
13011    
13012                    if (bindDisplayDate) {
13013                            qPos.add(new Timestamp(displayDate.getTime()));
13014                    }
13015    
13016                    qPos.add(status);
13017    
13018                    if (orderByComparator != null) {
13019                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13020    
13021                            for (Object value : values) {
13022                                    qPos.add(value);
13023                            }
13024                    }
13025    
13026                    List<BlogsEntry> list = q.list();
13027    
13028                    if (list.size() == 2) {
13029                            return list.get(1);
13030                    }
13031                    else {
13032                            return null;
13033                    }
13034            }
13035    
13036            /**
13037             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
13038             *
13039             * @param groupId the group ID
13040             * @param displayDate the display date
13041             * @param status the status
13042             */
13043            @Override
13044            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
13045                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
13046                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13047                            remove(blogsEntry);
13048                    }
13049            }
13050    
13051            /**
13052             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13053             *
13054             * @param groupId the group ID
13055             * @param displayDate the display date
13056             * @param status the status
13057             * @return the number of matching blogs entries
13058             */
13059            @Override
13060            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
13061                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
13062    
13063                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13064    
13065                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13066                                    this);
13067    
13068                    if (count == null) {
13069                            StringBundler query = new StringBundler(4);
13070    
13071                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13072    
13073                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13074    
13075                            boolean bindDisplayDate = false;
13076    
13077                            if (displayDate == null) {
13078                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13079                            }
13080                            else {
13081                                    bindDisplayDate = true;
13082    
13083                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13084                            }
13085    
13086                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13087    
13088                            String sql = query.toString();
13089    
13090                            Session session = null;
13091    
13092                            try {
13093                                    session = openSession();
13094    
13095                                    Query q = session.createQuery(sql);
13096    
13097                                    QueryPos qPos = QueryPos.getInstance(q);
13098    
13099                                    qPos.add(groupId);
13100    
13101                                    if (bindDisplayDate) {
13102                                            qPos.add(new Timestamp(displayDate.getTime()));
13103                                    }
13104    
13105                                    qPos.add(status);
13106    
13107                                    count = (Long)q.uniqueResult();
13108    
13109                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13110                            }
13111                            catch (Exception e) {
13112                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13113    
13114                                    throw processException(e);
13115                            }
13116                            finally {
13117                                    closeSession(session);
13118                            }
13119                    }
13120    
13121                    return count.intValue();
13122            }
13123    
13124            /**
13125             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13126             *
13127             * @param groupId the group ID
13128             * @param displayDate the display date
13129             * @param status the status
13130             * @return the number of matching blogs entries that the user has permission to view
13131             */
13132            @Override
13133            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
13134                    int status) {
13135                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13136                            return countByG_LtD_NotS(groupId, displayDate, status);
13137                    }
13138    
13139                    StringBundler query = new StringBundler(4);
13140    
13141                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13142    
13143                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13144    
13145                    boolean bindDisplayDate = false;
13146    
13147                    if (displayDate == null) {
13148                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13149                    }
13150                    else {
13151                            bindDisplayDate = true;
13152    
13153                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13154                    }
13155    
13156                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13157    
13158                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13159                                    BlogsEntry.class.getName(),
13160                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13161    
13162                    Session session = null;
13163    
13164                    try {
13165                            session = openSession();
13166    
13167                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13168    
13169                            q.addScalar(COUNT_COLUMN_NAME,
13170                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13171    
13172                            QueryPos qPos = QueryPos.getInstance(q);
13173    
13174                            qPos.add(groupId);
13175    
13176                            if (bindDisplayDate) {
13177                                    qPos.add(new Timestamp(displayDate.getTime()));
13178                            }
13179    
13180                            qPos.add(status);
13181    
13182                            Long count = (Long)q.uniqueResult();
13183    
13184                            return count.intValue();
13185                    }
13186                    catch (Exception e) {
13187                            throw processException(e);
13188                    }
13189                    finally {
13190                            closeSession(session);
13191                    }
13192            }
13193    
13194            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13195            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
13196            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13197            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
13198            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13199                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13200                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
13201                            new String[] {
13202                                    Long.class.getName(), Long.class.getName(),
13203                                    Integer.class.getName(),
13204                                    
13205                            Integer.class.getName(), Integer.class.getName(),
13206                                    OrderByComparator.class.getName()
13207                            });
13208            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13209                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13210                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
13211                            new String[] {
13212                                    Long.class.getName(), Long.class.getName(),
13213                                    Integer.class.getName()
13214                            },
13215                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
13216                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
13217                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
13218                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
13219                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
13220            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13221                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13222                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
13223                            new String[] {
13224                                    Long.class.getName(), Long.class.getName(),
13225                                    Integer.class.getName()
13226                            });
13227    
13228            /**
13229             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13230             *
13231             * @param companyId the company ID
13232             * @param userId the user ID
13233             * @param status the status
13234             * @return the matching blogs entries
13235             */
13236            @Override
13237            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
13238                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
13239                            QueryUtil.ALL_POS, null);
13240            }
13241    
13242            /**
13243             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13244             *
13245             * <p>
13246             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13247             * </p>
13248             *
13249             * @param companyId the company ID
13250             * @param userId the user ID
13251             * @param status the status
13252             * @param start the lower bound of the range of blogs entries
13253             * @param end the upper bound of the range of blogs entries (not inclusive)
13254             * @return the range of matching blogs entries
13255             */
13256            @Override
13257            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13258                    int status, int start, int end) {
13259                    return findByC_U_S(companyId, userId, status, start, end, null);
13260            }
13261    
13262            /**
13263             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13264             *
13265             * <p>
13266             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13267             * </p>
13268             *
13269             * @param companyId the company ID
13270             * @param userId the user ID
13271             * @param status the status
13272             * @param start the lower bound of the range of blogs entries
13273             * @param end the upper bound of the range of blogs entries (not inclusive)
13274             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13275             * @return the ordered range of matching blogs entries
13276             */
13277            @Override
13278            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13279                    int status, int start, int end,
13280                    OrderByComparator<BlogsEntry> orderByComparator) {
13281                    boolean pagination = true;
13282                    FinderPath finderPath = null;
13283                    Object[] finderArgs = null;
13284    
13285                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13286                                    (orderByComparator == null)) {
13287                            pagination = false;
13288                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
13289                            finderArgs = new Object[] { companyId, userId, status };
13290                    }
13291                    else {
13292                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
13293                            finderArgs = new Object[] {
13294                                            companyId, userId, status,
13295                                            
13296                                            start, end, orderByComparator
13297                                    };
13298                    }
13299    
13300                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13301                                    finderArgs, this);
13302    
13303                    if ((list != null) && !list.isEmpty()) {
13304                            for (BlogsEntry blogsEntry : list) {
13305                                    if ((companyId != blogsEntry.getCompanyId()) ||
13306                                                    (userId != blogsEntry.getUserId()) ||
13307                                                    (status != blogsEntry.getStatus())) {
13308                                            list = null;
13309    
13310                                            break;
13311                                    }
13312                            }
13313                    }
13314    
13315                    if (list == null) {
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                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13327    
13328                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13329    
13330                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13331    
13332                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13333    
13334                            if (orderByComparator != null) {
13335                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13336                                            orderByComparator);
13337                            }
13338                            else
13339                             if (pagination) {
13340                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13341                            }
13342    
13343                            String sql = query.toString();
13344    
13345                            Session session = null;
13346    
13347                            try {
13348                                    session = openSession();
13349    
13350                                    Query q = session.createQuery(sql);
13351    
13352                                    QueryPos qPos = QueryPos.getInstance(q);
13353    
13354                                    qPos.add(companyId);
13355    
13356                                    qPos.add(userId);
13357    
13358                                    qPos.add(status);
13359    
13360                                    if (!pagination) {
13361                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13362                                                            start, end, false);
13363    
13364                                            Collections.sort(list);
13365    
13366                                            list = Collections.unmodifiableList(list);
13367                                    }
13368                                    else {
13369                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13370                                                            start, end);
13371                                    }
13372    
13373                                    cacheResult(list);
13374    
13375                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13376                            }
13377                            catch (Exception e) {
13378                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13379    
13380                                    throw processException(e);
13381                            }
13382                            finally {
13383                                    closeSession(session);
13384                            }
13385                    }
13386    
13387                    return list;
13388            }
13389    
13390            /**
13391             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13392             *
13393             * @param companyId the company ID
13394             * @param userId the user ID
13395             * @param status the status
13396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13397             * @return the first matching blogs entry
13398             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13399             */
13400            @Override
13401            public BlogsEntry findByC_U_S_First(long companyId, long userId,
13402                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13403                    throws NoSuchEntryException {
13404                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
13405                                    orderByComparator);
13406    
13407                    if (blogsEntry != null) {
13408                            return blogsEntry;
13409                    }
13410    
13411                    StringBundler msg = new StringBundler(8);
13412    
13413                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13414    
13415                    msg.append("companyId=");
13416                    msg.append(companyId);
13417    
13418                    msg.append(", userId=");
13419                    msg.append(userId);
13420    
13421                    msg.append(", status=");
13422                    msg.append(status);
13423    
13424                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13425    
13426                    throw new NoSuchEntryException(msg.toString());
13427            }
13428    
13429            /**
13430             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13431             *
13432             * @param companyId the company ID
13433             * @param userId the user ID
13434             * @param status the status
13435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13436             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13437             */
13438            @Override
13439            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
13440                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13441                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
13442                                    orderByComparator);
13443    
13444                    if (!list.isEmpty()) {
13445                            return list.get(0);
13446                    }
13447    
13448                    return null;
13449            }
13450    
13451            /**
13452             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13453             *
13454             * @param companyId the company ID
13455             * @param userId the user ID
13456             * @param status the status
13457             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13458             * @return the last matching blogs entry
13459             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13460             */
13461            @Override
13462            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
13463                    OrderByComparator<BlogsEntry> orderByComparator)
13464                    throws NoSuchEntryException {
13465                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
13466                                    orderByComparator);
13467    
13468                    if (blogsEntry != null) {
13469                            return blogsEntry;
13470                    }
13471    
13472                    StringBundler msg = new StringBundler(8);
13473    
13474                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13475    
13476                    msg.append("companyId=");
13477                    msg.append(companyId);
13478    
13479                    msg.append(", userId=");
13480                    msg.append(userId);
13481    
13482                    msg.append(", status=");
13483                    msg.append(status);
13484    
13485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13486    
13487                    throw new NoSuchEntryException(msg.toString());
13488            }
13489    
13490            /**
13491             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13492             *
13493             * @param companyId the company ID
13494             * @param userId the user ID
13495             * @param status the status
13496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13497             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13498             */
13499            @Override
13500            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
13501                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13502                    int count = countByC_U_S(companyId, userId, status);
13503    
13504                    if (count == 0) {
13505                            return null;
13506                    }
13507    
13508                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
13509                                    count - 1, count, orderByComparator);
13510    
13511                    if (!list.isEmpty()) {
13512                            return list.get(0);
13513                    }
13514    
13515                    return null;
13516            }
13517    
13518            /**
13519             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13520             *
13521             * @param entryId the primary key of the current blogs entry
13522             * @param companyId the company ID
13523             * @param userId the user ID
13524             * @param status the status
13525             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13526             * @return the previous, current, and next blogs entry
13527             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
13528             */
13529            @Override
13530            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
13531                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
13532                    throws NoSuchEntryException {
13533                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13534    
13535                    Session session = null;
13536    
13537                    try {
13538                            session = openSession();
13539    
13540                            BlogsEntry[] array = new BlogsEntryImpl[3];
13541    
13542                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
13543                                            userId, status, orderByComparator, true);
13544    
13545                            array[1] = blogsEntry;
13546    
13547                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
13548                                            userId, status, orderByComparator, false);
13549    
13550                            return array;
13551                    }
13552                    catch (Exception e) {
13553                            throw processException(e);
13554                    }
13555                    finally {
13556                            closeSession(session);
13557                    }
13558            }
13559    
13560            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
13561                    BlogsEntry blogsEntry, long companyId, long userId, int status,
13562                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13563                    StringBundler query = null;
13564    
13565                    if (orderByComparator != null) {
13566                            query = new StringBundler(6 +
13567                                            (orderByComparator.getOrderByFields().length * 6));
13568                    }
13569                    else {
13570                            query = new StringBundler(3);
13571                    }
13572    
13573                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13574    
13575                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13576    
13577                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13578    
13579                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13580    
13581                    if (orderByComparator != null) {
13582                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13583    
13584                            if (orderByConditionFields.length > 0) {
13585                                    query.append(WHERE_AND);
13586                            }
13587    
13588                            for (int i = 0; i < orderByConditionFields.length; i++) {
13589                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13590                                    query.append(orderByConditionFields[i]);
13591    
13592                                    if ((i + 1) < orderByConditionFields.length) {
13593                                            if (orderByComparator.isAscending() ^ previous) {
13594                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13595                                            }
13596                                            else {
13597                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13598                                            }
13599                                    }
13600                                    else {
13601                                            if (orderByComparator.isAscending() ^ previous) {
13602                                                    query.append(WHERE_GREATER_THAN);
13603                                            }
13604                                            else {
13605                                                    query.append(WHERE_LESSER_THAN);
13606                                            }
13607                                    }
13608                            }
13609    
13610                            query.append(ORDER_BY_CLAUSE);
13611    
13612                            String[] orderByFields = orderByComparator.getOrderByFields();
13613    
13614                            for (int i = 0; i < orderByFields.length; i++) {
13615                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13616                                    query.append(orderByFields[i]);
13617    
13618                                    if ((i + 1) < orderByFields.length) {
13619                                            if (orderByComparator.isAscending() ^ previous) {
13620                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13621                                            }
13622                                            else {
13623                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13624                                            }
13625                                    }
13626                                    else {
13627                                            if (orderByComparator.isAscending() ^ previous) {
13628                                                    query.append(ORDER_BY_ASC);
13629                                            }
13630                                            else {
13631                                                    query.append(ORDER_BY_DESC);
13632                                            }
13633                                    }
13634                            }
13635                    }
13636                    else {
13637                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13638                    }
13639    
13640                    String sql = query.toString();
13641    
13642                    Query q = session.createQuery(sql);
13643    
13644                    q.setFirstResult(0);
13645                    q.setMaxResults(2);
13646    
13647                    QueryPos qPos = QueryPos.getInstance(q);
13648    
13649                    qPos.add(companyId);
13650    
13651                    qPos.add(userId);
13652    
13653                    qPos.add(status);
13654    
13655                    if (orderByComparator != null) {
13656                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13657    
13658                            for (Object value : values) {
13659                                    qPos.add(value);
13660                            }
13661                    }
13662    
13663                    List<BlogsEntry> list = q.list();
13664    
13665                    if (list.size() == 2) {
13666                            return list.get(1);
13667                    }
13668                    else {
13669                            return null;
13670                    }
13671            }
13672    
13673            /**
13674             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
13675             *
13676             * @param companyId the company ID
13677             * @param userId the user ID
13678             * @param status the status
13679             */
13680            @Override
13681            public void removeByC_U_S(long companyId, long userId, int status) {
13682                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
13683                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13684                            remove(blogsEntry);
13685                    }
13686            }
13687    
13688            /**
13689             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13690             *
13691             * @param companyId the company ID
13692             * @param userId the user ID
13693             * @param status the status
13694             * @return the number of matching blogs entries
13695             */
13696            @Override
13697            public int countByC_U_S(long companyId, long userId, int status) {
13698                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
13699    
13700                    Object[] finderArgs = new Object[] { companyId, userId, status };
13701    
13702                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13703                                    this);
13704    
13705                    if (count == null) {
13706                            StringBundler query = new StringBundler(4);
13707    
13708                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13709    
13710                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13711    
13712                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13713    
13714                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13715    
13716                            String sql = query.toString();
13717    
13718                            Session session = null;
13719    
13720                            try {
13721                                    session = openSession();
13722    
13723                                    Query q = session.createQuery(sql);
13724    
13725                                    QueryPos qPos = QueryPos.getInstance(q);
13726    
13727                                    qPos.add(companyId);
13728    
13729                                    qPos.add(userId);
13730    
13731                                    qPos.add(status);
13732    
13733                                    count = (Long)q.uniqueResult();
13734    
13735                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13736                            }
13737                            catch (Exception e) {
13738                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13739    
13740                                    throw processException(e);
13741                            }
13742                            finally {
13743                                    closeSession(session);
13744                            }
13745                    }
13746    
13747                    return count.intValue();
13748            }
13749    
13750            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
13751            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
13752            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
13753            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13754                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13755                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
13756                            new String[] {
13757                                    Long.class.getName(), Long.class.getName(),
13758                                    Integer.class.getName(),
13759                                    
13760                            Integer.class.getName(), Integer.class.getName(),
13761                                    OrderByComparator.class.getName()
13762                            });
13763            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
13764                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13765                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13766                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
13767                            new String[] {
13768                                    Long.class.getName(), Long.class.getName(),
13769                                    Integer.class.getName()
13770                            });
13771    
13772            /**
13773             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13774             *
13775             * @param companyId the company ID
13776             * @param userId the user ID
13777             * @param status the status
13778             * @return the matching blogs entries
13779             */
13780            @Override
13781            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
13782                    int status) {
13783                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
13784                            QueryUtil.ALL_POS, null);
13785            }
13786    
13787            /**
13788             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13789             *
13790             * <p>
13791             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13792             * </p>
13793             *
13794             * @param companyId the company ID
13795             * @param userId the user ID
13796             * @param status the status
13797             * @param start the lower bound of the range of blogs entries
13798             * @param end the upper bound of the range of blogs entries (not inclusive)
13799             * @return the range of matching blogs entries
13800             */
13801            @Override
13802            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
13803                    int status, int start, int end) {
13804                    return findByC_U_NotS(companyId, userId, status, start, end, null);
13805            }
13806    
13807            /**
13808             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13809             *
13810             * <p>
13811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
13812             * </p>
13813             *
13814             * @param companyId the company ID
13815             * @param userId the user ID
13816             * @param status the status
13817             * @param start the lower bound of the range of blogs entries
13818             * @param end the upper bound of the range of blogs entries (not inclusive)
13819             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13820             * @return the ordered range of matching blogs entries
13821             */
13822            @Override
13823            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
13824                    int status, int start, int end,
13825                    OrderByComparator<BlogsEntry> orderByComparator) {
13826                    boolean pagination = true;
13827                    FinderPath finderPath = null;
13828                    Object[] finderArgs = null;
13829    
13830                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
13831                    finderArgs = new Object[] {
13832                                    companyId, userId, status,
13833                                    
13834                                    start, end, orderByComparator
13835                            };
13836    
13837                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13838                                    finderArgs, this);
13839    
13840                    if ((list != null) && !list.isEmpty()) {
13841                            for (BlogsEntry blogsEntry : list) {
13842                                    if ((companyId != blogsEntry.getCompanyId()) ||
13843                                                    (userId != blogsEntry.getUserId()) ||
13844                                                    (status == blogsEntry.getStatus())) {
13845                                            list = null;
13846    
13847                                            break;
13848                                    }
13849                            }
13850                    }
13851    
13852                    if (list == null) {
13853                            StringBundler query = null;
13854    
13855                            if (orderByComparator != null) {
13856                                    query = new StringBundler(5 +
13857                                                    (orderByComparator.getOrderByFields().length * 3));
13858                            }
13859                            else {
13860                                    query = new StringBundler(5);
13861                            }
13862    
13863                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13864    
13865                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
13866    
13867                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
13868    
13869                            query.append(_FINDER_COLUMN_C_U_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(companyId);
13892    
13893                                    qPos.add(userId);
13894    
13895                                    qPos.add(status);
13896    
13897                                    if (!pagination) {
13898                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13899                                                            start, end, false);
13900    
13901                                            Collections.sort(list);
13902    
13903                                            list = Collections.unmodifiableList(list);
13904                                    }
13905                                    else {
13906                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13907                                                            start, end);
13908                                    }
13909    
13910                                    cacheResult(list);
13911    
13912                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13913                            }
13914                            catch (Exception e) {
13915                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13916    
13917                                    throw processException(e);
13918                            }
13919                            finally {
13920                                    closeSession(session);
13921                            }
13922                    }
13923    
13924                    return list;
13925            }
13926    
13927            /**
13928             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13929             *
13930             * @param companyId the company ID
13931             * @param userId the user ID
13932             * @param status the status
13933             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13934             * @return the first matching blogs entry
13935             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13936             */
13937            @Override
13938            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
13939                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13940                    throws NoSuchEntryException {
13941                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
13942                                    status, orderByComparator);
13943    
13944                    if (blogsEntry != null) {
13945                            return blogsEntry;
13946                    }
13947    
13948                    StringBundler msg = new StringBundler(8);
13949    
13950                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13951    
13952                    msg.append("companyId=");
13953                    msg.append(companyId);
13954    
13955                    msg.append(", userId=");
13956                    msg.append(userId);
13957    
13958                    msg.append(", status=");
13959                    msg.append(status);
13960    
13961                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13962    
13963                    throw new NoSuchEntryException(msg.toString());
13964            }
13965    
13966            /**
13967             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13968             *
13969             * @param companyId the company ID
13970             * @param userId the user ID
13971             * @param status the status
13972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13973             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13974             */
13975            @Override
13976            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
13977                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13978                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
13979                                    orderByComparator);
13980    
13981                    if (!list.isEmpty()) {
13982                            return list.get(0);
13983                    }
13984    
13985                    return null;
13986            }
13987    
13988            /**
13989             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13990             *
13991             * @param companyId the company ID
13992             * @param userId the user ID
13993             * @param status the status
13994             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13995             * @return the last matching blogs entry
13996             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
13997             */
13998            @Override
13999            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
14000                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14001                    throws NoSuchEntryException {
14002                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
14003                                    orderByComparator);
14004    
14005                    if (blogsEntry != null) {
14006                            return blogsEntry;
14007                    }
14008    
14009                    StringBundler msg = new StringBundler(8);
14010    
14011                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14012    
14013                    msg.append("companyId=");
14014                    msg.append(companyId);
14015    
14016                    msg.append(", userId=");
14017                    msg.append(userId);
14018    
14019                    msg.append(", status=");
14020                    msg.append(status);
14021    
14022                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14023    
14024                    throw new NoSuchEntryException(msg.toString());
14025            }
14026    
14027            /**
14028             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14029             *
14030             * @param companyId the company ID
14031             * @param userId the user ID
14032             * @param status the status
14033             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14034             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14035             */
14036            @Override
14037            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
14038                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14039                    int count = countByC_U_NotS(companyId, userId, status);
14040    
14041                    if (count == 0) {
14042                            return null;
14043                    }
14044    
14045                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
14046                                    count - 1, count, orderByComparator);
14047    
14048                    if (!list.isEmpty()) {
14049                            return list.get(0);
14050                    }
14051    
14052                    return null;
14053            }
14054    
14055            /**
14056             * 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;.
14057             *
14058             * @param entryId the primary key of the current blogs entry
14059             * @param companyId the company ID
14060             * @param userId the user ID
14061             * @param status the status
14062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14063             * @return the previous, current, and next blogs entry
14064             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14065             */
14066            @Override
14067            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
14068                    long companyId, long userId, int status,
14069                    OrderByComparator<BlogsEntry> orderByComparator)
14070                    throws NoSuchEntryException {
14071                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14072    
14073                    Session session = null;
14074    
14075                    try {
14076                            session = openSession();
14077    
14078                            BlogsEntry[] array = new BlogsEntryImpl[3];
14079    
14080                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14081                                            companyId, userId, status, orderByComparator, true);
14082    
14083                            array[1] = blogsEntry;
14084    
14085                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14086                                            companyId, userId, status, orderByComparator, false);
14087    
14088                            return array;
14089                    }
14090                    catch (Exception e) {
14091                            throw processException(e);
14092                    }
14093                    finally {
14094                            closeSession(session);
14095                    }
14096            }
14097    
14098            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
14099                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14100                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14101                    StringBundler query = null;
14102    
14103                    if (orderByComparator != null) {
14104                            query = new StringBundler(6 +
14105                                            (orderByComparator.getOrderByFields().length * 6));
14106                    }
14107                    else {
14108                            query = new StringBundler(3);
14109                    }
14110    
14111                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14112    
14113                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14114    
14115                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14116    
14117                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14118    
14119                    if (orderByComparator != null) {
14120                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14121    
14122                            if (orderByConditionFields.length > 0) {
14123                                    query.append(WHERE_AND);
14124                            }
14125    
14126                            for (int i = 0; i < orderByConditionFields.length; i++) {
14127                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14128                                    query.append(orderByConditionFields[i]);
14129    
14130                                    if ((i + 1) < orderByConditionFields.length) {
14131                                            if (orderByComparator.isAscending() ^ previous) {
14132                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14133                                            }
14134                                            else {
14135                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14136                                            }
14137                                    }
14138                                    else {
14139                                            if (orderByComparator.isAscending() ^ previous) {
14140                                                    query.append(WHERE_GREATER_THAN);
14141                                            }
14142                                            else {
14143                                                    query.append(WHERE_LESSER_THAN);
14144                                            }
14145                                    }
14146                            }
14147    
14148                            query.append(ORDER_BY_CLAUSE);
14149    
14150                            String[] orderByFields = orderByComparator.getOrderByFields();
14151    
14152                            for (int i = 0; i < orderByFields.length; i++) {
14153                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14154                                    query.append(orderByFields[i]);
14155    
14156                                    if ((i + 1) < orderByFields.length) {
14157                                            if (orderByComparator.isAscending() ^ previous) {
14158                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14159                                            }
14160                                            else {
14161                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14162                                            }
14163                                    }
14164                                    else {
14165                                            if (orderByComparator.isAscending() ^ previous) {
14166                                                    query.append(ORDER_BY_ASC);
14167                                            }
14168                                            else {
14169                                                    query.append(ORDER_BY_DESC);
14170                                            }
14171                                    }
14172                            }
14173                    }
14174                    else {
14175                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14176                    }
14177    
14178                    String sql = query.toString();
14179    
14180                    Query q = session.createQuery(sql);
14181    
14182                    q.setFirstResult(0);
14183                    q.setMaxResults(2);
14184    
14185                    QueryPos qPos = QueryPos.getInstance(q);
14186    
14187                    qPos.add(companyId);
14188    
14189                    qPos.add(userId);
14190    
14191                    qPos.add(status);
14192    
14193                    if (orderByComparator != null) {
14194                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14195    
14196                            for (Object value : values) {
14197                                    qPos.add(value);
14198                            }
14199                    }
14200    
14201                    List<BlogsEntry> list = q.list();
14202    
14203                    if (list.size() == 2) {
14204                            return list.get(1);
14205                    }
14206                    else {
14207                            return null;
14208                    }
14209            }
14210    
14211            /**
14212             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
14213             *
14214             * @param companyId the company ID
14215             * @param userId the user ID
14216             * @param status the status
14217             */
14218            @Override
14219            public void removeByC_U_NotS(long companyId, long userId, int status) {
14220                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
14221                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14222                            remove(blogsEntry);
14223                    }
14224            }
14225    
14226            /**
14227             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14228             *
14229             * @param companyId the company ID
14230             * @param userId the user ID
14231             * @param status the status
14232             * @return the number of matching blogs entries
14233             */
14234            @Override
14235            public int countByC_U_NotS(long companyId, long userId, int status) {
14236                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
14237    
14238                    Object[] finderArgs = new Object[] { companyId, userId, status };
14239    
14240                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14241                                    this);
14242    
14243                    if (count == null) {
14244                            StringBundler query = new StringBundler(4);
14245    
14246                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14247    
14248                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14249    
14250                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14251    
14252                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14253    
14254                            String sql = query.toString();
14255    
14256                            Session session = null;
14257    
14258                            try {
14259                                    session = openSession();
14260    
14261                                    Query q = session.createQuery(sql);
14262    
14263                                    QueryPos qPos = QueryPos.getInstance(q);
14264    
14265                                    qPos.add(companyId);
14266    
14267                                    qPos.add(userId);
14268    
14269                                    qPos.add(status);
14270    
14271                                    count = (Long)q.uniqueResult();
14272    
14273                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14274                            }
14275                            catch (Exception e) {
14276                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14277    
14278                                    throw processException(e);
14279                            }
14280                            finally {
14281                                    closeSession(session);
14282                            }
14283                    }
14284    
14285                    return count.intValue();
14286            }
14287    
14288            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14289            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
14290            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
14291            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14292                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14293                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
14294                            new String[] {
14295                                    Long.class.getName(), Date.class.getName(),
14296                                    Integer.class.getName(),
14297                                    
14298                            Integer.class.getName(), Integer.class.getName(),
14299                                    OrderByComparator.class.getName()
14300                            });
14301            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14302                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14303                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
14304                            new String[] {
14305                                    Long.class.getName(), Date.class.getName(),
14306                                    Integer.class.getName()
14307                            });
14308    
14309            /**
14310             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14311             *
14312             * @param companyId the company ID
14313             * @param displayDate the display date
14314             * @param status the status
14315             * @return the matching blogs entries
14316             */
14317            @Override
14318            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14319                    int status) {
14320                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
14321                            QueryUtil.ALL_POS, null);
14322            }
14323    
14324            /**
14325             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14326             *
14327             * <p>
14328             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14329             * </p>
14330             *
14331             * @param companyId the company ID
14332             * @param displayDate the display date
14333             * @param status the status
14334             * @param start the lower bound of the range of blogs entries
14335             * @param end the upper bound of the range of blogs entries (not inclusive)
14336             * @return the range of matching blogs entries
14337             */
14338            @Override
14339            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14340                    int status, int start, int end) {
14341                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
14342            }
14343    
14344            /**
14345             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14346             *
14347             * <p>
14348             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14349             * </p>
14350             *
14351             * @param companyId the company ID
14352             * @param displayDate the display date
14353             * @param status the status
14354             * @param start the lower bound of the range of blogs entries
14355             * @param end the upper bound of the range of blogs entries (not inclusive)
14356             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14357             * @return the ordered range of matching blogs entries
14358             */
14359            @Override
14360            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14361                    int status, int start, int end,
14362                    OrderByComparator<BlogsEntry> orderByComparator) {
14363                    boolean pagination = true;
14364                    FinderPath finderPath = null;
14365                    Object[] finderArgs = null;
14366    
14367                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
14368                    finderArgs = new Object[] {
14369                                    companyId, displayDate, status,
14370                                    
14371                                    start, end, orderByComparator
14372                            };
14373    
14374                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14375                                    finderArgs, this);
14376    
14377                    if ((list != null) && !list.isEmpty()) {
14378                            for (BlogsEntry blogsEntry : list) {
14379                                    if ((companyId != blogsEntry.getCompanyId()) ||
14380                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
14381                                                                                                                                    .getTime()) ||
14382                                                    (status != blogsEntry.getStatus())) {
14383                                            list = null;
14384    
14385                                            break;
14386                                    }
14387                            }
14388                    }
14389    
14390                    if (list == null) {
14391                            StringBundler query = null;
14392    
14393                            if (orderByComparator != null) {
14394                                    query = new StringBundler(5 +
14395                                                    (orderByComparator.getOrderByFields().length * 3));
14396                            }
14397                            else {
14398                                    query = new StringBundler(5);
14399                            }
14400    
14401                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14402    
14403                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14404    
14405                            boolean bindDisplayDate = false;
14406    
14407                            if (displayDate == null) {
14408                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14409                            }
14410                            else {
14411                                    bindDisplayDate = true;
14412    
14413                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14414                            }
14415    
14416                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14417    
14418                            if (orderByComparator != null) {
14419                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14420                                            orderByComparator);
14421                            }
14422                            else
14423                             if (pagination) {
14424                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14425                            }
14426    
14427                            String sql = query.toString();
14428    
14429                            Session session = null;
14430    
14431                            try {
14432                                    session = openSession();
14433    
14434                                    Query q = session.createQuery(sql);
14435    
14436                                    QueryPos qPos = QueryPos.getInstance(q);
14437    
14438                                    qPos.add(companyId);
14439    
14440                                    if (bindDisplayDate) {
14441                                            qPos.add(new Timestamp(displayDate.getTime()));
14442                                    }
14443    
14444                                    qPos.add(status);
14445    
14446                                    if (!pagination) {
14447                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14448                                                            start, end, false);
14449    
14450                                            Collections.sort(list);
14451    
14452                                            list = Collections.unmodifiableList(list);
14453                                    }
14454                                    else {
14455                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14456                                                            start, end);
14457                                    }
14458    
14459                                    cacheResult(list);
14460    
14461                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14462                            }
14463                            catch (Exception e) {
14464                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14465    
14466                                    throw processException(e);
14467                            }
14468                            finally {
14469                                    closeSession(session);
14470                            }
14471                    }
14472    
14473                    return list;
14474            }
14475    
14476            /**
14477             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14478             *
14479             * @param companyId the company ID
14480             * @param displayDate the display date
14481             * @param status the status
14482             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14483             * @return the first matching blogs entry
14484             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14485             */
14486            @Override
14487            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
14488                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14489                    throws NoSuchEntryException {
14490                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
14491                                    status, orderByComparator);
14492    
14493                    if (blogsEntry != null) {
14494                            return blogsEntry;
14495                    }
14496    
14497                    StringBundler msg = new StringBundler(8);
14498    
14499                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14500    
14501                    msg.append("companyId=");
14502                    msg.append(companyId);
14503    
14504                    msg.append(", displayDate=");
14505                    msg.append(displayDate);
14506    
14507                    msg.append(", status=");
14508                    msg.append(status);
14509    
14510                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14511    
14512                    throw new NoSuchEntryException(msg.toString());
14513            }
14514    
14515            /**
14516             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14517             *
14518             * @param companyId the company ID
14519             * @param displayDate the display date
14520             * @param status the status
14521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14522             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14523             */
14524            @Override
14525            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
14526                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14527                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
14528                                    0, 1, orderByComparator);
14529    
14530                    if (!list.isEmpty()) {
14531                            return list.get(0);
14532                    }
14533    
14534                    return null;
14535            }
14536    
14537            /**
14538             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14539             *
14540             * @param companyId the company ID
14541             * @param displayDate the display date
14542             * @param status the status
14543             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14544             * @return the last matching blogs entry
14545             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
14546             */
14547            @Override
14548            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
14549                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14550                    throws NoSuchEntryException {
14551                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
14552                                    status, orderByComparator);
14553    
14554                    if (blogsEntry != null) {
14555                            return blogsEntry;
14556                    }
14557    
14558                    StringBundler msg = new StringBundler(8);
14559    
14560                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14561    
14562                    msg.append("companyId=");
14563                    msg.append(companyId);
14564    
14565                    msg.append(", displayDate=");
14566                    msg.append(displayDate);
14567    
14568                    msg.append(", status=");
14569                    msg.append(status);
14570    
14571                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14572    
14573                    throw new NoSuchEntryException(msg.toString());
14574            }
14575    
14576            /**
14577             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14578             *
14579             * @param companyId the company ID
14580             * @param displayDate the display date
14581             * @param status the status
14582             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14583             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14584             */
14585            @Override
14586            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
14587                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14588                    int count = countByC_LtD_S(companyId, displayDate, status);
14589    
14590                    if (count == 0) {
14591                            return null;
14592                    }
14593    
14594                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
14595                                    count - 1, count, orderByComparator);
14596    
14597                    if (!list.isEmpty()) {
14598                            return list.get(0);
14599                    }
14600    
14601                    return null;
14602            }
14603    
14604            /**
14605             * 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;.
14606             *
14607             * @param entryId the primary key of the current blogs entry
14608             * @param companyId the company ID
14609             * @param displayDate the display date
14610             * @param status the status
14611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14612             * @return the previous, current, and next blogs entry
14613             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
14614             */
14615            @Override
14616            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
14617                    Date displayDate, int status,
14618                    OrderByComparator<BlogsEntry> orderByComparator)
14619                    throws NoSuchEntryException {
14620                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14621    
14622                    Session session = null;
14623    
14624                    try {
14625                            session = openSession();
14626    
14627                            BlogsEntry[] array = new BlogsEntryImpl[3];
14628    
14629                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
14630                                            displayDate, status, orderByComparator, true);
14631    
14632                            array[1] = blogsEntry;
14633    
14634                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
14635                                            displayDate, status, orderByComparator, false);
14636    
14637                            return array;
14638                    }
14639                    catch (Exception e) {
14640                            throw processException(e);
14641                    }
14642                    finally {
14643                            closeSession(session);
14644                    }
14645            }
14646    
14647            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
14648                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
14649                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14650                    StringBundler query = null;
14651    
14652                    if (orderByComparator != null) {
14653                            query = new StringBundler(6 +
14654                                            (orderByComparator.getOrderByFields().length * 6));
14655                    }
14656                    else {
14657                            query = new StringBundler(3);
14658                    }
14659    
14660                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14661    
14662                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14663    
14664                    boolean bindDisplayDate = false;
14665    
14666                    if (displayDate == null) {
14667                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14668                    }
14669                    else {
14670                            bindDisplayDate = true;
14671    
14672                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14673                    }
14674    
14675                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14676    
14677                    if (orderByComparator != null) {
14678                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14679    
14680                            if (orderByConditionFields.length > 0) {
14681                                    query.append(WHERE_AND);
14682                            }
14683    
14684                            for (int i = 0; i < orderByConditionFields.length; i++) {
14685                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14686                                    query.append(orderByConditionFields[i]);
14687    
14688                                    if ((i + 1) < orderByConditionFields.length) {
14689                                            if (orderByComparator.isAscending() ^ previous) {
14690                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14691                                            }
14692                                            else {
14693                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14694                                            }
14695                                    }
14696                                    else {
14697                                            if (orderByComparator.isAscending() ^ previous) {
14698                                                    query.append(WHERE_GREATER_THAN);
14699                                            }
14700                                            else {
14701                                                    query.append(WHERE_LESSER_THAN);
14702                                            }
14703                                    }
14704                            }
14705    
14706                            query.append(ORDER_BY_CLAUSE);
14707    
14708                            String[] orderByFields = orderByComparator.getOrderByFields();
14709    
14710                            for (int i = 0; i < orderByFields.length; i++) {
14711                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14712                                    query.append(orderByFields[i]);
14713    
14714                                    if ((i + 1) < orderByFields.length) {
14715                                            if (orderByComparator.isAscending() ^ previous) {
14716                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14717                                            }
14718                                            else {
14719                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14720                                            }
14721                                    }
14722                                    else {
14723                                            if (orderByComparator.isAscending() ^ previous) {
14724                                                    query.append(ORDER_BY_ASC);
14725                                            }
14726                                            else {
14727                                                    query.append(ORDER_BY_DESC);
14728                                            }
14729                                    }
14730                            }
14731                    }
14732                    else {
14733                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14734                    }
14735    
14736                    String sql = query.toString();
14737    
14738                    Query q = session.createQuery(sql);
14739    
14740                    q.setFirstResult(0);
14741                    q.setMaxResults(2);
14742    
14743                    QueryPos qPos = QueryPos.getInstance(q);
14744    
14745                    qPos.add(companyId);
14746    
14747                    if (bindDisplayDate) {
14748                            qPos.add(new Timestamp(displayDate.getTime()));
14749                    }
14750    
14751                    qPos.add(status);
14752    
14753                    if (orderByComparator != null) {
14754                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14755    
14756                            for (Object value : values) {
14757                                    qPos.add(value);
14758                            }
14759                    }
14760    
14761                    List<BlogsEntry> list = q.list();
14762    
14763                    if (list.size() == 2) {
14764                            return list.get(1);
14765                    }
14766                    else {
14767                            return null;
14768                    }
14769            }
14770    
14771            /**
14772             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
14773             *
14774             * @param companyId the company ID
14775             * @param displayDate the display date
14776             * @param status the status
14777             */
14778            @Override
14779            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
14780                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
14781                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14782                            remove(blogsEntry);
14783                    }
14784            }
14785    
14786            /**
14787             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14788             *
14789             * @param companyId the company ID
14790             * @param displayDate the display date
14791             * @param status the status
14792             * @return the number of matching blogs entries
14793             */
14794            @Override
14795            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
14796                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
14797    
14798                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
14799    
14800                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14801                                    this);
14802    
14803                    if (count == null) {
14804                            StringBundler query = new StringBundler(4);
14805    
14806                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14807    
14808                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14809    
14810                            boolean bindDisplayDate = false;
14811    
14812                            if (displayDate == null) {
14813                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14814                            }
14815                            else {
14816                                    bindDisplayDate = true;
14817    
14818                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14819                            }
14820    
14821                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14822    
14823                            String sql = query.toString();
14824    
14825                            Session session = null;
14826    
14827                            try {
14828                                    session = openSession();
14829    
14830                                    Query q = session.createQuery(sql);
14831    
14832                                    QueryPos qPos = QueryPos.getInstance(q);
14833    
14834                                    qPos.add(companyId);
14835    
14836                                    if (bindDisplayDate) {
14837                                            qPos.add(new Timestamp(displayDate.getTime()));
14838                                    }
14839    
14840                                    qPos.add(status);
14841    
14842                                    count = (Long)q.uniqueResult();
14843    
14844                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14845                            }
14846                            catch (Exception e) {
14847                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14848    
14849                                    throw processException(e);
14850                            }
14851                            finally {
14852                                    closeSession(session);
14853                            }
14854                    }
14855    
14856                    return count.intValue();
14857            }
14858    
14859            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14860            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
14861            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14862            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
14863            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
14864                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14865                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14866                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
14867                            new String[] {
14868                                    Long.class.getName(), Date.class.getName(),
14869                                    Integer.class.getName(),
14870                                    
14871                            Integer.class.getName(), Integer.class.getName(),
14872                                    OrderByComparator.class.getName()
14873                            });
14874            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
14875                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14876                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14877                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
14878                            new String[] {
14879                                    Long.class.getName(), Date.class.getName(),
14880                                    Integer.class.getName()
14881                            });
14882    
14883            /**
14884             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14885             *
14886             * @param companyId the company ID
14887             * @param displayDate the display date
14888             * @param status the status
14889             * @return the matching blogs entries
14890             */
14891            @Override
14892            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
14893                    int status) {
14894                    return findByC_LtD_NotS(companyId, displayDate, status,
14895                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14896            }
14897    
14898            /**
14899             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14900             *
14901             * <p>
14902             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14903             * </p>
14904             *
14905             * @param companyId the company ID
14906             * @param displayDate the display date
14907             * @param status the status
14908             * @param start the lower bound of the range of blogs entries
14909             * @param end the upper bound of the range of blogs entries (not inclusive)
14910             * @return the range of matching blogs entries
14911             */
14912            @Override
14913            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
14914                    int status, int start, int end) {
14915                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
14916            }
14917    
14918            /**
14919             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14920             *
14921             * <p>
14922             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
14923             * </p>
14924             *
14925             * @param companyId the company ID
14926             * @param displayDate the display date
14927             * @param status the status
14928             * @param start the lower bound of the range of blogs entries
14929             * @param end the upper bound of the range of blogs entries (not inclusive)
14930             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14931             * @return the ordered range of matching blogs entries
14932             */
14933            @Override
14934            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
14935                    int status, int start, int end,
14936                    OrderByComparator<BlogsEntry> orderByComparator) {
14937                    boolean pagination = true;
14938                    FinderPath finderPath = null;
14939                    Object[] finderArgs = null;
14940    
14941                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
14942                    finderArgs = new Object[] {
14943                                    companyId, displayDate, status,
14944                                    
14945                                    start, end, orderByComparator
14946                            };
14947    
14948                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14949                                    finderArgs, this);
14950    
14951                    if ((list != null) && !list.isEmpty()) {
14952                            for (BlogsEntry blogsEntry : list) {
14953                                    if ((companyId != blogsEntry.getCompanyId()) ||
14954                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
14955                                                                                                                                    .getTime()) ||
14956                                                    (status == blogsEntry.getStatus())) {
14957                                            list = null;
14958    
14959                                            break;
14960                                    }
14961                            }
14962                    }
14963    
14964                    if (list == null) {
14965                            StringBundler query = null;
14966    
14967                            if (orderByComparator != null) {
14968                                    query = new StringBundler(5 +
14969                                                    (orderByComparator.getOrderByFields().length * 3));
14970                            }
14971                            else {
14972                                    query = new StringBundler(5);
14973                            }
14974    
14975                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14976    
14977                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
14978    
14979                            boolean bindDisplayDate = false;
14980    
14981                            if (displayDate == null) {
14982                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
14983                            }
14984                            else {
14985                                    bindDisplayDate = true;
14986    
14987                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
14988                            }
14989    
14990                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
14991    
14992                            if (orderByComparator != null) {
14993                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14994                                            orderByComparator);
14995                            }
14996                            else
14997                             if (pagination) {
14998                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14999                            }
15000    
15001                            String sql = query.toString();
15002    
15003                            Session session = null;
15004    
15005                            try {
15006                                    session = openSession();
15007    
15008                                    Query q = session.createQuery(sql);
15009    
15010                                    QueryPos qPos = QueryPos.getInstance(q);
15011    
15012                                    qPos.add(companyId);
15013    
15014                                    if (bindDisplayDate) {
15015                                            qPos.add(new Timestamp(displayDate.getTime()));
15016                                    }
15017    
15018                                    qPos.add(status);
15019    
15020                                    if (!pagination) {
15021                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15022                                                            start, end, false);
15023    
15024                                            Collections.sort(list);
15025    
15026                                            list = Collections.unmodifiableList(list);
15027                                    }
15028                                    else {
15029                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15030                                                            start, end);
15031                                    }
15032    
15033                                    cacheResult(list);
15034    
15035                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15036                            }
15037                            catch (Exception e) {
15038                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15039    
15040                                    throw processException(e);
15041                            }
15042                            finally {
15043                                    closeSession(session);
15044                            }
15045                    }
15046    
15047                    return list;
15048            }
15049    
15050            /**
15051             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15052             *
15053             * @param companyId the company ID
15054             * @param displayDate the display date
15055             * @param status the status
15056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15057             * @return the first matching blogs entry
15058             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15059             */
15060            @Override
15061            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
15062                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15063                    throws NoSuchEntryException {
15064                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
15065                                    status, orderByComparator);
15066    
15067                    if (blogsEntry != null) {
15068                            return blogsEntry;
15069                    }
15070    
15071                    StringBundler msg = new StringBundler(8);
15072    
15073                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15074    
15075                    msg.append("companyId=");
15076                    msg.append(companyId);
15077    
15078                    msg.append(", displayDate=");
15079                    msg.append(displayDate);
15080    
15081                    msg.append(", status=");
15082                    msg.append(status);
15083    
15084                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15085    
15086                    throw new NoSuchEntryException(msg.toString());
15087            }
15088    
15089            /**
15090             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15091             *
15092             * @param companyId the company ID
15093             * @param displayDate the display date
15094             * @param status the status
15095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15096             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15097             */
15098            @Override
15099            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
15100                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15101                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15102                                    status, 0, 1, orderByComparator);
15103    
15104                    if (!list.isEmpty()) {
15105                            return list.get(0);
15106                    }
15107    
15108                    return null;
15109            }
15110    
15111            /**
15112             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15113             *
15114             * @param companyId the company ID
15115             * @param displayDate the display date
15116             * @param status the status
15117             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15118             * @return the last matching blogs entry
15119             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15120             */
15121            @Override
15122            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
15123                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15124                    throws NoSuchEntryException {
15125                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
15126                                    status, orderByComparator);
15127    
15128                    if (blogsEntry != null) {
15129                            return blogsEntry;
15130                    }
15131    
15132                    StringBundler msg = new StringBundler(8);
15133    
15134                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15135    
15136                    msg.append("companyId=");
15137                    msg.append(companyId);
15138    
15139                    msg.append(", displayDate=");
15140                    msg.append(displayDate);
15141    
15142                    msg.append(", status=");
15143                    msg.append(status);
15144    
15145                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15146    
15147                    throw new NoSuchEntryException(msg.toString());
15148            }
15149    
15150            /**
15151             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15152             *
15153             * @param companyId the company ID
15154             * @param displayDate the display date
15155             * @param status the status
15156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15157             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15158             */
15159            @Override
15160            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
15161                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15162                    int count = countByC_LtD_NotS(companyId, displayDate, status);
15163    
15164                    if (count == 0) {
15165                            return null;
15166                    }
15167    
15168                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15169                                    status, count - 1, count, orderByComparator);
15170    
15171                    if (!list.isEmpty()) {
15172                            return list.get(0);
15173                    }
15174    
15175                    return null;
15176            }
15177    
15178            /**
15179             * 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;.
15180             *
15181             * @param entryId the primary key of the current blogs entry
15182             * @param companyId the company ID
15183             * @param displayDate the display date
15184             * @param status the status
15185             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15186             * @return the previous, current, and next blogs entry
15187             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15188             */
15189            @Override
15190            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
15191                    long companyId, Date displayDate, int status,
15192                    OrderByComparator<BlogsEntry> orderByComparator)
15193                    throws NoSuchEntryException {
15194                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15195    
15196                    Session session = null;
15197    
15198                    try {
15199                            session = openSession();
15200    
15201                            BlogsEntry[] array = new BlogsEntryImpl[3];
15202    
15203                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15204                                            companyId, displayDate, status, orderByComparator, true);
15205    
15206                            array[1] = blogsEntry;
15207    
15208                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15209                                            companyId, displayDate, status, orderByComparator, false);
15210    
15211                            return array;
15212                    }
15213                    catch (Exception e) {
15214                            throw processException(e);
15215                    }
15216                    finally {
15217                            closeSession(session);
15218                    }
15219            }
15220    
15221            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
15222                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15223                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15224                    StringBundler query = null;
15225    
15226                    if (orderByComparator != null) {
15227                            query = new StringBundler(6 +
15228                                            (orderByComparator.getOrderByFields().length * 6));
15229                    }
15230                    else {
15231                            query = new StringBundler(3);
15232                    }
15233    
15234                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15235    
15236                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15237    
15238                    boolean bindDisplayDate = false;
15239    
15240                    if (displayDate == null) {
15241                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15242                    }
15243                    else {
15244                            bindDisplayDate = true;
15245    
15246                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15247                    }
15248    
15249                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15250    
15251                    if (orderByComparator != null) {
15252                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15253    
15254                            if (orderByConditionFields.length > 0) {
15255                                    query.append(WHERE_AND);
15256                            }
15257    
15258                            for (int i = 0; i < orderByConditionFields.length; i++) {
15259                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15260                                    query.append(orderByConditionFields[i]);
15261    
15262                                    if ((i + 1) < orderByConditionFields.length) {
15263                                            if (orderByComparator.isAscending() ^ previous) {
15264                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15265                                            }
15266                                            else {
15267                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15268                                            }
15269                                    }
15270                                    else {
15271                                            if (orderByComparator.isAscending() ^ previous) {
15272                                                    query.append(WHERE_GREATER_THAN);
15273                                            }
15274                                            else {
15275                                                    query.append(WHERE_LESSER_THAN);
15276                                            }
15277                                    }
15278                            }
15279    
15280                            query.append(ORDER_BY_CLAUSE);
15281    
15282                            String[] orderByFields = orderByComparator.getOrderByFields();
15283    
15284                            for (int i = 0; i < orderByFields.length; i++) {
15285                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15286                                    query.append(orderByFields[i]);
15287    
15288                                    if ((i + 1) < orderByFields.length) {
15289                                            if (orderByComparator.isAscending() ^ previous) {
15290                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15291                                            }
15292                                            else {
15293                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15294                                            }
15295                                    }
15296                                    else {
15297                                            if (orderByComparator.isAscending() ^ previous) {
15298                                                    query.append(ORDER_BY_ASC);
15299                                            }
15300                                            else {
15301                                                    query.append(ORDER_BY_DESC);
15302                                            }
15303                                    }
15304                            }
15305                    }
15306                    else {
15307                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15308                    }
15309    
15310                    String sql = query.toString();
15311    
15312                    Query q = session.createQuery(sql);
15313    
15314                    q.setFirstResult(0);
15315                    q.setMaxResults(2);
15316    
15317                    QueryPos qPos = QueryPos.getInstance(q);
15318    
15319                    qPos.add(companyId);
15320    
15321                    if (bindDisplayDate) {
15322                            qPos.add(new Timestamp(displayDate.getTime()));
15323                    }
15324    
15325                    qPos.add(status);
15326    
15327                    if (orderByComparator != null) {
15328                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15329    
15330                            for (Object value : values) {
15331                                    qPos.add(value);
15332                            }
15333                    }
15334    
15335                    List<BlogsEntry> list = q.list();
15336    
15337                    if (list.size() == 2) {
15338                            return list.get(1);
15339                    }
15340                    else {
15341                            return null;
15342                    }
15343            }
15344    
15345            /**
15346             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15347             *
15348             * @param companyId the company ID
15349             * @param displayDate the display date
15350             * @param status the status
15351             */
15352            @Override
15353            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
15354                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
15355                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15356                            remove(blogsEntry);
15357                    }
15358            }
15359    
15360            /**
15361             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15362             *
15363             * @param companyId the company ID
15364             * @param displayDate the display date
15365             * @param status the status
15366             * @return the number of matching blogs entries
15367             */
15368            @Override
15369            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
15370                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
15371    
15372                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15373    
15374                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15375                                    this);
15376    
15377                    if (count == null) {
15378                            StringBundler query = new StringBundler(4);
15379    
15380                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15381    
15382                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15383    
15384                            boolean bindDisplayDate = false;
15385    
15386                            if (displayDate == null) {
15387                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15388                            }
15389                            else {
15390                                    bindDisplayDate = true;
15391    
15392                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15393                            }
15394    
15395                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15396    
15397                            String sql = query.toString();
15398    
15399                            Session session = null;
15400    
15401                            try {
15402                                    session = openSession();
15403    
15404                                    Query q = session.createQuery(sql);
15405    
15406                                    QueryPos qPos = QueryPos.getInstance(q);
15407    
15408                                    qPos.add(companyId);
15409    
15410                                    if (bindDisplayDate) {
15411                                            qPos.add(new Timestamp(displayDate.getTime()));
15412                                    }
15413    
15414                                    qPos.add(status);
15415    
15416                                    count = (Long)q.uniqueResult();
15417    
15418                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15419                            }
15420                            catch (Exception e) {
15421                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15422    
15423                                    throw processException(e);
15424                            }
15425                            finally {
15426                                    closeSession(session);
15427                            }
15428                    }
15429    
15430                    return count.intValue();
15431            }
15432    
15433            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15434            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
15435            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15436            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
15437            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
15438                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15439                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15440                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
15441                            new String[] {
15442                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15443                                    Integer.class.getName(),
15444                                    
15445                            Integer.class.getName(), Integer.class.getName(),
15446                                    OrderByComparator.class.getName()
15447                            });
15448            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
15449                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15450                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15451                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
15452                            new String[] {
15453                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15454                                    Integer.class.getName()
15455                            });
15456    
15457            /**
15458             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15459             *
15460             * @param groupId the group ID
15461             * @param userId the user ID
15462             * @param displayDate the display date
15463             * @param status the status
15464             * @return the matching blogs entries
15465             */
15466            @Override
15467            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
15468                    Date displayDate, int status) {
15469                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
15470                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15471            }
15472    
15473            /**
15474             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15475             *
15476             * <p>
15477             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15478             * </p>
15479             *
15480             * @param groupId the group ID
15481             * @param userId the user ID
15482             * @param displayDate the display date
15483             * @param status the status
15484             * @param start the lower bound of the range of blogs entries
15485             * @param end the upper bound of the range of blogs entries (not inclusive)
15486             * @return the range of matching blogs entries
15487             */
15488            @Override
15489            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
15490                    Date displayDate, int status, int start, int end) {
15491                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
15492                            end, null);
15493            }
15494    
15495            /**
15496             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15497             *
15498             * <p>
15499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15500             * </p>
15501             *
15502             * @param groupId the group ID
15503             * @param userId the user ID
15504             * @param displayDate the display date
15505             * @param status the status
15506             * @param start the lower bound of the range of blogs entries
15507             * @param end the upper bound of the range of blogs entries (not inclusive)
15508             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15509             * @return the ordered range of matching blogs entries
15510             */
15511            @Override
15512            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
15513                    Date displayDate, int status, int start, int end,
15514                    OrderByComparator<BlogsEntry> orderByComparator) {
15515                    boolean pagination = true;
15516                    FinderPath finderPath = null;
15517                    Object[] finderArgs = null;
15518    
15519                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
15520                    finderArgs = new Object[] {
15521                                    groupId, userId, displayDate, status,
15522                                    
15523                                    start, end, orderByComparator
15524                            };
15525    
15526                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
15527                                    finderArgs, this);
15528    
15529                    if ((list != null) && !list.isEmpty()) {
15530                            for (BlogsEntry blogsEntry : list) {
15531                                    if ((groupId != blogsEntry.getGroupId()) ||
15532                                                    (userId != blogsEntry.getUserId()) ||
15533                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
15534                                                                                                                                    .getTime()) ||
15535                                                    (status != blogsEntry.getStatus())) {
15536                                            list = null;
15537    
15538                                            break;
15539                                    }
15540                            }
15541                    }
15542    
15543                    if (list == null) {
15544                            StringBundler query = null;
15545    
15546                            if (orderByComparator != null) {
15547                                    query = new StringBundler(6 +
15548                                                    (orderByComparator.getOrderByFields().length * 3));
15549                            }
15550                            else {
15551                                    query = new StringBundler(6);
15552                            }
15553    
15554                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15555    
15556                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
15557    
15558                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
15559    
15560                            boolean bindDisplayDate = false;
15561    
15562                            if (displayDate == null) {
15563                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
15564                            }
15565                            else {
15566                                    bindDisplayDate = true;
15567    
15568                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
15569                            }
15570    
15571                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
15572    
15573                            if (orderByComparator != null) {
15574                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15575                                            orderByComparator);
15576                            }
15577                            else
15578                             if (pagination) {
15579                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15580                            }
15581    
15582                            String sql = query.toString();
15583    
15584                            Session session = null;
15585    
15586                            try {
15587                                    session = openSession();
15588    
15589                                    Query q = session.createQuery(sql);
15590    
15591                                    QueryPos qPos = QueryPos.getInstance(q);
15592    
15593                                    qPos.add(groupId);
15594    
15595                                    qPos.add(userId);
15596    
15597                                    if (bindDisplayDate) {
15598                                            qPos.add(new Timestamp(displayDate.getTime()));
15599                                    }
15600    
15601                                    qPos.add(status);
15602    
15603                                    if (!pagination) {
15604                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15605                                                            start, end, false);
15606    
15607                                            Collections.sort(list);
15608    
15609                                            list = Collections.unmodifiableList(list);
15610                                    }
15611                                    else {
15612                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15613                                                            start, end);
15614                                    }
15615    
15616                                    cacheResult(list);
15617    
15618                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15619                            }
15620                            catch (Exception e) {
15621                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15622    
15623                                    throw processException(e);
15624                            }
15625                            finally {
15626                                    closeSession(session);
15627                            }
15628                    }
15629    
15630                    return list;
15631            }
15632    
15633            /**
15634             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15635             *
15636             * @param groupId the group ID
15637             * @param userId the user ID
15638             * @param displayDate the display date
15639             * @param status the status
15640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15641             * @return the first matching blogs entry
15642             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15643             */
15644            @Override
15645            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
15646                    Date displayDate, int status,
15647                    OrderByComparator<BlogsEntry> orderByComparator)
15648                    throws NoSuchEntryException {
15649                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
15650                                    displayDate, status, orderByComparator);
15651    
15652                    if (blogsEntry != null) {
15653                            return blogsEntry;
15654                    }
15655    
15656                    StringBundler msg = new StringBundler(10);
15657    
15658                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15659    
15660                    msg.append("groupId=");
15661                    msg.append(groupId);
15662    
15663                    msg.append(", userId=");
15664                    msg.append(userId);
15665    
15666                    msg.append(", displayDate=");
15667                    msg.append(displayDate);
15668    
15669                    msg.append(", status=");
15670                    msg.append(status);
15671    
15672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15673    
15674                    throw new NoSuchEntryException(msg.toString());
15675            }
15676    
15677            /**
15678             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15679             *
15680             * @param groupId the group ID
15681             * @param userId the user ID
15682             * @param displayDate the display date
15683             * @param status the status
15684             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15685             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15686             */
15687            @Override
15688            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
15689                    Date displayDate, int status,
15690                    OrderByComparator<BlogsEntry> orderByComparator) {
15691                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
15692                                    status, 0, 1, orderByComparator);
15693    
15694                    if (!list.isEmpty()) {
15695                            return list.get(0);
15696                    }
15697    
15698                    return null;
15699            }
15700    
15701            /**
15702             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15703             *
15704             * @param groupId the group ID
15705             * @param userId the user ID
15706             * @param displayDate the display date
15707             * @param status the status
15708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15709             * @return the last matching blogs entry
15710             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
15711             */
15712            @Override
15713            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
15714                    Date displayDate, int status,
15715                    OrderByComparator<BlogsEntry> orderByComparator)
15716                    throws NoSuchEntryException {
15717                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
15718                                    displayDate, status, orderByComparator);
15719    
15720                    if (blogsEntry != null) {
15721                            return blogsEntry;
15722                    }
15723    
15724                    StringBundler msg = new StringBundler(10);
15725    
15726                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15727    
15728                    msg.append("groupId=");
15729                    msg.append(groupId);
15730    
15731                    msg.append(", userId=");
15732                    msg.append(userId);
15733    
15734                    msg.append(", displayDate=");
15735                    msg.append(displayDate);
15736    
15737                    msg.append(", status=");
15738                    msg.append(status);
15739    
15740                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15741    
15742                    throw new NoSuchEntryException(msg.toString());
15743            }
15744    
15745            /**
15746             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15747             *
15748             * @param groupId the group ID
15749             * @param userId the user ID
15750             * @param displayDate the display date
15751             * @param status the status
15752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15753             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15754             */
15755            @Override
15756            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
15757                    Date displayDate, int status,
15758                    OrderByComparator<BlogsEntry> orderByComparator) {
15759                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
15760    
15761                    if (count == 0) {
15762                            return null;
15763                    }
15764    
15765                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
15766                                    status, count - 1, count, orderByComparator);
15767    
15768                    if (!list.isEmpty()) {
15769                            return list.get(0);
15770                    }
15771    
15772                    return null;
15773            }
15774    
15775            /**
15776             * 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;.
15777             *
15778             * @param entryId the primary key of the current blogs entry
15779             * @param groupId the group ID
15780             * @param userId the user ID
15781             * @param displayDate the display date
15782             * @param status the status
15783             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15784             * @return the previous, current, and next blogs entry
15785             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
15786             */
15787            @Override
15788            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
15789                    long userId, Date displayDate, int status,
15790                    OrderByComparator<BlogsEntry> orderByComparator)
15791                    throws NoSuchEntryException {
15792                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15793    
15794                    Session session = null;
15795    
15796                    try {
15797                            session = openSession();
15798    
15799                            BlogsEntry[] array = new BlogsEntryImpl[3];
15800    
15801                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15802                                            userId, displayDate, status, orderByComparator, true);
15803    
15804                            array[1] = blogsEntry;
15805    
15806                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15807                                            userId, displayDate, status, orderByComparator, false);
15808    
15809                            return array;
15810                    }
15811                    catch (Exception e) {
15812                            throw processException(e);
15813                    }
15814                    finally {
15815                            closeSession(session);
15816                    }
15817            }
15818    
15819            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
15820                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
15821                    int status, OrderByComparator<BlogsEntry> orderByComparator,
15822                    boolean previous) {
15823                    StringBundler query = null;
15824    
15825                    if (orderByComparator != null) {
15826                            query = new StringBundler(6 +
15827                                            (orderByComparator.getOrderByFields().length * 6));
15828                    }
15829                    else {
15830                            query = new StringBundler(3);
15831                    }
15832    
15833                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15834    
15835                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
15836    
15837                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
15838    
15839                    boolean bindDisplayDate = false;
15840    
15841                    if (displayDate == null) {
15842                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
15843                    }
15844                    else {
15845                            bindDisplayDate = true;
15846    
15847                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
15848                    }
15849    
15850                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
15851    
15852                    if (orderByComparator != null) {
15853                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15854    
15855                            if (orderByConditionFields.length > 0) {
15856                                    query.append(WHERE_AND);
15857                            }
15858    
15859                            for (int i = 0; i < orderByConditionFields.length; i++) {
15860                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15861                                    query.append(orderByConditionFields[i]);
15862    
15863                                    if ((i + 1) < orderByConditionFields.length) {
15864                                            if (orderByComparator.isAscending() ^ previous) {
15865                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15866                                            }
15867                                            else {
15868                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15869                                            }
15870                                    }
15871                                    else {
15872                                            if (orderByComparator.isAscending() ^ previous) {
15873                                                    query.append(WHERE_GREATER_THAN);
15874                                            }
15875                                            else {
15876                                                    query.append(WHERE_LESSER_THAN);
15877                                            }
15878                                    }
15879                            }
15880    
15881                            query.append(ORDER_BY_CLAUSE);
15882    
15883                            String[] orderByFields = orderByComparator.getOrderByFields();
15884    
15885                            for (int i = 0; i < orderByFields.length; i++) {
15886                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15887                                    query.append(orderByFields[i]);
15888    
15889                                    if ((i + 1) < orderByFields.length) {
15890                                            if (orderByComparator.isAscending() ^ previous) {
15891                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15892                                            }
15893                                            else {
15894                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15895                                            }
15896                                    }
15897                                    else {
15898                                            if (orderByComparator.isAscending() ^ previous) {
15899                                                    query.append(ORDER_BY_ASC);
15900                                            }
15901                                            else {
15902                                                    query.append(ORDER_BY_DESC);
15903                                            }
15904                                    }
15905                            }
15906                    }
15907                    else {
15908                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15909                    }
15910    
15911                    String sql = query.toString();
15912    
15913                    Query q = session.createQuery(sql);
15914    
15915                    q.setFirstResult(0);
15916                    q.setMaxResults(2);
15917    
15918                    QueryPos qPos = QueryPos.getInstance(q);
15919    
15920                    qPos.add(groupId);
15921    
15922                    qPos.add(userId);
15923    
15924                    if (bindDisplayDate) {
15925                            qPos.add(new Timestamp(displayDate.getTime()));
15926                    }
15927    
15928                    qPos.add(status);
15929    
15930                    if (orderByComparator != null) {
15931                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15932    
15933                            for (Object value : values) {
15934                                    qPos.add(value);
15935                            }
15936                    }
15937    
15938                    List<BlogsEntry> list = q.list();
15939    
15940                    if (list.size() == 2) {
15941                            return list.get(1);
15942                    }
15943                    else {
15944                            return null;
15945                    }
15946            }
15947    
15948            /**
15949             * 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;.
15950             *
15951             * @param groupId the group ID
15952             * @param userId the user ID
15953             * @param displayDate the display date
15954             * @param status the status
15955             * @return the matching blogs entries that the user has permission to view
15956             */
15957            @Override
15958            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
15959                    Date displayDate, int status) {
15960                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
15961                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15962            }
15963    
15964            /**
15965             * 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;.
15966             *
15967             * <p>
15968             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15969             * </p>
15970             *
15971             * @param groupId the group ID
15972             * @param userId the user ID
15973             * @param displayDate the display date
15974             * @param status the status
15975             * @param start the lower bound of the range of blogs entries
15976             * @param end the upper bound of the range of blogs entries (not inclusive)
15977             * @return the range of matching blogs entries that the user has permission to view
15978             */
15979            @Override
15980            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
15981                    Date displayDate, int status, int start, int end) {
15982                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
15983                            start, end, null);
15984            }
15985    
15986            /**
15987             * 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;.
15988             *
15989             * <p>
15990             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
15991             * </p>
15992             *
15993             * @param groupId the group ID
15994             * @param userId the user ID
15995             * @param displayDate the display date
15996             * @param status the status
15997             * @param start the lower bound of the range of blogs entries
15998             * @param end the upper bound of the range of blogs entries (not inclusive)
15999             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16000             * @return the ordered range of matching blogs entries that the user has permission to view
16001             */
16002            @Override
16003            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16004                    Date displayDate, int status, int start, int end,
16005                    OrderByComparator<BlogsEntry> orderByComparator) {
16006                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16007                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16008                                    end, orderByComparator);
16009                    }
16010    
16011                    StringBundler query = null;
16012    
16013                    if (orderByComparator != null) {
16014                            query = new StringBundler(6 +
16015                                            (orderByComparator.getOrderByFields().length * 3));
16016                    }
16017                    else {
16018                            query = new StringBundler(6);
16019                    }
16020    
16021                    if (getDB().isSupportsInlineDistinct()) {
16022                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16023                    }
16024                    else {
16025                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16026                    }
16027    
16028                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16029    
16030                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16031    
16032                    boolean bindDisplayDate = false;
16033    
16034                    if (displayDate == null) {
16035                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16036                    }
16037                    else {
16038                            bindDisplayDate = true;
16039    
16040                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16041                    }
16042    
16043                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16044    
16045                    if (!getDB().isSupportsInlineDistinct()) {
16046                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16047                    }
16048    
16049                    if (orderByComparator != null) {
16050                            if (getDB().isSupportsInlineDistinct()) {
16051                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16052                                            orderByComparator, true);
16053                            }
16054                            else {
16055                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16056                                            orderByComparator, true);
16057                            }
16058                    }
16059                    else {
16060                            if (getDB().isSupportsInlineDistinct()) {
16061                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16062                            }
16063                            else {
16064                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16065                            }
16066                    }
16067    
16068                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16069                                    BlogsEntry.class.getName(),
16070                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16071    
16072                    Session session = null;
16073    
16074                    try {
16075                            session = openSession();
16076    
16077                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16078    
16079                            if (getDB().isSupportsInlineDistinct()) {
16080                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16081                            }
16082                            else {
16083                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16084                            }
16085    
16086                            QueryPos qPos = QueryPos.getInstance(q);
16087    
16088                            qPos.add(groupId);
16089    
16090                            qPos.add(userId);
16091    
16092                            if (bindDisplayDate) {
16093                                    qPos.add(new Timestamp(displayDate.getTime()));
16094                            }
16095    
16096                            qPos.add(status);
16097    
16098                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16099                    }
16100                    catch (Exception e) {
16101                            throw processException(e);
16102                    }
16103                    finally {
16104                            closeSession(session);
16105                    }
16106            }
16107    
16108            /**
16109             * 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;.
16110             *
16111             * @param entryId the primary key of the current blogs entry
16112             * @param groupId the group ID
16113             * @param userId the user ID
16114             * @param displayDate the display date
16115             * @param status the status
16116             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16117             * @return the previous, current, and next blogs entry
16118             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16119             */
16120            @Override
16121            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
16122                    long groupId, long userId, Date displayDate, int status,
16123                    OrderByComparator<BlogsEntry> orderByComparator)
16124                    throws NoSuchEntryException {
16125                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16126                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
16127                                    displayDate, status, orderByComparator);
16128                    }
16129    
16130                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16131    
16132                    Session session = null;
16133    
16134                    try {
16135                            session = openSession();
16136    
16137                            BlogsEntry[] array = new BlogsEntryImpl[3];
16138    
16139                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16140                                            groupId, userId, displayDate, status, orderByComparator,
16141                                            true);
16142    
16143                            array[1] = blogsEntry;
16144    
16145                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16146                                            groupId, userId, displayDate, status, orderByComparator,
16147                                            false);
16148    
16149                            return array;
16150                    }
16151                    catch (Exception e) {
16152                            throw processException(e);
16153                    }
16154                    finally {
16155                            closeSession(session);
16156                    }
16157            }
16158    
16159            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
16160                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16161                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16162                    boolean previous) {
16163                    StringBundler query = null;
16164    
16165                    if (orderByComparator != null) {
16166                            query = new StringBundler(6 +
16167                                            (orderByComparator.getOrderByFields().length * 6));
16168                    }
16169                    else {
16170                            query = new StringBundler(3);
16171                    }
16172    
16173                    if (getDB().isSupportsInlineDistinct()) {
16174                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16175                    }
16176                    else {
16177                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16178                    }
16179    
16180                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16181    
16182                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16183    
16184                    boolean bindDisplayDate = false;
16185    
16186                    if (displayDate == null) {
16187                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16188                    }
16189                    else {
16190                            bindDisplayDate = true;
16191    
16192                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16193                    }
16194    
16195                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16196    
16197                    if (!getDB().isSupportsInlineDistinct()) {
16198                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16199                    }
16200    
16201                    if (orderByComparator != null) {
16202                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16203    
16204                            if (orderByConditionFields.length > 0) {
16205                                    query.append(WHERE_AND);
16206                            }
16207    
16208                            for (int i = 0; i < orderByConditionFields.length; i++) {
16209                                    if (getDB().isSupportsInlineDistinct()) {
16210                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16211                                    }
16212                                    else {
16213                                            query.append(_ORDER_BY_ENTITY_TABLE);
16214                                    }
16215    
16216                                    query.append(orderByConditionFields[i]);
16217    
16218                                    if ((i + 1) < orderByConditionFields.length) {
16219                                            if (orderByComparator.isAscending() ^ previous) {
16220                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16221                                            }
16222                                            else {
16223                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16224                                            }
16225                                    }
16226                                    else {
16227                                            if (orderByComparator.isAscending() ^ previous) {
16228                                                    query.append(WHERE_GREATER_THAN);
16229                                            }
16230                                            else {
16231                                                    query.append(WHERE_LESSER_THAN);
16232                                            }
16233                                    }
16234                            }
16235    
16236                            query.append(ORDER_BY_CLAUSE);
16237    
16238                            String[] orderByFields = orderByComparator.getOrderByFields();
16239    
16240                            for (int i = 0; i < orderByFields.length; i++) {
16241                                    if (getDB().isSupportsInlineDistinct()) {
16242                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16243                                    }
16244                                    else {
16245                                            query.append(_ORDER_BY_ENTITY_TABLE);
16246                                    }
16247    
16248                                    query.append(orderByFields[i]);
16249    
16250                                    if ((i + 1) < orderByFields.length) {
16251                                            if (orderByComparator.isAscending() ^ previous) {
16252                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16253                                            }
16254                                            else {
16255                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16256                                            }
16257                                    }
16258                                    else {
16259                                            if (orderByComparator.isAscending() ^ previous) {
16260                                                    query.append(ORDER_BY_ASC);
16261                                            }
16262                                            else {
16263                                                    query.append(ORDER_BY_DESC);
16264                                            }
16265                                    }
16266                            }
16267                    }
16268                    else {
16269                            if (getDB().isSupportsInlineDistinct()) {
16270                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16271                            }
16272                            else {
16273                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16274                            }
16275                    }
16276    
16277                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16278                                    BlogsEntry.class.getName(),
16279                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16280    
16281                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
16282    
16283                    q.setFirstResult(0);
16284                    q.setMaxResults(2);
16285    
16286                    if (getDB().isSupportsInlineDistinct()) {
16287                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16288                    }
16289                    else {
16290                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16291                    }
16292    
16293                    QueryPos qPos = QueryPos.getInstance(q);
16294    
16295                    qPos.add(groupId);
16296    
16297                    qPos.add(userId);
16298    
16299                    if (bindDisplayDate) {
16300                            qPos.add(new Timestamp(displayDate.getTime()));
16301                    }
16302    
16303                    qPos.add(status);
16304    
16305                    if (orderByComparator != null) {
16306                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16307    
16308                            for (Object value : values) {
16309                                    qPos.add(value);
16310                            }
16311                    }
16312    
16313                    List<BlogsEntry> list = q.list();
16314    
16315                    if (list.size() == 2) {
16316                            return list.get(1);
16317                    }
16318                    else {
16319                            return null;
16320                    }
16321            }
16322    
16323            /**
16324             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
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             */
16331            @Override
16332            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
16333                    int status) {
16334                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
16335                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16336                            remove(blogsEntry);
16337                    }
16338            }
16339    
16340            /**
16341             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16342             *
16343             * @param groupId the group ID
16344             * @param userId the user ID
16345             * @param displayDate the display date
16346             * @param status the status
16347             * @return the number of matching blogs entries
16348             */
16349            @Override
16350            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
16351                    int status) {
16352                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
16353    
16354                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16355    
16356                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16357                                    this);
16358    
16359                    if (count == null) {
16360                            StringBundler query = new StringBundler(5);
16361    
16362                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16363    
16364                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16365    
16366                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16367    
16368                            boolean bindDisplayDate = false;
16369    
16370                            if (displayDate == null) {
16371                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16372                            }
16373                            else {
16374                                    bindDisplayDate = true;
16375    
16376                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16377                            }
16378    
16379                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16380    
16381                            String sql = query.toString();
16382    
16383                            Session session = null;
16384    
16385                            try {
16386                                    session = openSession();
16387    
16388                                    Query q = session.createQuery(sql);
16389    
16390                                    QueryPos qPos = QueryPos.getInstance(q);
16391    
16392                                    qPos.add(groupId);
16393    
16394                                    qPos.add(userId);
16395    
16396                                    if (bindDisplayDate) {
16397                                            qPos.add(new Timestamp(displayDate.getTime()));
16398                                    }
16399    
16400                                    qPos.add(status);
16401    
16402                                    count = (Long)q.uniqueResult();
16403    
16404                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16405                            }
16406                            catch (Exception e) {
16407                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16408    
16409                                    throw processException(e);
16410                            }
16411                            finally {
16412                                    closeSession(session);
16413                            }
16414                    }
16415    
16416                    return count.intValue();
16417            }
16418    
16419            /**
16420             * 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;.
16421             *
16422             * @param groupId the group ID
16423             * @param userId the user ID
16424             * @param displayDate the display date
16425             * @param status the status
16426             * @return the number of matching blogs entries that the user has permission to view
16427             */
16428            @Override
16429            public int filterCountByG_U_LtD_S(long groupId, long userId,
16430                    Date displayDate, int status) {
16431                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16432                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
16433                    }
16434    
16435                    StringBundler query = new StringBundler(5);
16436    
16437                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16438    
16439                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16440    
16441                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16442    
16443                    boolean bindDisplayDate = false;
16444    
16445                    if (displayDate == null) {
16446                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16447                    }
16448                    else {
16449                            bindDisplayDate = true;
16450    
16451                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16452                    }
16453    
16454                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16455    
16456                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16457                                    BlogsEntry.class.getName(),
16458                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16459    
16460                    Session session = null;
16461    
16462                    try {
16463                            session = openSession();
16464    
16465                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16466    
16467                            q.addScalar(COUNT_COLUMN_NAME,
16468                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16469    
16470                            QueryPos qPos = QueryPos.getInstance(q);
16471    
16472                            qPos.add(groupId);
16473    
16474                            qPos.add(userId);
16475    
16476                            if (bindDisplayDate) {
16477                                    qPos.add(new Timestamp(displayDate.getTime()));
16478                            }
16479    
16480                            qPos.add(status);
16481    
16482                            Long count = (Long)q.uniqueResult();
16483    
16484                            return count.intValue();
16485                    }
16486                    catch (Exception e) {
16487                            throw processException(e);
16488                    }
16489                    finally {
16490                            closeSession(session);
16491                    }
16492            }
16493    
16494            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
16495            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
16496            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
16497            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16498            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
16499            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
16500                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16501                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16502                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
16503                            new String[] {
16504                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16505                                    Integer.class.getName(),
16506                                    
16507                            Integer.class.getName(), Integer.class.getName(),
16508                                    OrderByComparator.class.getName()
16509                            });
16510            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
16511                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16512                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16513                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
16514                            new String[] {
16515                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16516                                    Integer.class.getName()
16517                            });
16518    
16519            /**
16520             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16521             *
16522             * @param groupId the group ID
16523             * @param userId the user ID
16524             * @param displayDate the display date
16525             * @param status the status
16526             * @return the matching blogs entries
16527             */
16528            @Override
16529            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
16530                    Date displayDate, int status) {
16531                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
16532                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16533            }
16534    
16535            /**
16536             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16537             *
16538             * <p>
16539             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16540             * </p>
16541             *
16542             * @param groupId the group ID
16543             * @param userId the user ID
16544             * @param displayDate the display date
16545             * @param status the status
16546             * @param start the lower bound of the range of blogs entries
16547             * @param end the upper bound of the range of blogs entries (not inclusive)
16548             * @return the range of matching blogs entries
16549             */
16550            @Override
16551            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
16552                    Date displayDate, int status, int start, int end) {
16553                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
16554                            end, null);
16555            }
16556    
16557            /**
16558             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16559             *
16560             * <p>
16561             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
16562             * </p>
16563             *
16564             * @param groupId the group ID
16565             * @param userId the user ID
16566             * @param displayDate the display date
16567             * @param status the status
16568             * @param start the lower bound of the range of blogs entries
16569             * @param end the upper bound of the range of blogs entries (not inclusive)
16570             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16571             * @return the ordered range of matching blogs entries
16572             */
16573            @Override
16574            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
16575                    Date displayDate, int status, int start, int end,
16576                    OrderByComparator<BlogsEntry> orderByComparator) {
16577                    boolean pagination = true;
16578                    FinderPath finderPath = null;
16579                    Object[] finderArgs = null;
16580    
16581                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
16582                    finderArgs = new Object[] {
16583                                    groupId, userId, displayDate, status,
16584                                    
16585                                    start, end, orderByComparator
16586                            };
16587    
16588                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
16589                                    finderArgs, this);
16590    
16591                    if ((list != null) && !list.isEmpty()) {
16592                            for (BlogsEntry blogsEntry : list) {
16593                                    if ((groupId != blogsEntry.getGroupId()) ||
16594                                                    (userId != blogsEntry.getUserId()) ||
16595                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
16596                                                                                                                                    .getTime()) ||
16597                                                    (status == blogsEntry.getStatus())) {
16598                                            list = null;
16599    
16600                                            break;
16601                                    }
16602                            }
16603                    }
16604    
16605                    if (list == null) {
16606                            StringBundler query = null;
16607    
16608                            if (orderByComparator != null) {
16609                                    query = new StringBundler(6 +
16610                                                    (orderByComparator.getOrderByFields().length * 3));
16611                            }
16612                            else {
16613                                    query = new StringBundler(6);
16614                            }
16615    
16616                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16617    
16618                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16619    
16620                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16621    
16622                            boolean bindDisplayDate = false;
16623    
16624                            if (displayDate == null) {
16625                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16626                            }
16627                            else {
16628                                    bindDisplayDate = true;
16629    
16630                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16631                            }
16632    
16633                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16634    
16635                            if (orderByComparator != null) {
16636                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16637                                            orderByComparator);
16638                            }
16639                            else
16640                             if (pagination) {
16641                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16642                            }
16643    
16644                            String sql = query.toString();
16645    
16646                            Session session = null;
16647    
16648                            try {
16649                                    session = openSession();
16650    
16651                                    Query q = session.createQuery(sql);
16652    
16653                                    QueryPos qPos = QueryPos.getInstance(q);
16654    
16655                                    qPos.add(groupId);
16656    
16657                                    qPos.add(userId);
16658    
16659                                    if (bindDisplayDate) {
16660                                            qPos.add(new Timestamp(displayDate.getTime()));
16661                                    }
16662    
16663                                    qPos.add(status);
16664    
16665                                    if (!pagination) {
16666                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16667                                                            start, end, false);
16668    
16669                                            Collections.sort(list);
16670    
16671                                            list = Collections.unmodifiableList(list);
16672                                    }
16673                                    else {
16674                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16675                                                            start, end);
16676                                    }
16677    
16678                                    cacheResult(list);
16679    
16680                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16681                            }
16682                            catch (Exception e) {
16683                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16684    
16685                                    throw processException(e);
16686                            }
16687                            finally {
16688                                    closeSession(session);
16689                            }
16690                    }
16691    
16692                    return list;
16693            }
16694    
16695            /**
16696             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16697             *
16698             * @param groupId the group ID
16699             * @param userId the user ID
16700             * @param displayDate the display date
16701             * @param status the status
16702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16703             * @return the first matching blogs entry
16704             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
16705             */
16706            @Override
16707            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
16708                    Date displayDate, int status,
16709                    OrderByComparator<BlogsEntry> orderByComparator)
16710                    throws NoSuchEntryException {
16711                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
16712                                    displayDate, status, orderByComparator);
16713    
16714                    if (blogsEntry != null) {
16715                            return blogsEntry;
16716                    }
16717    
16718                    StringBundler msg = new StringBundler(10);
16719    
16720                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16721    
16722                    msg.append("groupId=");
16723                    msg.append(groupId);
16724    
16725                    msg.append(", userId=");
16726                    msg.append(userId);
16727    
16728                    msg.append(", displayDate=");
16729                    msg.append(displayDate);
16730    
16731                    msg.append(", status=");
16732                    msg.append(status);
16733    
16734                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16735    
16736                    throw new NoSuchEntryException(msg.toString());
16737            }
16738    
16739            /**
16740             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16741             *
16742             * @param groupId the group ID
16743             * @param userId the user ID
16744             * @param displayDate the display date
16745             * @param status the status
16746             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16747             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16748             */
16749            @Override
16750            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
16751                    Date displayDate, int status,
16752                    OrderByComparator<BlogsEntry> orderByComparator) {
16753                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16754                                    displayDate, status, 0, 1, orderByComparator);
16755    
16756                    if (!list.isEmpty()) {
16757                            return list.get(0);
16758                    }
16759    
16760                    return null;
16761            }
16762    
16763            /**
16764             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16765             *
16766             * @param groupId the group ID
16767             * @param userId the user ID
16768             * @param displayDate the display date
16769             * @param status the status
16770             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16771             * @return the last matching blogs entry
16772             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a matching blogs entry could not be found
16773             */
16774            @Override
16775            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
16776                    Date displayDate, int status,
16777                    OrderByComparator<BlogsEntry> orderByComparator)
16778                    throws NoSuchEntryException {
16779                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
16780                                    displayDate, status, orderByComparator);
16781    
16782                    if (blogsEntry != null) {
16783                            return blogsEntry;
16784                    }
16785    
16786                    StringBundler msg = new StringBundler(10);
16787    
16788                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16789    
16790                    msg.append("groupId=");
16791                    msg.append(groupId);
16792    
16793                    msg.append(", userId=");
16794                    msg.append(userId);
16795    
16796                    msg.append(", displayDate=");
16797                    msg.append(displayDate);
16798    
16799                    msg.append(", status=");
16800                    msg.append(status);
16801    
16802                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16803    
16804                    throw new NoSuchEntryException(msg.toString());
16805            }
16806    
16807            /**
16808             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16809             *
16810             * @param groupId the group ID
16811             * @param userId the user ID
16812             * @param displayDate the display date
16813             * @param status the status
16814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16815             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16816             */
16817            @Override
16818            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
16819                    Date displayDate, int status,
16820                    OrderByComparator<BlogsEntry> orderByComparator) {
16821                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16822    
16823                    if (count == 0) {
16824                            return null;
16825                    }
16826    
16827                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16828                                    displayDate, status, count - 1, count, orderByComparator);
16829    
16830                    if (!list.isEmpty()) {
16831                            return list.get(0);
16832                    }
16833    
16834                    return null;
16835            }
16836    
16837            /**
16838             * 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;.
16839             *
16840             * @param entryId the primary key of the current blogs entry
16841             * @param groupId the group ID
16842             * @param userId the user ID
16843             * @param displayDate the display date
16844             * @param status the status
16845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16846             * @return the previous, current, and next blogs entry
16847             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
16848             */
16849            @Override
16850            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
16851                    long groupId, long userId, Date displayDate, int status,
16852                    OrderByComparator<BlogsEntry> orderByComparator)
16853                    throws NoSuchEntryException {
16854                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16855    
16856                    Session session = null;
16857    
16858                    try {
16859                            session = openSession();
16860    
16861                            BlogsEntry[] array = new BlogsEntryImpl[3];
16862    
16863                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16864                                            groupId, userId, displayDate, status, orderByComparator,
16865                                            true);
16866    
16867                            array[1] = blogsEntry;
16868    
16869                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16870                                            groupId, userId, displayDate, status, orderByComparator,
16871                                            false);
16872    
16873                            return array;
16874                    }
16875                    catch (Exception e) {
16876                            throw processException(e);
16877                    }
16878                    finally {
16879                            closeSession(session);
16880                    }
16881            }
16882    
16883            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
16884                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16885                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16886                    boolean previous) {
16887                    StringBundler query = null;
16888    
16889                    if (orderByComparator != null) {
16890                            query = new StringBundler(6 +
16891                                            (orderByComparator.getOrderByFields().length * 6));
16892                    }
16893                    else {
16894                            query = new StringBundler(3);
16895                    }
16896    
16897                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16898    
16899                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16900    
16901                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16902    
16903                    boolean bindDisplayDate = false;
16904    
16905                    if (displayDate == null) {
16906                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16907                    }
16908                    else {
16909                            bindDisplayDate = true;
16910    
16911                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16912                    }
16913    
16914                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16915    
16916                    if (orderByComparator != null) {
16917                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16918    
16919                            if (orderByConditionFields.length > 0) {
16920                                    query.append(WHERE_AND);
16921                            }
16922    
16923                            for (int i = 0; i < orderByConditionFields.length; i++) {
16924                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16925                                    query.append(orderByConditionFields[i]);
16926    
16927                                    if ((i + 1) < orderByConditionFields.length) {
16928                                            if (orderByComparator.isAscending() ^ previous) {
16929                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16930                                            }
16931                                            else {
16932                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16933                                            }
16934                                    }
16935                                    else {
16936                                            if (orderByComparator.isAscending() ^ previous) {
16937                                                    query.append(WHERE_GREATER_THAN);
16938                                            }
16939                                            else {
16940                                                    query.append(WHERE_LESSER_THAN);
16941                                            }
16942                                    }
16943                            }
16944    
16945                            query.append(ORDER_BY_CLAUSE);
16946    
16947                            String[] orderByFields = orderByComparator.getOrderByFields();
16948    
16949                            for (int i = 0; i < orderByFields.length; i++) {
16950                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16951                                    query.append(orderByFields[i]);
16952    
16953                                    if ((i + 1) < orderByFields.length) {
16954                                            if (orderByComparator.isAscending() ^ previous) {
16955                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16956                                            }
16957                                            else {
16958                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16959                                            }
16960                                    }
16961                                    else {
16962                                            if (orderByComparator.isAscending() ^ previous) {
16963                                                    query.append(ORDER_BY_ASC);
16964                                            }
16965                                            else {
16966                                                    query.append(ORDER_BY_DESC);
16967                                            }
16968                                    }
16969                            }
16970                    }
16971                    else {
16972                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16973                    }
16974    
16975                    String sql = query.toString();
16976    
16977                    Query q = session.createQuery(sql);
16978    
16979                    q.setFirstResult(0);
16980                    q.setMaxResults(2);
16981    
16982                    QueryPos qPos = QueryPos.getInstance(q);
16983    
16984                    qPos.add(groupId);
16985    
16986                    qPos.add(userId);
16987    
16988                    if (bindDisplayDate) {
16989                            qPos.add(new Timestamp(displayDate.getTime()));
16990                    }
16991    
16992                    qPos.add(status);
16993    
16994                    if (orderByComparator != null) {
16995                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16996    
16997                            for (Object value : values) {
16998                                    qPos.add(value);
16999                            }
17000                    }
17001    
17002                    List<BlogsEntry> list = q.list();
17003    
17004                    if (list.size() == 2) {
17005                            return list.get(1);
17006                    }
17007                    else {
17008                            return null;
17009                    }
17010            }
17011    
17012            /**
17013             * 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;.
17014             *
17015             * @param groupId the group ID
17016             * @param userId the user ID
17017             * @param displayDate the display date
17018             * @param status the status
17019             * @return the matching blogs entries that the user has permission to view
17020             */
17021            @Override
17022            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17023                    Date displayDate, int status) {
17024                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17025                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17026            }
17027    
17028            /**
17029             * 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;.
17030             *
17031             * <p>
17032             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
17033             * </p>
17034             *
17035             * @param groupId the group ID
17036             * @param userId the user ID
17037             * @param displayDate the display date
17038             * @param status the status
17039             * @param start the lower bound of the range of blogs entries
17040             * @param end the upper bound of the range of blogs entries (not inclusive)
17041             * @return the range of matching blogs entries that the user has permission to view
17042             */
17043            @Override
17044            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17045                    Date displayDate, int status, int start, int end) {
17046                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17047                            start, end, null);
17048            }
17049    
17050            /**
17051             * 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;.
17052             *
17053             * <p>
17054             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
17055             * </p>
17056             *
17057             * @param groupId the group ID
17058             * @param userId the user ID
17059             * @param displayDate the display date
17060             * @param status the status
17061             * @param start the lower bound of the range of blogs entries
17062             * @param end the upper bound of the range of blogs entries (not inclusive)
17063             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17064             * @return the ordered range of matching blogs entries that the user has permission to view
17065             */
17066            @Override
17067            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17068                    Date displayDate, int status, int start, int end,
17069                    OrderByComparator<BlogsEntry> orderByComparator) {
17070                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17071                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17072                                    start, end, orderByComparator);
17073                    }
17074    
17075                    StringBundler query = null;
17076    
17077                    if (orderByComparator != null) {
17078                            query = new StringBundler(6 +
17079                                            (orderByComparator.getOrderByFields().length * 3));
17080                    }
17081                    else {
17082                            query = new StringBundler(6);
17083                    }
17084    
17085                    if (getDB().isSupportsInlineDistinct()) {
17086                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17087                    }
17088                    else {
17089                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17090                    }
17091    
17092                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17093    
17094                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17095    
17096                    boolean bindDisplayDate = false;
17097    
17098                    if (displayDate == null) {
17099                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17100                    }
17101                    else {
17102                            bindDisplayDate = true;
17103    
17104                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17105                    }
17106    
17107                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17108    
17109                    if (!getDB().isSupportsInlineDistinct()) {
17110                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17111                    }
17112    
17113                    if (orderByComparator != null) {
17114                            if (getDB().isSupportsInlineDistinct()) {
17115                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17116                                            orderByComparator, true);
17117                            }
17118                            else {
17119                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17120                                            orderByComparator, true);
17121                            }
17122                    }
17123                    else {
17124                            if (getDB().isSupportsInlineDistinct()) {
17125                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17126                            }
17127                            else {
17128                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17129                            }
17130                    }
17131    
17132                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17133                                    BlogsEntry.class.getName(),
17134                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17135    
17136                    Session session = null;
17137    
17138                    try {
17139                            session = openSession();
17140    
17141                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17142    
17143                            if (getDB().isSupportsInlineDistinct()) {
17144                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17145                            }
17146                            else {
17147                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17148                            }
17149    
17150                            QueryPos qPos = QueryPos.getInstance(q);
17151    
17152                            qPos.add(groupId);
17153    
17154                            qPos.add(userId);
17155    
17156                            if (bindDisplayDate) {
17157                                    qPos.add(new Timestamp(displayDate.getTime()));
17158                            }
17159    
17160                            qPos.add(status);
17161    
17162                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17163                    }
17164                    catch (Exception e) {
17165                            throw processException(e);
17166                    }
17167                    finally {
17168                            closeSession(session);
17169                    }
17170            }
17171    
17172            /**
17173             * 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;.
17174             *
17175             * @param entryId the primary key of the current blogs entry
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 previous, current, and next blogs entry
17182             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17183             */
17184            @Override
17185            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
17186                    long groupId, long userId, Date displayDate, int status,
17187                    OrderByComparator<BlogsEntry> orderByComparator)
17188                    throws NoSuchEntryException {
17189                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17190                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
17191                                    displayDate, status, orderByComparator);
17192                    }
17193    
17194                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17195    
17196                    Session session = null;
17197    
17198                    try {
17199                            session = openSession();
17200    
17201                            BlogsEntry[] array = new BlogsEntryImpl[3];
17202    
17203                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17204                                            groupId, userId, displayDate, status, orderByComparator,
17205                                            true);
17206    
17207                            array[1] = blogsEntry;
17208    
17209                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17210                                            groupId, userId, displayDate, status, orderByComparator,
17211                                            false);
17212    
17213                            return array;
17214                    }
17215                    catch (Exception e) {
17216                            throw processException(e);
17217                    }
17218                    finally {
17219                            closeSession(session);
17220                    }
17221            }
17222    
17223            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
17224                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17225                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17226                    boolean previous) {
17227                    StringBundler query = null;
17228    
17229                    if (orderByComparator != null) {
17230                            query = new StringBundler(6 +
17231                                            (orderByComparator.getOrderByFields().length * 6));
17232                    }
17233                    else {
17234                            query = new StringBundler(3);
17235                    }
17236    
17237                    if (getDB().isSupportsInlineDistinct()) {
17238                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17239                    }
17240                    else {
17241                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17242                    }
17243    
17244                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17245    
17246                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17247    
17248                    boolean bindDisplayDate = false;
17249    
17250                    if (displayDate == null) {
17251                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17252                    }
17253                    else {
17254                            bindDisplayDate = true;
17255    
17256                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17257                    }
17258    
17259                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17260    
17261                    if (!getDB().isSupportsInlineDistinct()) {
17262                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17263                    }
17264    
17265                    if (orderByComparator != null) {
17266                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17267    
17268                            if (orderByConditionFields.length > 0) {
17269                                    query.append(WHERE_AND);
17270                            }
17271    
17272                            for (int i = 0; i < orderByConditionFields.length; i++) {
17273                                    if (getDB().isSupportsInlineDistinct()) {
17274                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17275                                    }
17276                                    else {
17277                                            query.append(_ORDER_BY_ENTITY_TABLE);
17278                                    }
17279    
17280                                    query.append(orderByConditionFields[i]);
17281    
17282                                    if ((i + 1) < orderByConditionFields.length) {
17283                                            if (orderByComparator.isAscending() ^ previous) {
17284                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17285                                            }
17286                                            else {
17287                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17288                                            }
17289                                    }
17290                                    else {
17291                                            if (orderByComparator.isAscending() ^ previous) {
17292                                                    query.append(WHERE_GREATER_THAN);
17293                                            }
17294                                            else {
17295                                                    query.append(WHERE_LESSER_THAN);
17296                                            }
17297                                    }
17298                            }
17299    
17300                            query.append(ORDER_BY_CLAUSE);
17301    
17302                            String[] orderByFields = orderByComparator.getOrderByFields();
17303    
17304                            for (int i = 0; i < orderByFields.length; i++) {
17305                                    if (getDB().isSupportsInlineDistinct()) {
17306                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17307                                    }
17308                                    else {
17309                                            query.append(_ORDER_BY_ENTITY_TABLE);
17310                                    }
17311    
17312                                    query.append(orderByFields[i]);
17313    
17314                                    if ((i + 1) < orderByFields.length) {
17315                                            if (orderByComparator.isAscending() ^ previous) {
17316                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17317                                            }
17318                                            else {
17319                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17320                                            }
17321                                    }
17322                                    else {
17323                                            if (orderByComparator.isAscending() ^ previous) {
17324                                                    query.append(ORDER_BY_ASC);
17325                                            }
17326                                            else {
17327                                                    query.append(ORDER_BY_DESC);
17328                                            }
17329                                    }
17330                            }
17331                    }
17332                    else {
17333                            if (getDB().isSupportsInlineDistinct()) {
17334                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17335                            }
17336                            else {
17337                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17338                            }
17339                    }
17340    
17341                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17342                                    BlogsEntry.class.getName(),
17343                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17344    
17345                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17346    
17347                    q.setFirstResult(0);
17348                    q.setMaxResults(2);
17349    
17350                    if (getDB().isSupportsInlineDistinct()) {
17351                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17352                    }
17353                    else {
17354                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17355                    }
17356    
17357                    QueryPos qPos = QueryPos.getInstance(q);
17358    
17359                    qPos.add(groupId);
17360    
17361                    qPos.add(userId);
17362    
17363                    if (bindDisplayDate) {
17364                            qPos.add(new Timestamp(displayDate.getTime()));
17365                    }
17366    
17367                    qPos.add(status);
17368    
17369                    if (orderByComparator != null) {
17370                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17371    
17372                            for (Object value : values) {
17373                                    qPos.add(value);
17374                            }
17375                    }
17376    
17377                    List<BlogsEntry> list = q.list();
17378    
17379                    if (list.size() == 2) {
17380                            return list.get(1);
17381                    }
17382                    else {
17383                            return null;
17384                    }
17385            }
17386    
17387            /**
17388             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
17389             *
17390             * @param groupId the group ID
17391             * @param userId the user ID
17392             * @param displayDate the display date
17393             * @param status the status
17394             */
17395            @Override
17396            public void removeByG_U_LtD_NotS(long groupId, long userId,
17397                    Date displayDate, int status) {
17398                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
17399                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17400                            remove(blogsEntry);
17401                    }
17402            }
17403    
17404            /**
17405             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17406             *
17407             * @param groupId the group ID
17408             * @param userId the user ID
17409             * @param displayDate the display date
17410             * @param status the status
17411             * @return the number of matching blogs entries
17412             */
17413            @Override
17414            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
17415                    int status) {
17416                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
17417    
17418                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17419    
17420                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17421                                    this);
17422    
17423                    if (count == null) {
17424                            StringBundler query = new StringBundler(5);
17425    
17426                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17427    
17428                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17429    
17430                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17431    
17432                            boolean bindDisplayDate = false;
17433    
17434                            if (displayDate == null) {
17435                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17436                            }
17437                            else {
17438                                    bindDisplayDate = true;
17439    
17440                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17441                            }
17442    
17443                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17444    
17445                            String sql = query.toString();
17446    
17447                            Session session = null;
17448    
17449                            try {
17450                                    session = openSession();
17451    
17452                                    Query q = session.createQuery(sql);
17453    
17454                                    QueryPos qPos = QueryPos.getInstance(q);
17455    
17456                                    qPos.add(groupId);
17457    
17458                                    qPos.add(userId);
17459    
17460                                    if (bindDisplayDate) {
17461                                            qPos.add(new Timestamp(displayDate.getTime()));
17462                                    }
17463    
17464                                    qPos.add(status);
17465    
17466                                    count = (Long)q.uniqueResult();
17467    
17468                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17469                            }
17470                            catch (Exception e) {
17471                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17472    
17473                                    throw processException(e);
17474                            }
17475                            finally {
17476                                    closeSession(session);
17477                            }
17478                    }
17479    
17480                    return count.intValue();
17481            }
17482    
17483            /**
17484             * 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;.
17485             *
17486             * @param groupId the group ID
17487             * @param userId the user ID
17488             * @param displayDate the display date
17489             * @param status the status
17490             * @return the number of matching blogs entries that the user has permission to view
17491             */
17492            @Override
17493            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
17494                    Date displayDate, int status) {
17495                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17496                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
17497                    }
17498    
17499                    StringBundler query = new StringBundler(5);
17500    
17501                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17502    
17503                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17504    
17505                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17506    
17507                    boolean bindDisplayDate = false;
17508    
17509                    if (displayDate == null) {
17510                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17511                    }
17512                    else {
17513                            bindDisplayDate = true;
17514    
17515                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17516                    }
17517    
17518                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17519    
17520                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17521                                    BlogsEntry.class.getName(),
17522                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17523    
17524                    Session session = null;
17525    
17526                    try {
17527                            session = openSession();
17528    
17529                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17530    
17531                            q.addScalar(COUNT_COLUMN_NAME,
17532                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17533    
17534                            QueryPos qPos = QueryPos.getInstance(q);
17535    
17536                            qPos.add(groupId);
17537    
17538                            qPos.add(userId);
17539    
17540                            if (bindDisplayDate) {
17541                                    qPos.add(new Timestamp(displayDate.getTime()));
17542                            }
17543    
17544                            qPos.add(status);
17545    
17546                            Long count = (Long)q.uniqueResult();
17547    
17548                            return count.intValue();
17549                    }
17550                    catch (Exception e) {
17551                            throw processException(e);
17552                    }
17553                    finally {
17554                            closeSession(session);
17555                    }
17556            }
17557    
17558            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17559            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
17560            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
17561            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17562            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
17563    
17564            public BlogsEntryPersistenceImpl() {
17565                    setModelClass(BlogsEntry.class);
17566            }
17567    
17568            /**
17569             * Caches the blogs entry in the entity cache if it is enabled.
17570             *
17571             * @param blogsEntry the blogs entry
17572             */
17573            @Override
17574            public void cacheResult(BlogsEntry blogsEntry) {
17575                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17576                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
17577    
17578                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
17579                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
17580                            blogsEntry);
17581    
17582                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
17583                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
17584                            blogsEntry);
17585    
17586                    blogsEntry.resetOriginalValues();
17587            }
17588    
17589            /**
17590             * Caches the blogs entries in the entity cache if it is enabled.
17591             *
17592             * @param blogsEntries the blogs entries
17593             */
17594            @Override
17595            public void cacheResult(List<BlogsEntry> blogsEntries) {
17596                    for (BlogsEntry blogsEntry : blogsEntries) {
17597                            if (EntityCacheUtil.getResult(
17598                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17599                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
17600                                    cacheResult(blogsEntry);
17601                            }
17602                            else {
17603                                    blogsEntry.resetOriginalValues();
17604                            }
17605                    }
17606            }
17607    
17608            /**
17609             * Clears the cache for all blogs entries.
17610             *
17611             * <p>
17612             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17613             * </p>
17614             */
17615            @Override
17616            public void clearCache() {
17617                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
17618                            CacheRegistryUtil.clear(BlogsEntryImpl.class.getName());
17619                    }
17620    
17621                    EntityCacheUtil.clearCache(BlogsEntryImpl.class);
17622    
17623                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
17624                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17625                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17626            }
17627    
17628            /**
17629             * Clears the cache for the blogs entry.
17630             *
17631             * <p>
17632             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17633             * </p>
17634             */
17635            @Override
17636            public void clearCache(BlogsEntry blogsEntry) {
17637                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17638                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17639    
17640                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17641                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17642    
17643                    clearUniqueFindersCache(blogsEntry);
17644            }
17645    
17646            @Override
17647            public void clearCache(List<BlogsEntry> blogsEntries) {
17648                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17649                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17650    
17651                    for (BlogsEntry blogsEntry : blogsEntries) {
17652                            EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17653                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17654    
17655                            clearUniqueFindersCache(blogsEntry);
17656                    }
17657            }
17658    
17659            protected void cacheUniqueFindersCache(BlogsEntry blogsEntry) {
17660                    if (blogsEntry.isNew()) {
17661                            Object[] args = new Object[] {
17662                                            blogsEntry.getUuid(), blogsEntry.getGroupId()
17663                                    };
17664    
17665                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17666                                    Long.valueOf(1));
17667                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17668                                    blogsEntry);
17669    
17670                            args = new Object[] {
17671                                            blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
17672                                    };
17673    
17674                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17675                                    Long.valueOf(1));
17676                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17677                                    blogsEntry);
17678                    }
17679                    else {
17680                            BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17681    
17682                            if ((blogsEntryModelImpl.getColumnBitmask() &
17683                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17684                                    Object[] args = new Object[] {
17685                                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
17686                                            };
17687    
17688                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17689                                            Long.valueOf(1));
17690                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17691                                            blogsEntry);
17692                            }
17693    
17694                            if ((blogsEntryModelImpl.getColumnBitmask() &
17695                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17696                                    Object[] args = new Object[] {
17697                                                    blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
17698                                            };
17699    
17700                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17701                                            Long.valueOf(1));
17702                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17703                                            blogsEntry);
17704                            }
17705                    }
17706            }
17707    
17708            protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
17709                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17710    
17711                    Object[] args = new Object[] {
17712                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
17713                            };
17714    
17715                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17716                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17717    
17718                    if ((blogsEntryModelImpl.getColumnBitmask() &
17719                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17720                            args = new Object[] {
17721                                            blogsEntryModelImpl.getOriginalUuid(),
17722                                            blogsEntryModelImpl.getOriginalGroupId()
17723                                    };
17724    
17725                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17726                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17727                    }
17728    
17729                    args = new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() };
17730    
17731                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17732                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17733    
17734                    if ((blogsEntryModelImpl.getColumnBitmask() &
17735                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17736                            args = new Object[] {
17737                                            blogsEntryModelImpl.getOriginalGroupId(),
17738                                            blogsEntryModelImpl.getOriginalUrlTitle()
17739                                    };
17740    
17741                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17742                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17743                    }
17744            }
17745    
17746            /**
17747             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
17748             *
17749             * @param entryId the primary key for the new blogs entry
17750             * @return the new blogs entry
17751             */
17752            @Override
17753            public BlogsEntry create(long entryId) {
17754                    BlogsEntry blogsEntry = new BlogsEntryImpl();
17755    
17756                    blogsEntry.setNew(true);
17757                    blogsEntry.setPrimaryKey(entryId);
17758    
17759                    String uuid = PortalUUIDUtil.generate();
17760    
17761                    blogsEntry.setUuid(uuid);
17762    
17763                    return blogsEntry;
17764            }
17765    
17766            /**
17767             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
17768             *
17769             * @param entryId the primary key of the blogs entry
17770             * @return the blogs entry that was removed
17771             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17772             */
17773            @Override
17774            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
17775                    return remove((Serializable)entryId);
17776            }
17777    
17778            /**
17779             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
17780             *
17781             * @param primaryKey the primary key of the blogs entry
17782             * @return the blogs entry that was removed
17783             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
17784             */
17785            @Override
17786            public BlogsEntry remove(Serializable primaryKey)
17787                    throws NoSuchEntryException {
17788                    Session session = null;
17789    
17790                    try {
17791                            session = openSession();
17792    
17793                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17794                                            primaryKey);
17795    
17796                            if (blogsEntry == null) {
17797                                    if (_log.isWarnEnabled()) {
17798                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
17799                                    }
17800    
17801                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
17802                                            primaryKey);
17803                            }
17804    
17805                            return remove(blogsEntry);
17806                    }
17807                    catch (NoSuchEntryException nsee) {
17808                            throw nsee;
17809                    }
17810                    catch (Exception e) {
17811                            throw processException(e);
17812                    }
17813                    finally {
17814                            closeSession(session);
17815                    }
17816            }
17817    
17818            @Override
17819            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
17820                    blogsEntry = toUnwrappedModel(blogsEntry);
17821    
17822                    Session session = null;
17823    
17824                    try {
17825                            session = openSession();
17826    
17827                            if (!session.contains(blogsEntry)) {
17828                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17829                                                    blogsEntry.getPrimaryKeyObj());
17830                            }
17831    
17832                            if (blogsEntry != null) {
17833                                    session.delete(blogsEntry);
17834                            }
17835                    }
17836                    catch (Exception e) {
17837                            throw processException(e);
17838                    }
17839                    finally {
17840                            closeSession(session);
17841                    }
17842    
17843                    if (blogsEntry != null) {
17844                            clearCache(blogsEntry);
17845                    }
17846    
17847                    return blogsEntry;
17848            }
17849    
17850            @Override
17851            public BlogsEntry updateImpl(
17852                    com.liferay.portlet.blogs.model.BlogsEntry blogsEntry) {
17853                    blogsEntry = toUnwrappedModel(blogsEntry);
17854    
17855                    boolean isNew = blogsEntry.isNew();
17856    
17857                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17858    
17859                    if (Validator.isNull(blogsEntry.getUuid())) {
17860                            String uuid = PortalUUIDUtil.generate();
17861    
17862                            blogsEntry.setUuid(uuid);
17863                    }
17864    
17865                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
17866    
17867                    if (userId > 0) {
17868                            long companyId = blogsEntry.getCompanyId();
17869    
17870                            long groupId = blogsEntry.getGroupId();
17871    
17872                            long entryId = 0;
17873    
17874                            if (!isNew) {
17875                                    entryId = blogsEntry.getPrimaryKey();
17876                            }
17877    
17878                            try {
17879                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
17880                                                    userId,
17881                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
17882                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
17883                                                    blogsEntry.getTitle(), null));
17884    
17885                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
17886                                                    groupId, userId,
17887                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
17888                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
17889                                                    blogsEntry.getContent(), null));
17890                            }
17891                            catch (SanitizerException se) {
17892                                    throw new SystemException(se);
17893                            }
17894                    }
17895    
17896                    Session session = null;
17897    
17898                    try {
17899                            session = openSession();
17900    
17901                            if (blogsEntry.isNew()) {
17902                                    session.save(blogsEntry);
17903    
17904                                    blogsEntry.setNew(false);
17905                            }
17906                            else {
17907                                    session.merge(blogsEntry);
17908                            }
17909                    }
17910                    catch (Exception e) {
17911                            throw processException(e);
17912                    }
17913                    finally {
17914                            closeSession(session);
17915                    }
17916    
17917                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17918    
17919                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
17920                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17921                    }
17922    
17923                    else {
17924                            if ((blogsEntryModelImpl.getColumnBitmask() &
17925                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
17926                                    Object[] args = new Object[] {
17927                                                    blogsEntryModelImpl.getOriginalUuid()
17928                                            };
17929    
17930                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17931                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17932                                            args);
17933    
17934                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
17935    
17936                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17937                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17938                                            args);
17939                            }
17940    
17941                            if ((blogsEntryModelImpl.getColumnBitmask() &
17942                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
17943                                    Object[] args = new Object[] {
17944                                                    blogsEntryModelImpl.getOriginalUuid(),
17945                                                    blogsEntryModelImpl.getOriginalCompanyId()
17946                                            };
17947    
17948                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17949                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17950                                            args);
17951    
17952                                    args = new Object[] {
17953                                                    blogsEntryModelImpl.getUuid(),
17954                                                    blogsEntryModelImpl.getCompanyId()
17955                                            };
17956    
17957                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17958                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17959                                            args);
17960                            }
17961    
17962                            if ((blogsEntryModelImpl.getColumnBitmask() &
17963                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
17964                                    Object[] args = new Object[] {
17965                                                    blogsEntryModelImpl.getOriginalGroupId()
17966                                            };
17967    
17968                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17969                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17970                                            args);
17971    
17972                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
17973    
17974                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17975                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17976                                            args);
17977                            }
17978    
17979                            if ((blogsEntryModelImpl.getColumnBitmask() &
17980                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
17981                                    Object[] args = new Object[] {
17982                                                    blogsEntryModelImpl.getOriginalCompanyId()
17983                                            };
17984    
17985                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
17986                                            args);
17987                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
17988                                            args);
17989    
17990                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
17991    
17992                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
17993                                            args);
17994                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
17995                                            args);
17996                            }
17997    
17998                            if ((blogsEntryModelImpl.getColumnBitmask() &
17999                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18000                                    Object[] args = new Object[] {
18001                                                    blogsEntryModelImpl.getOriginalGroupId(),
18002                                                    blogsEntryModelImpl.getOriginalStatus()
18003                                            };
18004    
18005                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18006                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18007                                            args);
18008    
18009                                    args = new Object[] {
18010                                                    blogsEntryModelImpl.getGroupId(),
18011                                                    blogsEntryModelImpl.getStatus()
18012                                            };
18013    
18014                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18015                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18016                                            args);
18017                            }
18018    
18019                            if ((blogsEntryModelImpl.getColumnBitmask() &
18020                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
18021                                    Object[] args = new Object[] {
18022                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18023                                                    blogsEntryModelImpl.getOriginalUserId()
18024                                            };
18025    
18026                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18027                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18028                                            args);
18029    
18030                                    args = new Object[] {
18031                                                    blogsEntryModelImpl.getCompanyId(),
18032                                                    blogsEntryModelImpl.getUserId()
18033                                            };
18034    
18035                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18036                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18037                                            args);
18038                            }
18039    
18040                            if ((blogsEntryModelImpl.getColumnBitmask() &
18041                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18042                                    Object[] args = new Object[] {
18043                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18044                                                    blogsEntryModelImpl.getOriginalStatus()
18045                                            };
18046    
18047                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18048                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18049                                            args);
18050    
18051                                    args = new Object[] {
18052                                                    blogsEntryModelImpl.getCompanyId(),
18053                                                    blogsEntryModelImpl.getStatus()
18054                                            };
18055    
18056                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18057                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18058                                            args);
18059                            }
18060    
18061                            if ((blogsEntryModelImpl.getColumnBitmask() &
18062                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18063                                    Object[] args = new Object[] {
18064                                                    blogsEntryModelImpl.getOriginalGroupId(),
18065                                                    blogsEntryModelImpl.getOriginalUserId(),
18066                                                    blogsEntryModelImpl.getOriginalStatus()
18067                                            };
18068    
18069                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18070                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18071                                            args);
18072    
18073                                    args = new Object[] {
18074                                                    blogsEntryModelImpl.getGroupId(),
18075                                                    blogsEntryModelImpl.getUserId(),
18076                                                    blogsEntryModelImpl.getStatus()
18077                                            };
18078    
18079                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18080                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18081                                            args);
18082                            }
18083    
18084                            if ((blogsEntryModelImpl.getColumnBitmask() &
18085                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18086                                    Object[] args = new Object[] {
18087                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18088                                                    blogsEntryModelImpl.getOriginalUserId(),
18089                                                    blogsEntryModelImpl.getOriginalStatus()
18090                                            };
18091    
18092                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18093                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18094                                            args);
18095    
18096                                    args = new Object[] {
18097                                                    blogsEntryModelImpl.getCompanyId(),
18098                                                    blogsEntryModelImpl.getUserId(),
18099                                                    blogsEntryModelImpl.getStatus()
18100                                            };
18101    
18102                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18103                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18104                                            args);
18105                            }
18106                    }
18107    
18108                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18109                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry, false);
18110    
18111                    clearUniqueFindersCache(blogsEntry);
18112                    cacheUniqueFindersCache(blogsEntry);
18113    
18114                    blogsEntry.resetOriginalValues();
18115    
18116                    return blogsEntry;
18117            }
18118    
18119            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18120                    if (blogsEntry instanceof BlogsEntryImpl) {
18121                            return blogsEntry;
18122                    }
18123    
18124                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18125    
18126                    blogsEntryImpl.setNew(blogsEntry.isNew());
18127                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18128    
18129                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
18130                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18131                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18132                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18133                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
18134                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
18135                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18136                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18137                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
18138                    blogsEntryImpl.setSubtitle(blogsEntry.getSubtitle());
18139                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18140                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
18141                    blogsEntryImpl.setContent(blogsEntry.getContent());
18142                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18143                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18144                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18145                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18146                    blogsEntryImpl.setCoverImageFileEntryId(blogsEntry.getCoverImageFileEntryId());
18147                    blogsEntryImpl.setCoverImageURL(blogsEntry.getCoverImageURL());
18148                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18149                    blogsEntryImpl.setSmallImageFileEntryId(blogsEntry.getSmallImageFileEntryId());
18150                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18151                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18152                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
18153                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18154                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18155                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18156    
18157                    return blogsEntryImpl;
18158            }
18159    
18160            /**
18161             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
18162             *
18163             * @param primaryKey the primary key of the blogs entry
18164             * @return the blogs entry
18165             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18166             */
18167            @Override
18168            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18169                    throws NoSuchEntryException {
18170                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18171    
18172                    if (blogsEntry == null) {
18173                            if (_log.isWarnEnabled()) {
18174                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18175                            }
18176    
18177                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18178                                    primaryKey);
18179                    }
18180    
18181                    return blogsEntry;
18182            }
18183    
18184            /**
18185             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portlet.blogs.NoSuchEntryException} if it could not be found.
18186             *
18187             * @param entryId the primary key of the blogs entry
18188             * @return the blogs entry
18189             * @throws com.liferay.portlet.blogs.NoSuchEntryException if a blogs entry with the primary key could not be found
18190             */
18191            @Override
18192            public BlogsEntry findByPrimaryKey(long entryId)
18193                    throws NoSuchEntryException {
18194                    return findByPrimaryKey((Serializable)entryId);
18195            }
18196    
18197            /**
18198             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18199             *
18200             * @param primaryKey the primary key of the blogs entry
18201             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18202             */
18203            @Override
18204            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey) {
18205                    BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18206                                    BlogsEntryImpl.class, primaryKey);
18207    
18208                    if (blogsEntry == _nullBlogsEntry) {
18209                            return null;
18210                    }
18211    
18212                    if (blogsEntry == null) {
18213                            Session session = null;
18214    
18215                            try {
18216                                    session = openSession();
18217    
18218                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18219                                                    primaryKey);
18220    
18221                                    if (blogsEntry != null) {
18222                                            cacheResult(blogsEntry);
18223                                    }
18224                                    else {
18225                                            EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18226                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18227                                    }
18228                            }
18229                            catch (Exception e) {
18230                                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18231                                            BlogsEntryImpl.class, primaryKey);
18232    
18233                                    throw processException(e);
18234                            }
18235                            finally {
18236                                    closeSession(session);
18237                            }
18238                    }
18239    
18240                    return blogsEntry;
18241            }
18242    
18243            /**
18244             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18245             *
18246             * @param entryId the primary key of the blogs entry
18247             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18248             */
18249            @Override
18250            public BlogsEntry fetchByPrimaryKey(long entryId) {
18251                    return fetchByPrimaryKey((Serializable)entryId);
18252            }
18253    
18254            @Override
18255            public Map<Serializable, BlogsEntry> fetchByPrimaryKeys(
18256                    Set<Serializable> primaryKeys) {
18257                    if (primaryKeys.isEmpty()) {
18258                            return Collections.emptyMap();
18259                    }
18260    
18261                    Map<Serializable, BlogsEntry> map = new HashMap<Serializable, BlogsEntry>();
18262    
18263                    if (primaryKeys.size() == 1) {
18264                            Iterator<Serializable> iterator = primaryKeys.iterator();
18265    
18266                            Serializable primaryKey = iterator.next();
18267    
18268                            BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18269    
18270                            if (blogsEntry != null) {
18271                                    map.put(primaryKey, blogsEntry);
18272                            }
18273    
18274                            return map;
18275                    }
18276    
18277                    Set<Serializable> uncachedPrimaryKeys = null;
18278    
18279                    for (Serializable primaryKey : primaryKeys) {
18280                            BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18281                                            BlogsEntryImpl.class, primaryKey);
18282    
18283                            if (blogsEntry == null) {
18284                                    if (uncachedPrimaryKeys == null) {
18285                                            uncachedPrimaryKeys = new HashSet<Serializable>();
18286                                    }
18287    
18288                                    uncachedPrimaryKeys.add(primaryKey);
18289                            }
18290                            else {
18291                                    map.put(primaryKey, blogsEntry);
18292                            }
18293                    }
18294    
18295                    if (uncachedPrimaryKeys == null) {
18296                            return map;
18297                    }
18298    
18299                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
18300                                    1);
18301    
18302                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN);
18303    
18304                    for (Serializable primaryKey : uncachedPrimaryKeys) {
18305                            query.append(String.valueOf(primaryKey));
18306    
18307                            query.append(StringPool.COMMA);
18308                    }
18309    
18310                    query.setIndex(query.index() - 1);
18311    
18312                    query.append(StringPool.CLOSE_PARENTHESIS);
18313    
18314                    String sql = query.toString();
18315    
18316                    Session session = null;
18317    
18318                    try {
18319                            session = openSession();
18320    
18321                            Query q = session.createQuery(sql);
18322    
18323                            for (BlogsEntry blogsEntry : (List<BlogsEntry>)q.list()) {
18324                                    map.put(blogsEntry.getPrimaryKeyObj(), blogsEntry);
18325    
18326                                    cacheResult(blogsEntry);
18327    
18328                                    uncachedPrimaryKeys.remove(blogsEntry.getPrimaryKeyObj());
18329                            }
18330    
18331                            for (Serializable primaryKey : uncachedPrimaryKeys) {
18332                                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18333                                            BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18334                            }
18335                    }
18336                    catch (Exception e) {
18337                            throw processException(e);
18338                    }
18339                    finally {
18340                            closeSession(session);
18341                    }
18342    
18343                    return map;
18344            }
18345    
18346            /**
18347             * Returns all the blogs entries.
18348             *
18349             * @return the blogs entries
18350             */
18351            @Override
18352            public List<BlogsEntry> findAll() {
18353                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18354            }
18355    
18356            /**
18357             * Returns a range of all the blogs entries.
18358             *
18359             * <p>
18360             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
18361             * </p>
18362             *
18363             * @param start the lower bound of the range of blogs entries
18364             * @param end the upper bound of the range of blogs entries (not inclusive)
18365             * @return the range of blogs entries
18366             */
18367            @Override
18368            public List<BlogsEntry> findAll(int start, int end) {
18369                    return findAll(start, end, null);
18370            }
18371    
18372            /**
18373             * Returns an ordered range of all the blogs entries.
18374             *
18375             * <p>
18376             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <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.
18377             * </p>
18378             *
18379             * @param start the lower bound of the range of blogs entries
18380             * @param end the upper bound of the range of blogs entries (not inclusive)
18381             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18382             * @return the ordered range of blogs entries
18383             */
18384            @Override
18385            public List<BlogsEntry> findAll(int start, int end,
18386                    OrderByComparator<BlogsEntry> orderByComparator) {
18387                    boolean pagination = true;
18388                    FinderPath finderPath = null;
18389                    Object[] finderArgs = null;
18390    
18391                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18392                                    (orderByComparator == null)) {
18393                            pagination = false;
18394                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
18395                            finderArgs = FINDER_ARGS_EMPTY;
18396                    }
18397                    else {
18398                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
18399                            finderArgs = new Object[] { start, end, orderByComparator };
18400                    }
18401    
18402                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
18403                                    finderArgs, this);
18404    
18405                    if (list == null) {
18406                            StringBundler query = null;
18407                            String sql = null;
18408    
18409                            if (orderByComparator != null) {
18410                                    query = new StringBundler(2 +
18411                                                    (orderByComparator.getOrderByFields().length * 3));
18412    
18413                                    query.append(_SQL_SELECT_BLOGSENTRY);
18414    
18415                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18416                                            orderByComparator);
18417    
18418                                    sql = query.toString();
18419                            }
18420                            else {
18421                                    sql = _SQL_SELECT_BLOGSENTRY;
18422    
18423                                    if (pagination) {
18424                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
18425                                    }
18426                            }
18427    
18428                            Session session = null;
18429    
18430                            try {
18431                                    session = openSession();
18432    
18433                                    Query q = session.createQuery(sql);
18434    
18435                                    if (!pagination) {
18436                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18437                                                            start, end, false);
18438    
18439                                            Collections.sort(list);
18440    
18441                                            list = Collections.unmodifiableList(list);
18442                                    }
18443                                    else {
18444                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18445                                                            start, end);
18446                                    }
18447    
18448                                    cacheResult(list);
18449    
18450                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18451                            }
18452                            catch (Exception e) {
18453                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18454    
18455                                    throw processException(e);
18456                            }
18457                            finally {
18458                                    closeSession(session);
18459                            }
18460                    }
18461    
18462                    return list;
18463            }
18464    
18465            /**
18466             * Removes all the blogs entries from the database.
18467             *
18468             */
18469            @Override
18470            public void removeAll() {
18471                    for (BlogsEntry blogsEntry : findAll()) {
18472                            remove(blogsEntry);
18473                    }
18474            }
18475    
18476            /**
18477             * Returns the number of blogs entries.
18478             *
18479             * @return the number of blogs entries
18480             */
18481            @Override
18482            public int countAll() {
18483                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18484                                    FINDER_ARGS_EMPTY, this);
18485    
18486                    if (count == null) {
18487                            Session session = null;
18488    
18489                            try {
18490                                    session = openSession();
18491    
18492                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
18493    
18494                                    count = (Long)q.uniqueResult();
18495    
18496                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18497                                            FINDER_ARGS_EMPTY, count);
18498                            }
18499                            catch (Exception e) {
18500                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
18501                                            FINDER_ARGS_EMPTY);
18502    
18503                                    throw processException(e);
18504                            }
18505                            finally {
18506                                    closeSession(session);
18507                            }
18508                    }
18509    
18510                    return count.intValue();
18511            }
18512    
18513            @Override
18514            protected Set<String> getBadColumnNames() {
18515                    return _badColumnNames;
18516            }
18517    
18518            /**
18519             * Initializes the blogs entry persistence.
18520             */
18521            public void afterPropertiesSet() {
18522            }
18523    
18524            public void destroy() {
18525                    EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
18526                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18527                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18528                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18529            }
18530    
18531            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
18532            private static final String _SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE entryId IN (";
18533            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
18534            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
18535            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
18536            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
18537            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
18538            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
18539                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
18540            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
18541                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
18542            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
18543            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
18544            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
18545            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
18546            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
18547            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
18548            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
18549            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
18550            private static final Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
18551            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
18552                                    "uuid"
18553                            });
18554            private static final BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
18555                            @Override
18556                            public Object clone() {
18557                                    return this;
18558                            }
18559    
18560                            @Override
18561                            public CacheModel<BlogsEntry> toCacheModel() {
18562                                    return _nullBlogsEntryCacheModel;
18563                            }
18564                    };
18565    
18566            private static final CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
18567                            @Override
18568                            public BlogsEntry toEntityModel() {
18569                                    return _nullBlogsEntry;
18570                            }
18571                    };
18572    }