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.dao.orm.EntityCache;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCache;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.SQLQuery;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.exception.SystemException;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.sanitizer.Sanitizer;
033    import com.liferay.portal.kernel.sanitizer.SanitizerException;
034    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
035    import com.liferay.portal.kernel.util.ContentTypes;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.OrderByComparator;
038    import com.liferay.portal.kernel.util.SetUtil;
039    import com.liferay.portal.kernel.util.StringBundler;
040    import com.liferay.portal.kernel.util.StringPool;
041    import com.liferay.portal.kernel.util.Validator;
042    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
043    import com.liferay.portal.model.CacheModel;
044    import com.liferay.portal.security.auth.PrincipalThreadLocal;
045    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046    import com.liferay.portal.service.ServiceContext;
047    import com.liferay.portal.service.ServiceContextThreadLocal;
048    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
049    
050    import com.liferay.portlet.blogs.NoSuchEntryException;
051    import com.liferay.portlet.blogs.model.BlogsEntry;
052    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
053    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
054    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
055    
056    import java.io.Serializable;
057    
058    import java.sql.Timestamp;
059    
060    import java.util.Collections;
061    import java.util.Date;
062    import java.util.HashMap;
063    import java.util.HashSet;
064    import java.util.Iterator;
065    import java.util.List;
066    import java.util.Map;
067    import java.util.Set;
068    
069    /**
070     * The persistence implementation for the blogs entry service.
071     *
072     * <p>
073     * Caching information and settings can be found in <code>portal.properties</code>
074     * </p>
075     *
076     * @author Brian Wing Shun Chan
077     * @see BlogsEntryPersistence
078     * @see com.liferay.portlet.blogs.service.persistence.BlogsEntryUtil
079     * @generated
080     */
081    @ProviderType
082    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
083            implements BlogsEntryPersistence {
084            /*
085             * NOTE FOR DEVELOPERS:
086             *
087             * 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.
088             */
089            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
090            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091                    ".List1";
092            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
093                    ".List2";
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
095                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
098                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
100            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
101                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
103            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
106                            new String[] {
107                                    String.class.getName(),
108                                    
109                            Integer.class.getName(), Integer.class.getName(),
110                                    OrderByComparator.class.getName()
111                            });
112            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
113                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
115                            new String[] { String.class.getName() },
116                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
117                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
118                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
119            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
120                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
122                            new String[] { String.class.getName() });
123    
124            /**
125             * Returns all the blogs entries where uuid = &#63;.
126             *
127             * @param uuid the uuid
128             * @return the matching blogs entries
129             */
130            @Override
131            public List<BlogsEntry> findByUuid(String uuid) {
132                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
133            }
134    
135            /**
136             * Returns a range of all the blogs entries where uuid = &#63;.
137             *
138             * <p>
139             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
140             * </p>
141             *
142             * @param uuid the uuid
143             * @param start the lower bound of the range of blogs entries
144             * @param end the upper bound of the range of blogs entries (not inclusive)
145             * @return the range of matching blogs entries
146             */
147            @Override
148            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
149                    return findByUuid(uuid, start, end, null);
150            }
151    
152            /**
153             * Returns an ordered range of all the blogs entries where uuid = &#63;.
154             *
155             * <p>
156             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
157             * </p>
158             *
159             * @param uuid the uuid
160             * @param start the lower bound of the range of blogs entries
161             * @param end the upper bound of the range of blogs entries (not inclusive)
162             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
163             * @return the ordered range of matching blogs entries
164             */
165            @Override
166            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
167                    OrderByComparator<BlogsEntry> orderByComparator) {
168                    return findByUuid(uuid, start, end, orderByComparator, true);
169            }
170    
171            /**
172             * Returns an ordered range of all the blogs entries where uuid = &#63;.
173             *
174             * <p>
175             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
176             * </p>
177             *
178             * @param uuid the uuid
179             * @param start the lower bound of the range of blogs entries
180             * @param end the upper bound of the range of blogs entries (not inclusive)
181             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
182             * @param retrieveFromCache whether to retrieve from the finder cache
183             * @return the ordered range of matching blogs entries
184             */
185            @Override
186            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
187                    OrderByComparator<BlogsEntry> orderByComparator,
188                    boolean retrieveFromCache) {
189                    boolean pagination = true;
190                    FinderPath finderPath = null;
191                    Object[] finderArgs = null;
192    
193                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
194                                    (orderByComparator == null)) {
195                            pagination = false;
196                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
197                            finderArgs = new Object[] { uuid };
198                    }
199                    else {
200                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
201                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
202                    }
203    
204                    List<BlogsEntry> list = null;
205    
206                    if (retrieveFromCache) {
207                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
208                                            finderArgs, this);
209    
210                            if ((list != null) && !list.isEmpty()) {
211                                    for (BlogsEntry blogsEntry : list) {
212                                            if (!Validator.equals(uuid, blogsEntry.getUuid())) {
213                                                    list = null;
214    
215                                                    break;
216                                            }
217                                    }
218                            }
219                    }
220    
221                    if (list == null) {
222                            StringBundler query = null;
223    
224                            if (orderByComparator != null) {
225                                    query = new StringBundler(3 +
226                                                    (orderByComparator.getOrderByFields().length * 3));
227                            }
228                            else {
229                                    query = new StringBundler(3);
230                            }
231    
232                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
233    
234                            boolean bindUuid = false;
235    
236                            if (uuid == null) {
237                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
238                            }
239                            else if (uuid.equals(StringPool.BLANK)) {
240                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
241                            }
242                            else {
243                                    bindUuid = true;
244    
245                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
246                            }
247    
248                            if (orderByComparator != null) {
249                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
250                                            orderByComparator);
251                            }
252                            else
253                             if (pagination) {
254                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
255                            }
256    
257                            String sql = query.toString();
258    
259                            Session session = null;
260    
261                            try {
262                                    session = openSession();
263    
264                                    Query q = session.createQuery(sql);
265    
266                                    QueryPos qPos = QueryPos.getInstance(q);
267    
268                                    if (bindUuid) {
269                                            qPos.add(uuid);
270                                    }
271    
272                                    if (!pagination) {
273                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
274                                                            start, end, false);
275    
276                                            Collections.sort(list);
277    
278                                            list = Collections.unmodifiableList(list);
279                                    }
280                                    else {
281                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
282                                                            start, end);
283                                    }
284    
285                                    cacheResult(list);
286    
287                                    finderCache.putResult(finderPath, finderArgs, list);
288                            }
289                            catch (Exception e) {
290                                    finderCache.removeResult(finderPath, finderArgs);
291    
292                                    throw processException(e);
293                            }
294                            finally {
295                                    closeSession(session);
296                            }
297                    }
298    
299                    return list;
300            }
301    
302            /**
303             * Returns the first blogs entry in the ordered set where uuid = &#63;.
304             *
305             * @param uuid the uuid
306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
307             * @return the first matching blogs entry
308             * @throws NoSuchEntryException if a matching blogs entry could not be found
309             */
310            @Override
311            public BlogsEntry findByUuid_First(String uuid,
312                    OrderByComparator<BlogsEntry> orderByComparator)
313                    throws NoSuchEntryException {
314                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
315    
316                    if (blogsEntry != null) {
317                            return blogsEntry;
318                    }
319    
320                    StringBundler msg = new StringBundler(4);
321    
322                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
323    
324                    msg.append("uuid=");
325                    msg.append(uuid);
326    
327                    msg.append(StringPool.CLOSE_CURLY_BRACE);
328    
329                    throw new NoSuchEntryException(msg.toString());
330            }
331    
332            /**
333             * Returns the first blogs entry in the ordered set where uuid = &#63;.
334             *
335             * @param uuid the uuid
336             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
337             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
338             */
339            @Override
340            public BlogsEntry fetchByUuid_First(String uuid,
341                    OrderByComparator<BlogsEntry> orderByComparator) {
342                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
343    
344                    if (!list.isEmpty()) {
345                            return list.get(0);
346                    }
347    
348                    return null;
349            }
350    
351            /**
352             * Returns the last blogs entry in the ordered set where uuid = &#63;.
353             *
354             * @param uuid the uuid
355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
356             * @return the last matching blogs entry
357             * @throws NoSuchEntryException if a matching blogs entry could not be found
358             */
359            @Override
360            public BlogsEntry findByUuid_Last(String uuid,
361                    OrderByComparator<BlogsEntry> orderByComparator)
362                    throws NoSuchEntryException {
363                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
364    
365                    if (blogsEntry != null) {
366                            return blogsEntry;
367                    }
368    
369                    StringBundler msg = new StringBundler(4);
370    
371                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
372    
373                    msg.append("uuid=");
374                    msg.append(uuid);
375    
376                    msg.append(StringPool.CLOSE_CURLY_BRACE);
377    
378                    throw new NoSuchEntryException(msg.toString());
379            }
380    
381            /**
382             * Returns the last blogs entry in the ordered set where uuid = &#63;.
383             *
384             * @param uuid the uuid
385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
386             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
387             */
388            @Override
389            public BlogsEntry fetchByUuid_Last(String uuid,
390                    OrderByComparator<BlogsEntry> orderByComparator) {
391                    int count = countByUuid(uuid);
392    
393                    if (count == 0) {
394                            return null;
395                    }
396    
397                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
398                                    orderByComparator);
399    
400                    if (!list.isEmpty()) {
401                            return list.get(0);
402                    }
403    
404                    return null;
405            }
406    
407            /**
408             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
409             *
410             * @param entryId the primary key of the current blogs entry
411             * @param uuid the uuid
412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
413             * @return the previous, current, and next blogs entry
414             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
415             */
416            @Override
417            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
418                    OrderByComparator<BlogsEntry> orderByComparator)
419                    throws NoSuchEntryException {
420                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
421    
422                    Session session = null;
423    
424                    try {
425                            session = openSession();
426    
427                            BlogsEntry[] array = new BlogsEntryImpl[3];
428    
429                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
430                                            orderByComparator, true);
431    
432                            array[1] = blogsEntry;
433    
434                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
435                                            orderByComparator, false);
436    
437                            return array;
438                    }
439                    catch (Exception e) {
440                            throw processException(e);
441                    }
442                    finally {
443                            closeSession(session);
444                    }
445            }
446    
447            protected BlogsEntry getByUuid_PrevAndNext(Session session,
448                    BlogsEntry blogsEntry, String uuid,
449                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
450                    StringBundler query = null;
451    
452                    if (orderByComparator != null) {
453                            query = new StringBundler(6 +
454                                            (orderByComparator.getOrderByFields().length * 6));
455                    }
456                    else {
457                            query = new StringBundler(3);
458                    }
459    
460                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
461    
462                    boolean bindUuid = false;
463    
464                    if (uuid == null) {
465                            query.append(_FINDER_COLUMN_UUID_UUID_1);
466                    }
467                    else if (uuid.equals(StringPool.BLANK)) {
468                            query.append(_FINDER_COLUMN_UUID_UUID_3);
469                    }
470                    else {
471                            bindUuid = true;
472    
473                            query.append(_FINDER_COLUMN_UUID_UUID_2);
474                    }
475    
476                    if (orderByComparator != null) {
477                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
478    
479                            if (orderByConditionFields.length > 0) {
480                                    query.append(WHERE_AND);
481                            }
482    
483                            for (int i = 0; i < orderByConditionFields.length; i++) {
484                                    query.append(_ORDER_BY_ENTITY_ALIAS);
485                                    query.append(orderByConditionFields[i]);
486    
487                                    if ((i + 1) < orderByConditionFields.length) {
488                                            if (orderByComparator.isAscending() ^ previous) {
489                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
490                                            }
491                                            else {
492                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
493                                            }
494                                    }
495                                    else {
496                                            if (orderByComparator.isAscending() ^ previous) {
497                                                    query.append(WHERE_GREATER_THAN);
498                                            }
499                                            else {
500                                                    query.append(WHERE_LESSER_THAN);
501                                            }
502                                    }
503                            }
504    
505                            query.append(ORDER_BY_CLAUSE);
506    
507                            String[] orderByFields = orderByComparator.getOrderByFields();
508    
509                            for (int i = 0; i < orderByFields.length; i++) {
510                                    query.append(_ORDER_BY_ENTITY_ALIAS);
511                                    query.append(orderByFields[i]);
512    
513                                    if ((i + 1) < orderByFields.length) {
514                                            if (orderByComparator.isAscending() ^ previous) {
515                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
516                                            }
517                                            else {
518                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
519                                            }
520                                    }
521                                    else {
522                                            if (orderByComparator.isAscending() ^ previous) {
523                                                    query.append(ORDER_BY_ASC);
524                                            }
525                                            else {
526                                                    query.append(ORDER_BY_DESC);
527                                            }
528                                    }
529                            }
530                    }
531                    else {
532                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
533                    }
534    
535                    String sql = query.toString();
536    
537                    Query q = session.createQuery(sql);
538    
539                    q.setFirstResult(0);
540                    q.setMaxResults(2);
541    
542                    QueryPos qPos = QueryPos.getInstance(q);
543    
544                    if (bindUuid) {
545                            qPos.add(uuid);
546                    }
547    
548                    if (orderByComparator != null) {
549                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
550    
551                            for (Object value : values) {
552                                    qPos.add(value);
553                            }
554                    }
555    
556                    List<BlogsEntry> list = q.list();
557    
558                    if (list.size() == 2) {
559                            return list.get(1);
560                    }
561                    else {
562                            return null;
563                    }
564            }
565    
566            /**
567             * Removes all the blogs entries where uuid = &#63; from the database.
568             *
569             * @param uuid the uuid
570             */
571            @Override
572            public void removeByUuid(String uuid) {
573                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
574                                    QueryUtil.ALL_POS, null)) {
575                            remove(blogsEntry);
576                    }
577            }
578    
579            /**
580             * Returns the number of blogs entries where uuid = &#63;.
581             *
582             * @param uuid the uuid
583             * @return the number of matching blogs entries
584             */
585            @Override
586            public int countByUuid(String uuid) {
587                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
588    
589                    Object[] finderArgs = new Object[] { uuid };
590    
591                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
592    
593                    if (count == null) {
594                            StringBundler query = new StringBundler(2);
595    
596                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
597    
598                            boolean bindUuid = false;
599    
600                            if (uuid == null) {
601                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
602                            }
603                            else if (uuid.equals(StringPool.BLANK)) {
604                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
605                            }
606                            else {
607                                    bindUuid = true;
608    
609                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
610                            }
611    
612                            String sql = query.toString();
613    
614                            Session session = null;
615    
616                            try {
617                                    session = openSession();
618    
619                                    Query q = session.createQuery(sql);
620    
621                                    QueryPos qPos = QueryPos.getInstance(q);
622    
623                                    if (bindUuid) {
624                                            qPos.add(uuid);
625                                    }
626    
627                                    count = (Long)q.uniqueResult();
628    
629                                    finderCache.putResult(finderPath, finderArgs, count);
630                            }
631                            catch (Exception e) {
632                                    finderCache.removeResult(finderPath, finderArgs);
633    
634                                    throw processException(e);
635                            }
636                            finally {
637                                    closeSession(session);
638                            }
639                    }
640    
641                    return count.intValue();
642            }
643    
644            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
645            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
646            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
647            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
648                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
649                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
650                            new String[] { String.class.getName(), Long.class.getName() },
651                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
652                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
653            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
654                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
655                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
656                            new String[] { String.class.getName(), Long.class.getName() });
657    
658            /**
659             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
660             *
661             * @param uuid the uuid
662             * @param groupId the group ID
663             * @return the matching blogs entry
664             * @throws NoSuchEntryException if a matching blogs entry could not be found
665             */
666            @Override
667            public BlogsEntry findByUUID_G(String uuid, long groupId)
668                    throws NoSuchEntryException {
669                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
670    
671                    if (blogsEntry == null) {
672                            StringBundler msg = new StringBundler(6);
673    
674                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
675    
676                            msg.append("uuid=");
677                            msg.append(uuid);
678    
679                            msg.append(", groupId=");
680                            msg.append(groupId);
681    
682                            msg.append(StringPool.CLOSE_CURLY_BRACE);
683    
684                            if (_log.isWarnEnabled()) {
685                                    _log.warn(msg.toString());
686                            }
687    
688                            throw new NoSuchEntryException(msg.toString());
689                    }
690    
691                    return blogsEntry;
692            }
693    
694            /**
695             * 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.
696             *
697             * @param uuid the uuid
698             * @param groupId the group ID
699             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
700             */
701            @Override
702            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
703                    return fetchByUUID_G(uuid, groupId, true);
704            }
705    
706            /**
707             * 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.
708             *
709             * @param uuid the uuid
710             * @param groupId the group ID
711             * @param retrieveFromCache whether to retrieve from the finder cache
712             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
713             */
714            @Override
715            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
716                    boolean retrieveFromCache) {
717                    Object[] finderArgs = new Object[] { uuid, groupId };
718    
719                    Object result = null;
720    
721                    if (retrieveFromCache) {
722                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
723                                            finderArgs, this);
724                    }
725    
726                    if (result instanceof BlogsEntry) {
727                            BlogsEntry blogsEntry = (BlogsEntry)result;
728    
729                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
730                                            (groupId != blogsEntry.getGroupId())) {
731                                    result = null;
732                            }
733                    }
734    
735                    if (result == null) {
736                            StringBundler query = new StringBundler(4);
737    
738                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
739    
740                            boolean bindUuid = false;
741    
742                            if (uuid == null) {
743                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
744                            }
745                            else if (uuid.equals(StringPool.BLANK)) {
746                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
747                            }
748                            else {
749                                    bindUuid = true;
750    
751                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
752                            }
753    
754                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
755    
756                            String sql = query.toString();
757    
758                            Session session = null;
759    
760                            try {
761                                    session = openSession();
762    
763                                    Query q = session.createQuery(sql);
764    
765                                    QueryPos qPos = QueryPos.getInstance(q);
766    
767                                    if (bindUuid) {
768                                            qPos.add(uuid);
769                                    }
770    
771                                    qPos.add(groupId);
772    
773                                    List<BlogsEntry> list = q.list();
774    
775                                    if (list.isEmpty()) {
776                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
777                                                    finderArgs, list);
778                                    }
779                                    else {
780                                            BlogsEntry blogsEntry = list.get(0);
781    
782                                            result = blogsEntry;
783    
784                                            cacheResult(blogsEntry);
785    
786                                            if ((blogsEntry.getUuid() == null) ||
787                                                            !blogsEntry.getUuid().equals(uuid) ||
788                                                            (blogsEntry.getGroupId() != groupId)) {
789                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
790                                                            finderArgs, blogsEntry);
791                                            }
792                                    }
793                            }
794                            catch (Exception e) {
795                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
796    
797                                    throw processException(e);
798                            }
799                            finally {
800                                    closeSession(session);
801                            }
802                    }
803    
804                    if (result instanceof List<?>) {
805                            return null;
806                    }
807                    else {
808                            return (BlogsEntry)result;
809                    }
810            }
811    
812            /**
813             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
814             *
815             * @param uuid the uuid
816             * @param groupId the group ID
817             * @return the blogs entry that was removed
818             */
819            @Override
820            public BlogsEntry removeByUUID_G(String uuid, long groupId)
821                    throws NoSuchEntryException {
822                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
823    
824                    return remove(blogsEntry);
825            }
826    
827            /**
828             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
829             *
830             * @param uuid the uuid
831             * @param groupId the group ID
832             * @return the number of matching blogs entries
833             */
834            @Override
835            public int countByUUID_G(String uuid, long groupId) {
836                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
837    
838                    Object[] finderArgs = new Object[] { uuid, groupId };
839    
840                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
841    
842                    if (count == null) {
843                            StringBundler query = new StringBundler(3);
844    
845                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
846    
847                            boolean bindUuid = false;
848    
849                            if (uuid == null) {
850                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
851                            }
852                            else if (uuid.equals(StringPool.BLANK)) {
853                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
854                            }
855                            else {
856                                    bindUuid = true;
857    
858                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
859                            }
860    
861                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
862    
863                            String sql = query.toString();
864    
865                            Session session = null;
866    
867                            try {
868                                    session = openSession();
869    
870                                    Query q = session.createQuery(sql);
871    
872                                    QueryPos qPos = QueryPos.getInstance(q);
873    
874                                    if (bindUuid) {
875                                            qPos.add(uuid);
876                                    }
877    
878                                    qPos.add(groupId);
879    
880                                    count = (Long)q.uniqueResult();
881    
882                                    finderCache.putResult(finderPath, finderArgs, count);
883                            }
884                            catch (Exception e) {
885                                    finderCache.removeResult(finderPath, finderArgs);
886    
887                                    throw processException(e);
888                            }
889                            finally {
890                                    closeSession(session);
891                            }
892                    }
893    
894                    return count.intValue();
895            }
896    
897            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
898            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
899            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
900            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
901            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
902                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
903                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
904                            new String[] {
905                                    String.class.getName(), Long.class.getName(),
906                                    
907                            Integer.class.getName(), Integer.class.getName(),
908                                    OrderByComparator.class.getName()
909                            });
910            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
911                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
912                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
913                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
914                            new String[] { String.class.getName(), Long.class.getName() },
915                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
916                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
917                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
918                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
919            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
920                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
921                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
922                            new String[] { String.class.getName(), Long.class.getName() });
923    
924            /**
925             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
926             *
927             * @param uuid the uuid
928             * @param companyId the company ID
929             * @return the matching blogs entries
930             */
931            @Override
932            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
933                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
934                            QueryUtil.ALL_POS, null);
935            }
936    
937            /**
938             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
939             *
940             * <p>
941             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
942             * </p>
943             *
944             * @param uuid the uuid
945             * @param companyId the company ID
946             * @param start the lower bound of the range of blogs entries
947             * @param end the upper bound of the range of blogs entries (not inclusive)
948             * @return the range of matching blogs entries
949             */
950            @Override
951            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
952                    int start, int end) {
953                    return findByUuid_C(uuid, companyId, start, end, null);
954            }
955    
956            /**
957             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
958             *
959             * <p>
960             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
961             * </p>
962             *
963             * @param uuid the uuid
964             * @param companyId the company ID
965             * @param start the lower bound of the range of blogs entries
966             * @param end the upper bound of the range of blogs entries (not inclusive)
967             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
968             * @return the ordered range of matching blogs entries
969             */
970            @Override
971            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
972                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
973                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
974            }
975    
976            /**
977             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
978             *
979             * <p>
980             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
981             * </p>
982             *
983             * @param uuid the uuid
984             * @param companyId the company ID
985             * @param start the lower bound of the range of blogs entries
986             * @param end the upper bound of the range of blogs entries (not inclusive)
987             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
988             * @param retrieveFromCache whether to retrieve from the finder cache
989             * @return the ordered range of matching blogs entries
990             */
991            @Override
992            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
993                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
994                    boolean retrieveFromCache) {
995                    boolean pagination = true;
996                    FinderPath finderPath = null;
997                    Object[] finderArgs = null;
998    
999                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1000                                    (orderByComparator == null)) {
1001                            pagination = false;
1002                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1003                            finderArgs = new Object[] { uuid, companyId };
1004                    }
1005                    else {
1006                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1007                            finderArgs = new Object[] {
1008                                            uuid, companyId,
1009                                            
1010                                            start, end, orderByComparator
1011                                    };
1012                    }
1013    
1014                    List<BlogsEntry> list = null;
1015    
1016                    if (retrieveFromCache) {
1017                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1018                                            finderArgs, this);
1019    
1020                            if ((list != null) && !list.isEmpty()) {
1021                                    for (BlogsEntry blogsEntry : list) {
1022                                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1023                                                            (companyId != blogsEntry.getCompanyId())) {
1024                                                    list = null;
1025    
1026                                                    break;
1027                                            }
1028                                    }
1029                            }
1030                    }
1031    
1032                    if (list == null) {
1033                            StringBundler query = null;
1034    
1035                            if (orderByComparator != null) {
1036                                    query = new StringBundler(4 +
1037                                                    (orderByComparator.getOrderByFields().length * 3));
1038                            }
1039                            else {
1040                                    query = new StringBundler(4);
1041                            }
1042    
1043                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1044    
1045                            boolean bindUuid = false;
1046    
1047                            if (uuid == null) {
1048                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1049                            }
1050                            else if (uuid.equals(StringPool.BLANK)) {
1051                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1052                            }
1053                            else {
1054                                    bindUuid = true;
1055    
1056                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1057                            }
1058    
1059                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1060    
1061                            if (orderByComparator != null) {
1062                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1063                                            orderByComparator);
1064                            }
1065                            else
1066                             if (pagination) {
1067                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1068                            }
1069    
1070                            String sql = query.toString();
1071    
1072                            Session session = null;
1073    
1074                            try {
1075                                    session = openSession();
1076    
1077                                    Query q = session.createQuery(sql);
1078    
1079                                    QueryPos qPos = QueryPos.getInstance(q);
1080    
1081                                    if (bindUuid) {
1082                                            qPos.add(uuid);
1083                                    }
1084    
1085                                    qPos.add(companyId);
1086    
1087                                    if (!pagination) {
1088                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1089                                                            start, end, false);
1090    
1091                                            Collections.sort(list);
1092    
1093                                            list = Collections.unmodifiableList(list);
1094                                    }
1095                                    else {
1096                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1097                                                            start, end);
1098                                    }
1099    
1100                                    cacheResult(list);
1101    
1102                                    finderCache.putResult(finderPath, finderArgs, list);
1103                            }
1104                            catch (Exception e) {
1105                                    finderCache.removeResult(finderPath, finderArgs);
1106    
1107                                    throw processException(e);
1108                            }
1109                            finally {
1110                                    closeSession(session);
1111                            }
1112                    }
1113    
1114                    return list;
1115            }
1116    
1117            /**
1118             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1119             *
1120             * @param uuid the uuid
1121             * @param companyId the company ID
1122             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1123             * @return the first matching blogs entry
1124             * @throws NoSuchEntryException if a matching blogs entry could not be found
1125             */
1126            @Override
1127            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1128                    OrderByComparator<BlogsEntry> orderByComparator)
1129                    throws NoSuchEntryException {
1130                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1131                                    orderByComparator);
1132    
1133                    if (blogsEntry != null) {
1134                            return blogsEntry;
1135                    }
1136    
1137                    StringBundler msg = new StringBundler(6);
1138    
1139                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1140    
1141                    msg.append("uuid=");
1142                    msg.append(uuid);
1143    
1144                    msg.append(", companyId=");
1145                    msg.append(companyId);
1146    
1147                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1148    
1149                    throw new NoSuchEntryException(msg.toString());
1150            }
1151    
1152            /**
1153             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1154             *
1155             * @param uuid the uuid
1156             * @param companyId the company ID
1157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1158             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1159             */
1160            @Override
1161            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1162                    OrderByComparator<BlogsEntry> orderByComparator) {
1163                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1164                                    orderByComparator);
1165    
1166                    if (!list.isEmpty()) {
1167                            return list.get(0);
1168                    }
1169    
1170                    return null;
1171            }
1172    
1173            /**
1174             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1175             *
1176             * @param uuid the uuid
1177             * @param companyId the company ID
1178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1179             * @return the last matching blogs entry
1180             * @throws NoSuchEntryException if a matching blogs entry could not be found
1181             */
1182            @Override
1183            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1184                    OrderByComparator<BlogsEntry> orderByComparator)
1185                    throws NoSuchEntryException {
1186                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1187                                    orderByComparator);
1188    
1189                    if (blogsEntry != null) {
1190                            return blogsEntry;
1191                    }
1192    
1193                    StringBundler msg = new StringBundler(6);
1194    
1195                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1196    
1197                    msg.append("uuid=");
1198                    msg.append(uuid);
1199    
1200                    msg.append(", companyId=");
1201                    msg.append(companyId);
1202    
1203                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1204    
1205                    throw new NoSuchEntryException(msg.toString());
1206            }
1207    
1208            /**
1209             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1210             *
1211             * @param uuid the uuid
1212             * @param companyId the company ID
1213             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1214             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1215             */
1216            @Override
1217            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1218                    OrderByComparator<BlogsEntry> orderByComparator) {
1219                    int count = countByUuid_C(uuid, companyId);
1220    
1221                    if (count == 0) {
1222                            return null;
1223                    }
1224    
1225                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1226                                    orderByComparator);
1227    
1228                    if (!list.isEmpty()) {
1229                            return list.get(0);
1230                    }
1231    
1232                    return null;
1233            }
1234    
1235            /**
1236             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1237             *
1238             * @param entryId the primary key of the current blogs entry
1239             * @param uuid the uuid
1240             * @param companyId the company ID
1241             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1242             * @return the previous, current, and next blogs entry
1243             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1244             */
1245            @Override
1246            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1247                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1248                    throws NoSuchEntryException {
1249                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1250    
1251                    Session session = null;
1252    
1253                    try {
1254                            session = openSession();
1255    
1256                            BlogsEntry[] array = new BlogsEntryImpl[3];
1257    
1258                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1259                                            companyId, orderByComparator, true);
1260    
1261                            array[1] = blogsEntry;
1262    
1263                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1264                                            companyId, orderByComparator, false);
1265    
1266                            return array;
1267                    }
1268                    catch (Exception e) {
1269                            throw processException(e);
1270                    }
1271                    finally {
1272                            closeSession(session);
1273                    }
1274            }
1275    
1276            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1277                    BlogsEntry blogsEntry, String uuid, long companyId,
1278                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1279                    StringBundler query = null;
1280    
1281                    if (orderByComparator != null) {
1282                            query = new StringBundler(6 +
1283                                            (orderByComparator.getOrderByFields().length * 6));
1284                    }
1285                    else {
1286                            query = new StringBundler(3);
1287                    }
1288    
1289                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1290    
1291                    boolean bindUuid = false;
1292    
1293                    if (uuid == null) {
1294                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1295                    }
1296                    else if (uuid.equals(StringPool.BLANK)) {
1297                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1298                    }
1299                    else {
1300                            bindUuid = true;
1301    
1302                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1303                    }
1304    
1305                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1306    
1307                    if (orderByComparator != null) {
1308                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1309    
1310                            if (orderByConditionFields.length > 0) {
1311                                    query.append(WHERE_AND);
1312                            }
1313    
1314                            for (int i = 0; i < orderByConditionFields.length; i++) {
1315                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1316                                    query.append(orderByConditionFields[i]);
1317    
1318                                    if ((i + 1) < orderByConditionFields.length) {
1319                                            if (orderByComparator.isAscending() ^ previous) {
1320                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1321                                            }
1322                                            else {
1323                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1324                                            }
1325                                    }
1326                                    else {
1327                                            if (orderByComparator.isAscending() ^ previous) {
1328                                                    query.append(WHERE_GREATER_THAN);
1329                                            }
1330                                            else {
1331                                                    query.append(WHERE_LESSER_THAN);
1332                                            }
1333                                    }
1334                            }
1335    
1336                            query.append(ORDER_BY_CLAUSE);
1337    
1338                            String[] orderByFields = orderByComparator.getOrderByFields();
1339    
1340                            for (int i = 0; i < orderByFields.length; i++) {
1341                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1342                                    query.append(orderByFields[i]);
1343    
1344                                    if ((i + 1) < orderByFields.length) {
1345                                            if (orderByComparator.isAscending() ^ previous) {
1346                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1347                                            }
1348                                            else {
1349                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1350                                            }
1351                                    }
1352                                    else {
1353                                            if (orderByComparator.isAscending() ^ previous) {
1354                                                    query.append(ORDER_BY_ASC);
1355                                            }
1356                                            else {
1357                                                    query.append(ORDER_BY_DESC);
1358                                            }
1359                                    }
1360                            }
1361                    }
1362                    else {
1363                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1364                    }
1365    
1366                    String sql = query.toString();
1367    
1368                    Query q = session.createQuery(sql);
1369    
1370                    q.setFirstResult(0);
1371                    q.setMaxResults(2);
1372    
1373                    QueryPos qPos = QueryPos.getInstance(q);
1374    
1375                    if (bindUuid) {
1376                            qPos.add(uuid);
1377                    }
1378    
1379                    qPos.add(companyId);
1380    
1381                    if (orderByComparator != null) {
1382                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1383    
1384                            for (Object value : values) {
1385                                    qPos.add(value);
1386                            }
1387                    }
1388    
1389                    List<BlogsEntry> list = q.list();
1390    
1391                    if (list.size() == 2) {
1392                            return list.get(1);
1393                    }
1394                    else {
1395                            return null;
1396                    }
1397            }
1398    
1399            /**
1400             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1401             *
1402             * @param uuid the uuid
1403             * @param companyId the company ID
1404             */
1405            @Override
1406            public void removeByUuid_C(String uuid, long companyId) {
1407                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1408                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1409                            remove(blogsEntry);
1410                    }
1411            }
1412    
1413            /**
1414             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1415             *
1416             * @param uuid the uuid
1417             * @param companyId the company ID
1418             * @return the number of matching blogs entries
1419             */
1420            @Override
1421            public int countByUuid_C(String uuid, long companyId) {
1422                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1423    
1424                    Object[] finderArgs = new Object[] { uuid, companyId };
1425    
1426                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1427    
1428                    if (count == null) {
1429                            StringBundler query = new StringBundler(3);
1430    
1431                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1432    
1433                            boolean bindUuid = false;
1434    
1435                            if (uuid == null) {
1436                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1437                            }
1438                            else if (uuid.equals(StringPool.BLANK)) {
1439                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1440                            }
1441                            else {
1442                                    bindUuid = true;
1443    
1444                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1445                            }
1446    
1447                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1448    
1449                            String sql = query.toString();
1450    
1451                            Session session = null;
1452    
1453                            try {
1454                                    session = openSession();
1455    
1456                                    Query q = session.createQuery(sql);
1457    
1458                                    QueryPos qPos = QueryPos.getInstance(q);
1459    
1460                                    if (bindUuid) {
1461                                            qPos.add(uuid);
1462                                    }
1463    
1464                                    qPos.add(companyId);
1465    
1466                                    count = (Long)q.uniqueResult();
1467    
1468                                    finderCache.putResult(finderPath, finderArgs, count);
1469                            }
1470                            catch (Exception e) {
1471                                    finderCache.removeResult(finderPath, finderArgs);
1472    
1473                                    throw processException(e);
1474                            }
1475                            finally {
1476                                    closeSession(session);
1477                            }
1478                    }
1479    
1480                    return count.intValue();
1481            }
1482    
1483            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1484            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1485            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1486            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1487            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1488                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1489                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1490                            new String[] {
1491                                    Long.class.getName(),
1492                                    
1493                            Integer.class.getName(), Integer.class.getName(),
1494                                    OrderByComparator.class.getName()
1495                            });
1496            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1497                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1498                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1499                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1500                            new String[] { Long.class.getName() },
1501                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1502                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1503                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1504            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1505                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1506                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1507                            new String[] { Long.class.getName() });
1508    
1509            /**
1510             * Returns all the blogs entries where groupId = &#63;.
1511             *
1512             * @param groupId the group ID
1513             * @return the matching blogs entries
1514             */
1515            @Override
1516            public List<BlogsEntry> findByGroupId(long groupId) {
1517                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1518            }
1519    
1520            /**
1521             * Returns a range of all the blogs entries where groupId = &#63;.
1522             *
1523             * <p>
1524             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1525             * </p>
1526             *
1527             * @param groupId the group ID
1528             * @param start the lower bound of the range of blogs entries
1529             * @param end the upper bound of the range of blogs entries (not inclusive)
1530             * @return the range of matching blogs entries
1531             */
1532            @Override
1533            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1534                    return findByGroupId(groupId, start, end, null);
1535            }
1536    
1537            /**
1538             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1539             *
1540             * <p>
1541             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1542             * </p>
1543             *
1544             * @param groupId the group ID
1545             * @param start the lower bound of the range of blogs entries
1546             * @param end the upper bound of the range of blogs entries (not inclusive)
1547             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1548             * @return the ordered range of matching blogs entries
1549             */
1550            @Override
1551            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1552                    OrderByComparator<BlogsEntry> orderByComparator) {
1553                    return findByGroupId(groupId, start, end, orderByComparator, true);
1554            }
1555    
1556            /**
1557             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1558             *
1559             * <p>
1560             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1561             * </p>
1562             *
1563             * @param groupId the group ID
1564             * @param start the lower bound of the range of blogs entries
1565             * @param end the upper bound of the range of blogs entries (not inclusive)
1566             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1567             * @param retrieveFromCache whether to retrieve from the finder cache
1568             * @return the ordered range of matching blogs entries
1569             */
1570            @Override
1571            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1572                    OrderByComparator<BlogsEntry> orderByComparator,
1573                    boolean retrieveFromCache) {
1574                    boolean pagination = true;
1575                    FinderPath finderPath = null;
1576                    Object[] finderArgs = null;
1577    
1578                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1579                                    (orderByComparator == null)) {
1580                            pagination = false;
1581                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1582                            finderArgs = new Object[] { groupId };
1583                    }
1584                    else {
1585                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1586                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1587                    }
1588    
1589                    List<BlogsEntry> list = null;
1590    
1591                    if (retrieveFromCache) {
1592                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1593                                            finderArgs, this);
1594    
1595                            if ((list != null) && !list.isEmpty()) {
1596                                    for (BlogsEntry blogsEntry : list) {
1597                                            if ((groupId != blogsEntry.getGroupId())) {
1598                                                    list = null;
1599    
1600                                                    break;
1601                                            }
1602                                    }
1603                            }
1604                    }
1605    
1606                    if (list == null) {
1607                            StringBundler query = null;
1608    
1609                            if (orderByComparator != null) {
1610                                    query = new StringBundler(3 +
1611                                                    (orderByComparator.getOrderByFields().length * 3));
1612                            }
1613                            else {
1614                                    query = new StringBundler(3);
1615                            }
1616    
1617                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1618    
1619                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1620    
1621                            if (orderByComparator != null) {
1622                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1623                                            orderByComparator);
1624                            }
1625                            else
1626                             if (pagination) {
1627                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1628                            }
1629    
1630                            String sql = query.toString();
1631    
1632                            Session session = null;
1633    
1634                            try {
1635                                    session = openSession();
1636    
1637                                    Query q = session.createQuery(sql);
1638    
1639                                    QueryPos qPos = QueryPos.getInstance(q);
1640    
1641                                    qPos.add(groupId);
1642    
1643                                    if (!pagination) {
1644                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1645                                                            start, end, false);
1646    
1647                                            Collections.sort(list);
1648    
1649                                            list = Collections.unmodifiableList(list);
1650                                    }
1651                                    else {
1652                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1653                                                            start, end);
1654                                    }
1655    
1656                                    cacheResult(list);
1657    
1658                                    finderCache.putResult(finderPath, finderArgs, list);
1659                            }
1660                            catch (Exception e) {
1661                                    finderCache.removeResult(finderPath, finderArgs);
1662    
1663                                    throw processException(e);
1664                            }
1665                            finally {
1666                                    closeSession(session);
1667                            }
1668                    }
1669    
1670                    return list;
1671            }
1672    
1673            /**
1674             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1675             *
1676             * @param groupId the group ID
1677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1678             * @return the first matching blogs entry
1679             * @throws NoSuchEntryException if a matching blogs entry could not be found
1680             */
1681            @Override
1682            public BlogsEntry findByGroupId_First(long groupId,
1683                    OrderByComparator<BlogsEntry> orderByComparator)
1684                    throws NoSuchEntryException {
1685                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1686    
1687                    if (blogsEntry != null) {
1688                            return blogsEntry;
1689                    }
1690    
1691                    StringBundler msg = new StringBundler(4);
1692    
1693                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1694    
1695                    msg.append("groupId=");
1696                    msg.append(groupId);
1697    
1698                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1699    
1700                    throw new NoSuchEntryException(msg.toString());
1701            }
1702    
1703            /**
1704             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1705             *
1706             * @param groupId the group ID
1707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1708             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1709             */
1710            @Override
1711            public BlogsEntry fetchByGroupId_First(long groupId,
1712                    OrderByComparator<BlogsEntry> orderByComparator) {
1713                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1714    
1715                    if (!list.isEmpty()) {
1716                            return list.get(0);
1717                    }
1718    
1719                    return null;
1720            }
1721    
1722            /**
1723             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1724             *
1725             * @param groupId the group ID
1726             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1727             * @return the last matching blogs entry
1728             * @throws NoSuchEntryException if a matching blogs entry could not be found
1729             */
1730            @Override
1731            public BlogsEntry findByGroupId_Last(long groupId,
1732                    OrderByComparator<BlogsEntry> orderByComparator)
1733                    throws NoSuchEntryException {
1734                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1735    
1736                    if (blogsEntry != null) {
1737                            return blogsEntry;
1738                    }
1739    
1740                    StringBundler msg = new StringBundler(4);
1741    
1742                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1743    
1744                    msg.append("groupId=");
1745                    msg.append(groupId);
1746    
1747                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1748    
1749                    throw new NoSuchEntryException(msg.toString());
1750            }
1751    
1752            /**
1753             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1754             *
1755             * @param groupId the group ID
1756             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1757             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1758             */
1759            @Override
1760            public BlogsEntry fetchByGroupId_Last(long groupId,
1761                    OrderByComparator<BlogsEntry> orderByComparator) {
1762                    int count = countByGroupId(groupId);
1763    
1764                    if (count == 0) {
1765                            return null;
1766                    }
1767    
1768                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1769                                    orderByComparator);
1770    
1771                    if (!list.isEmpty()) {
1772                            return list.get(0);
1773                    }
1774    
1775                    return null;
1776            }
1777    
1778            /**
1779             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1780             *
1781             * @param entryId the primary key of the current blogs entry
1782             * @param groupId the group ID
1783             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1784             * @return the previous, current, and next blogs entry
1785             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1786             */
1787            @Override
1788            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1789                    OrderByComparator<BlogsEntry> orderByComparator)
1790                    throws NoSuchEntryException {
1791                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1792    
1793                    Session session = null;
1794    
1795                    try {
1796                            session = openSession();
1797    
1798                            BlogsEntry[] array = new BlogsEntryImpl[3];
1799    
1800                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1801                                            orderByComparator, true);
1802    
1803                            array[1] = blogsEntry;
1804    
1805                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1806                                            orderByComparator, false);
1807    
1808                            return array;
1809                    }
1810                    catch (Exception e) {
1811                            throw processException(e);
1812                    }
1813                    finally {
1814                            closeSession(session);
1815                    }
1816            }
1817    
1818            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1819                    BlogsEntry blogsEntry, long groupId,
1820                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1821                    StringBundler query = null;
1822    
1823                    if (orderByComparator != null) {
1824                            query = new StringBundler(6 +
1825                                            (orderByComparator.getOrderByFields().length * 6));
1826                    }
1827                    else {
1828                            query = new StringBundler(3);
1829                    }
1830    
1831                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1832    
1833                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1834    
1835                    if (orderByComparator != null) {
1836                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1837    
1838                            if (orderByConditionFields.length > 0) {
1839                                    query.append(WHERE_AND);
1840                            }
1841    
1842                            for (int i = 0; i < orderByConditionFields.length; i++) {
1843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1844                                    query.append(orderByConditionFields[i]);
1845    
1846                                    if ((i + 1) < orderByConditionFields.length) {
1847                                            if (orderByComparator.isAscending() ^ previous) {
1848                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1849                                            }
1850                                            else {
1851                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1852                                            }
1853                                    }
1854                                    else {
1855                                            if (orderByComparator.isAscending() ^ previous) {
1856                                                    query.append(WHERE_GREATER_THAN);
1857                                            }
1858                                            else {
1859                                                    query.append(WHERE_LESSER_THAN);
1860                                            }
1861                                    }
1862                            }
1863    
1864                            query.append(ORDER_BY_CLAUSE);
1865    
1866                            String[] orderByFields = orderByComparator.getOrderByFields();
1867    
1868                            for (int i = 0; i < orderByFields.length; i++) {
1869                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1870                                    query.append(orderByFields[i]);
1871    
1872                                    if ((i + 1) < orderByFields.length) {
1873                                            if (orderByComparator.isAscending() ^ previous) {
1874                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1875                                            }
1876                                            else {
1877                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1878                                            }
1879                                    }
1880                                    else {
1881                                            if (orderByComparator.isAscending() ^ previous) {
1882                                                    query.append(ORDER_BY_ASC);
1883                                            }
1884                                            else {
1885                                                    query.append(ORDER_BY_DESC);
1886                                            }
1887                                    }
1888                            }
1889                    }
1890                    else {
1891                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1892                    }
1893    
1894                    String sql = query.toString();
1895    
1896                    Query q = session.createQuery(sql);
1897    
1898                    q.setFirstResult(0);
1899                    q.setMaxResults(2);
1900    
1901                    QueryPos qPos = QueryPos.getInstance(q);
1902    
1903                    qPos.add(groupId);
1904    
1905                    if (orderByComparator != null) {
1906                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1907    
1908                            for (Object value : values) {
1909                                    qPos.add(value);
1910                            }
1911                    }
1912    
1913                    List<BlogsEntry> list = q.list();
1914    
1915                    if (list.size() == 2) {
1916                            return list.get(1);
1917                    }
1918                    else {
1919                            return null;
1920                    }
1921            }
1922    
1923            /**
1924             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1925             *
1926             * @param groupId the group ID
1927             * @return the matching blogs entries that the user has permission to view
1928             */
1929            @Override
1930            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1931                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1932                            QueryUtil.ALL_POS, null);
1933            }
1934    
1935            /**
1936             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1937             *
1938             * <p>
1939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1940             * </p>
1941             *
1942             * @param groupId the group ID
1943             * @param start the lower bound of the range of blogs entries
1944             * @param end the upper bound of the range of blogs entries (not inclusive)
1945             * @return the range of matching blogs entries that the user has permission to view
1946             */
1947            @Override
1948            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1949                    return filterFindByGroupId(groupId, start, end, null);
1950            }
1951    
1952            /**
1953             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1954             *
1955             * <p>
1956             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1957             * </p>
1958             *
1959             * @param groupId the group ID
1960             * @param start the lower bound of the range of blogs entries
1961             * @param end the upper bound of the range of blogs entries (not inclusive)
1962             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1963             * @return the ordered range of matching blogs entries that the user has permission to view
1964             */
1965            @Override
1966            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1967                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1968                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1969                            return findByGroupId(groupId, start, end, orderByComparator);
1970                    }
1971    
1972                    StringBundler query = null;
1973    
1974                    if (orderByComparator != null) {
1975                            query = new StringBundler(3 +
1976                                            (orderByComparator.getOrderByFields().length * 3));
1977                    }
1978                    else {
1979                            query = new StringBundler(3);
1980                    }
1981    
1982                    if (getDB().isSupportsInlineDistinct()) {
1983                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1984                    }
1985                    else {
1986                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1987                    }
1988    
1989                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1990    
1991                    if (!getDB().isSupportsInlineDistinct()) {
1992                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1993                    }
1994    
1995                    if (orderByComparator != null) {
1996                            if (getDB().isSupportsInlineDistinct()) {
1997                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1998                                            orderByComparator, true);
1999                            }
2000                            else {
2001                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2002                                            orderByComparator, true);
2003                            }
2004                    }
2005                    else {
2006                            if (getDB().isSupportsInlineDistinct()) {
2007                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2008                            }
2009                            else {
2010                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2011                            }
2012                    }
2013    
2014                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2015                                    BlogsEntry.class.getName(),
2016                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2017    
2018                    Session session = null;
2019    
2020                    try {
2021                            session = openSession();
2022    
2023                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2024    
2025                            if (getDB().isSupportsInlineDistinct()) {
2026                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2027                            }
2028                            else {
2029                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2030                            }
2031    
2032                            QueryPos qPos = QueryPos.getInstance(q);
2033    
2034                            qPos.add(groupId);
2035    
2036                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2037                    }
2038                    catch (Exception e) {
2039                            throw processException(e);
2040                    }
2041                    finally {
2042                            closeSession(session);
2043                    }
2044            }
2045    
2046            /**
2047             * 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;.
2048             *
2049             * @param entryId the primary key of the current blogs entry
2050             * @param groupId the group ID
2051             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2052             * @return the previous, current, and next blogs entry
2053             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2054             */
2055            @Override
2056            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2057                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
2058                    throws NoSuchEntryException {
2059                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2060                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2061                    }
2062    
2063                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2064    
2065                    Session session = null;
2066    
2067                    try {
2068                            session = openSession();
2069    
2070                            BlogsEntry[] array = new BlogsEntryImpl[3];
2071    
2072                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2073                                            groupId, orderByComparator, true);
2074    
2075                            array[1] = blogsEntry;
2076    
2077                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2078                                            groupId, orderByComparator, false);
2079    
2080                            return array;
2081                    }
2082                    catch (Exception e) {
2083                            throw processException(e);
2084                    }
2085                    finally {
2086                            closeSession(session);
2087                    }
2088            }
2089    
2090            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2091                    BlogsEntry blogsEntry, long groupId,
2092                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2093                    StringBundler query = null;
2094    
2095                    if (orderByComparator != null) {
2096                            query = new StringBundler(6 +
2097                                            (orderByComparator.getOrderByFields().length * 6));
2098                    }
2099                    else {
2100                            query = new StringBundler(3);
2101                    }
2102    
2103                    if (getDB().isSupportsInlineDistinct()) {
2104                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2105                    }
2106                    else {
2107                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2108                    }
2109    
2110                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2111    
2112                    if (!getDB().isSupportsInlineDistinct()) {
2113                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2114                    }
2115    
2116                    if (orderByComparator != null) {
2117                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2118    
2119                            if (orderByConditionFields.length > 0) {
2120                                    query.append(WHERE_AND);
2121                            }
2122    
2123                            for (int i = 0; i < orderByConditionFields.length; i++) {
2124                                    if (getDB().isSupportsInlineDistinct()) {
2125                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2126                                    }
2127                                    else {
2128                                            query.append(_ORDER_BY_ENTITY_TABLE);
2129                                    }
2130    
2131                                    query.append(orderByConditionFields[i]);
2132    
2133                                    if ((i + 1) < orderByConditionFields.length) {
2134                                            if (orderByComparator.isAscending() ^ previous) {
2135                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2136                                            }
2137                                            else {
2138                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2139                                            }
2140                                    }
2141                                    else {
2142                                            if (orderByComparator.isAscending() ^ previous) {
2143                                                    query.append(WHERE_GREATER_THAN);
2144                                            }
2145                                            else {
2146                                                    query.append(WHERE_LESSER_THAN);
2147                                            }
2148                                    }
2149                            }
2150    
2151                            query.append(ORDER_BY_CLAUSE);
2152    
2153                            String[] orderByFields = orderByComparator.getOrderByFields();
2154    
2155                            for (int i = 0; i < orderByFields.length; i++) {
2156                                    if (getDB().isSupportsInlineDistinct()) {
2157                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2158                                    }
2159                                    else {
2160                                            query.append(_ORDER_BY_ENTITY_TABLE);
2161                                    }
2162    
2163                                    query.append(orderByFields[i]);
2164    
2165                                    if ((i + 1) < orderByFields.length) {
2166                                            if (orderByComparator.isAscending() ^ previous) {
2167                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2168                                            }
2169                                            else {
2170                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2171                                            }
2172                                    }
2173                                    else {
2174                                            if (orderByComparator.isAscending() ^ previous) {
2175                                                    query.append(ORDER_BY_ASC);
2176                                            }
2177                                            else {
2178                                                    query.append(ORDER_BY_DESC);
2179                                            }
2180                                    }
2181                            }
2182                    }
2183                    else {
2184                            if (getDB().isSupportsInlineDistinct()) {
2185                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2186                            }
2187                            else {
2188                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2189                            }
2190                    }
2191    
2192                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2193                                    BlogsEntry.class.getName(),
2194                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2195    
2196                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2197    
2198                    q.setFirstResult(0);
2199                    q.setMaxResults(2);
2200    
2201                    if (getDB().isSupportsInlineDistinct()) {
2202                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2203                    }
2204                    else {
2205                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2206                    }
2207    
2208                    QueryPos qPos = QueryPos.getInstance(q);
2209    
2210                    qPos.add(groupId);
2211    
2212                    if (orderByComparator != null) {
2213                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2214    
2215                            for (Object value : values) {
2216                                    qPos.add(value);
2217                            }
2218                    }
2219    
2220                    List<BlogsEntry> list = q.list();
2221    
2222                    if (list.size() == 2) {
2223                            return list.get(1);
2224                    }
2225                    else {
2226                            return null;
2227                    }
2228            }
2229    
2230            /**
2231             * Removes all the blogs entries where groupId = &#63; from the database.
2232             *
2233             * @param groupId the group ID
2234             */
2235            @Override
2236            public void removeByGroupId(long groupId) {
2237                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2238                                    QueryUtil.ALL_POS, null)) {
2239                            remove(blogsEntry);
2240                    }
2241            }
2242    
2243            /**
2244             * Returns the number of blogs entries where groupId = &#63;.
2245             *
2246             * @param groupId the group ID
2247             * @return the number of matching blogs entries
2248             */
2249            @Override
2250            public int countByGroupId(long groupId) {
2251                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2252    
2253                    Object[] finderArgs = new Object[] { groupId };
2254    
2255                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2256    
2257                    if (count == null) {
2258                            StringBundler query = new StringBundler(2);
2259    
2260                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2261    
2262                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2263    
2264                            String sql = query.toString();
2265    
2266                            Session session = null;
2267    
2268                            try {
2269                                    session = openSession();
2270    
2271                                    Query q = session.createQuery(sql);
2272    
2273                                    QueryPos qPos = QueryPos.getInstance(q);
2274    
2275                                    qPos.add(groupId);
2276    
2277                                    count = (Long)q.uniqueResult();
2278    
2279                                    finderCache.putResult(finderPath, finderArgs, count);
2280                            }
2281                            catch (Exception e) {
2282                                    finderCache.removeResult(finderPath, finderArgs);
2283    
2284                                    throw processException(e);
2285                            }
2286                            finally {
2287                                    closeSession(session);
2288                            }
2289                    }
2290    
2291                    return count.intValue();
2292            }
2293    
2294            /**
2295             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2296             *
2297             * @param groupId the group ID
2298             * @return the number of matching blogs entries that the user has permission to view
2299             */
2300            @Override
2301            public int filterCountByGroupId(long groupId) {
2302                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2303                            return countByGroupId(groupId);
2304                    }
2305    
2306                    StringBundler query = new StringBundler(2);
2307    
2308                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2309    
2310                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2311    
2312                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2313                                    BlogsEntry.class.getName(),
2314                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2315    
2316                    Session session = null;
2317    
2318                    try {
2319                            session = openSession();
2320    
2321                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2322    
2323                            q.addScalar(COUNT_COLUMN_NAME,
2324                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2325    
2326                            QueryPos qPos = QueryPos.getInstance(q);
2327    
2328                            qPos.add(groupId);
2329    
2330                            Long count = (Long)q.uniqueResult();
2331    
2332                            return count.intValue();
2333                    }
2334                    catch (Exception e) {
2335                            throw processException(e);
2336                    }
2337                    finally {
2338                            closeSession(session);
2339                    }
2340            }
2341    
2342            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2343            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2344                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2345                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2346                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2347                            new String[] {
2348                                    Long.class.getName(),
2349                                    
2350                            Integer.class.getName(), Integer.class.getName(),
2351                                    OrderByComparator.class.getName()
2352                            });
2353            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2354                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2355                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2356                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2357                            new String[] { Long.class.getName() },
2358                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2359                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2360                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2361            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2362                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2363                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2364                            new String[] { Long.class.getName() });
2365    
2366            /**
2367             * Returns all the blogs entries where companyId = &#63;.
2368             *
2369             * @param companyId the company ID
2370             * @return the matching blogs entries
2371             */
2372            @Override
2373            public List<BlogsEntry> findByCompanyId(long companyId) {
2374                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2375                            null);
2376            }
2377    
2378            /**
2379             * Returns a range of all the blogs entries where companyId = &#63;.
2380             *
2381             * <p>
2382             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2383             * </p>
2384             *
2385             * @param companyId the company ID
2386             * @param start the lower bound of the range of blogs entries
2387             * @param end the upper bound of the range of blogs entries (not inclusive)
2388             * @return the range of matching blogs entries
2389             */
2390            @Override
2391            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2392                    return findByCompanyId(companyId, start, end, null);
2393            }
2394    
2395            /**
2396             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2397             *
2398             * <p>
2399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2400             * </p>
2401             *
2402             * @param companyId the company ID
2403             * @param start the lower bound of the range of blogs entries
2404             * @param end the upper bound of the range of blogs entries (not inclusive)
2405             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2406             * @return the ordered range of matching blogs entries
2407             */
2408            @Override
2409            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2410                    OrderByComparator<BlogsEntry> orderByComparator) {
2411                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2412            }
2413    
2414            /**
2415             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2416             *
2417             * <p>
2418             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2419             * </p>
2420             *
2421             * @param companyId the company ID
2422             * @param start the lower bound of the range of blogs entries
2423             * @param end the upper bound of the range of blogs entries (not inclusive)
2424             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2425             * @param retrieveFromCache whether to retrieve from the finder cache
2426             * @return the ordered range of matching blogs entries
2427             */
2428            @Override
2429            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2430                    OrderByComparator<BlogsEntry> orderByComparator,
2431                    boolean retrieveFromCache) {
2432                    boolean pagination = true;
2433                    FinderPath finderPath = null;
2434                    Object[] finderArgs = null;
2435    
2436                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2437                                    (orderByComparator == null)) {
2438                            pagination = false;
2439                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2440                            finderArgs = new Object[] { companyId };
2441                    }
2442                    else {
2443                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2444                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2445                    }
2446    
2447                    List<BlogsEntry> list = null;
2448    
2449                    if (retrieveFromCache) {
2450                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
2451                                            finderArgs, this);
2452    
2453                            if ((list != null) && !list.isEmpty()) {
2454                                    for (BlogsEntry blogsEntry : list) {
2455                                            if ((companyId != blogsEntry.getCompanyId())) {
2456                                                    list = null;
2457    
2458                                                    break;
2459                                            }
2460                                    }
2461                            }
2462                    }
2463    
2464                    if (list == null) {
2465                            StringBundler query = null;
2466    
2467                            if (orderByComparator != null) {
2468                                    query = new StringBundler(3 +
2469                                                    (orderByComparator.getOrderByFields().length * 3));
2470                            }
2471                            else {
2472                                    query = new StringBundler(3);
2473                            }
2474    
2475                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2476    
2477                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2478    
2479                            if (orderByComparator != null) {
2480                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2481                                            orderByComparator);
2482                            }
2483                            else
2484                             if (pagination) {
2485                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2486                            }
2487    
2488                            String sql = query.toString();
2489    
2490                            Session session = null;
2491    
2492                            try {
2493                                    session = openSession();
2494    
2495                                    Query q = session.createQuery(sql);
2496    
2497                                    QueryPos qPos = QueryPos.getInstance(q);
2498    
2499                                    qPos.add(companyId);
2500    
2501                                    if (!pagination) {
2502                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2503                                                            start, end, false);
2504    
2505                                            Collections.sort(list);
2506    
2507                                            list = Collections.unmodifiableList(list);
2508                                    }
2509                                    else {
2510                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2511                                                            start, end);
2512                                    }
2513    
2514                                    cacheResult(list);
2515    
2516                                    finderCache.putResult(finderPath, finderArgs, list);
2517                            }
2518                            catch (Exception e) {
2519                                    finderCache.removeResult(finderPath, finderArgs);
2520    
2521                                    throw processException(e);
2522                            }
2523                            finally {
2524                                    closeSession(session);
2525                            }
2526                    }
2527    
2528                    return list;
2529            }
2530    
2531            /**
2532             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2533             *
2534             * @param companyId the company ID
2535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2536             * @return the first matching blogs entry
2537             * @throws NoSuchEntryException if a matching blogs entry could not be found
2538             */
2539            @Override
2540            public BlogsEntry findByCompanyId_First(long companyId,
2541                    OrderByComparator<BlogsEntry> orderByComparator)
2542                    throws NoSuchEntryException {
2543                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2544                                    orderByComparator);
2545    
2546                    if (blogsEntry != null) {
2547                            return blogsEntry;
2548                    }
2549    
2550                    StringBundler msg = new StringBundler(4);
2551    
2552                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2553    
2554                    msg.append("companyId=");
2555                    msg.append(companyId);
2556    
2557                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2558    
2559                    throw new NoSuchEntryException(msg.toString());
2560            }
2561    
2562            /**
2563             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2564             *
2565             * @param companyId the company ID
2566             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2567             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2568             */
2569            @Override
2570            public BlogsEntry fetchByCompanyId_First(long companyId,
2571                    OrderByComparator<BlogsEntry> orderByComparator) {
2572                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2573                                    orderByComparator);
2574    
2575                    if (!list.isEmpty()) {
2576                            return list.get(0);
2577                    }
2578    
2579                    return null;
2580            }
2581    
2582            /**
2583             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2584             *
2585             * @param companyId the company ID
2586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2587             * @return the last matching blogs entry
2588             * @throws NoSuchEntryException if a matching blogs entry could not be found
2589             */
2590            @Override
2591            public BlogsEntry findByCompanyId_Last(long companyId,
2592                    OrderByComparator<BlogsEntry> orderByComparator)
2593                    throws NoSuchEntryException {
2594                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2595                                    orderByComparator);
2596    
2597                    if (blogsEntry != null) {
2598                            return blogsEntry;
2599                    }
2600    
2601                    StringBundler msg = new StringBundler(4);
2602    
2603                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2604    
2605                    msg.append("companyId=");
2606                    msg.append(companyId);
2607    
2608                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2609    
2610                    throw new NoSuchEntryException(msg.toString());
2611            }
2612    
2613            /**
2614             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2615             *
2616             * @param companyId the company ID
2617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2618             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2619             */
2620            @Override
2621            public BlogsEntry fetchByCompanyId_Last(long companyId,
2622                    OrderByComparator<BlogsEntry> orderByComparator) {
2623                    int count = countByCompanyId(companyId);
2624    
2625                    if (count == 0) {
2626                            return null;
2627                    }
2628    
2629                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2630                                    orderByComparator);
2631    
2632                    if (!list.isEmpty()) {
2633                            return list.get(0);
2634                    }
2635    
2636                    return null;
2637            }
2638    
2639            /**
2640             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2641             *
2642             * @param entryId the primary key of the current blogs entry
2643             * @param companyId the company ID
2644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2645             * @return the previous, current, and next blogs entry
2646             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2647             */
2648            @Override
2649            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2650                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2651                    throws NoSuchEntryException {
2652                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2653    
2654                    Session session = null;
2655    
2656                    try {
2657                            session = openSession();
2658    
2659                            BlogsEntry[] array = new BlogsEntryImpl[3];
2660    
2661                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2662                                            companyId, orderByComparator, true);
2663    
2664                            array[1] = blogsEntry;
2665    
2666                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2667                                            companyId, orderByComparator, false);
2668    
2669                            return array;
2670                    }
2671                    catch (Exception e) {
2672                            throw processException(e);
2673                    }
2674                    finally {
2675                            closeSession(session);
2676                    }
2677            }
2678    
2679            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2680                    BlogsEntry blogsEntry, long companyId,
2681                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2682                    StringBundler query = null;
2683    
2684                    if (orderByComparator != null) {
2685                            query = new StringBundler(6 +
2686                                            (orderByComparator.getOrderByFields().length * 6));
2687                    }
2688                    else {
2689                            query = new StringBundler(3);
2690                    }
2691    
2692                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2693    
2694                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2695    
2696                    if (orderByComparator != null) {
2697                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2698    
2699                            if (orderByConditionFields.length > 0) {
2700                                    query.append(WHERE_AND);
2701                            }
2702    
2703                            for (int i = 0; i < orderByConditionFields.length; i++) {
2704                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2705                                    query.append(orderByConditionFields[i]);
2706    
2707                                    if ((i + 1) < orderByConditionFields.length) {
2708                                            if (orderByComparator.isAscending() ^ previous) {
2709                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2710                                            }
2711                                            else {
2712                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2713                                            }
2714                                    }
2715                                    else {
2716                                            if (orderByComparator.isAscending() ^ previous) {
2717                                                    query.append(WHERE_GREATER_THAN);
2718                                            }
2719                                            else {
2720                                                    query.append(WHERE_LESSER_THAN);
2721                                            }
2722                                    }
2723                            }
2724    
2725                            query.append(ORDER_BY_CLAUSE);
2726    
2727                            String[] orderByFields = orderByComparator.getOrderByFields();
2728    
2729                            for (int i = 0; i < orderByFields.length; i++) {
2730                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2731                                    query.append(orderByFields[i]);
2732    
2733                                    if ((i + 1) < orderByFields.length) {
2734                                            if (orderByComparator.isAscending() ^ previous) {
2735                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2736                                            }
2737                                            else {
2738                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2739                                            }
2740                                    }
2741                                    else {
2742                                            if (orderByComparator.isAscending() ^ previous) {
2743                                                    query.append(ORDER_BY_ASC);
2744                                            }
2745                                            else {
2746                                                    query.append(ORDER_BY_DESC);
2747                                            }
2748                                    }
2749                            }
2750                    }
2751                    else {
2752                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2753                    }
2754    
2755                    String sql = query.toString();
2756    
2757                    Query q = session.createQuery(sql);
2758    
2759                    q.setFirstResult(0);
2760                    q.setMaxResults(2);
2761    
2762                    QueryPos qPos = QueryPos.getInstance(q);
2763    
2764                    qPos.add(companyId);
2765    
2766                    if (orderByComparator != null) {
2767                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2768    
2769                            for (Object value : values) {
2770                                    qPos.add(value);
2771                            }
2772                    }
2773    
2774                    List<BlogsEntry> list = q.list();
2775    
2776                    if (list.size() == 2) {
2777                            return list.get(1);
2778                    }
2779                    else {
2780                            return null;
2781                    }
2782            }
2783    
2784            /**
2785             * Removes all the blogs entries where companyId = &#63; from the database.
2786             *
2787             * @param companyId the company ID
2788             */
2789            @Override
2790            public void removeByCompanyId(long companyId) {
2791                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2792                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2793                            remove(blogsEntry);
2794                    }
2795            }
2796    
2797            /**
2798             * Returns the number of blogs entries where companyId = &#63;.
2799             *
2800             * @param companyId the company ID
2801             * @return the number of matching blogs entries
2802             */
2803            @Override
2804            public int countByCompanyId(long companyId) {
2805                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2806    
2807                    Object[] finderArgs = new Object[] { companyId };
2808    
2809                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2810    
2811                    if (count == null) {
2812                            StringBundler query = new StringBundler(2);
2813    
2814                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2815    
2816                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2817    
2818                            String sql = query.toString();
2819    
2820                            Session session = null;
2821    
2822                            try {
2823                                    session = openSession();
2824    
2825                                    Query q = session.createQuery(sql);
2826    
2827                                    QueryPos qPos = QueryPos.getInstance(q);
2828    
2829                                    qPos.add(companyId);
2830    
2831                                    count = (Long)q.uniqueResult();
2832    
2833                                    finderCache.putResult(finderPath, finderArgs, count);
2834                            }
2835                            catch (Exception e) {
2836                                    finderCache.removeResult(finderPath, finderArgs);
2837    
2838                                    throw processException(e);
2839                            }
2840                            finally {
2841                                    closeSession(session);
2842                            }
2843                    }
2844    
2845                    return count.intValue();
2846            }
2847    
2848            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2849            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2850                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2851                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2852                            new String[] { Long.class.getName(), String.class.getName() },
2853                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2854                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2855            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2856                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2857                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2858                            new String[] { Long.class.getName(), String.class.getName() });
2859    
2860            /**
2861             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
2862             *
2863             * @param groupId the group ID
2864             * @param urlTitle the url title
2865             * @return the matching blogs entry
2866             * @throws NoSuchEntryException if a matching blogs entry could not be found
2867             */
2868            @Override
2869            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2870                    throws NoSuchEntryException {
2871                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2872    
2873                    if (blogsEntry == null) {
2874                            StringBundler msg = new StringBundler(6);
2875    
2876                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2877    
2878                            msg.append("groupId=");
2879                            msg.append(groupId);
2880    
2881                            msg.append(", urlTitle=");
2882                            msg.append(urlTitle);
2883    
2884                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2885    
2886                            if (_log.isWarnEnabled()) {
2887                                    _log.warn(msg.toString());
2888                            }
2889    
2890                            throw new NoSuchEntryException(msg.toString());
2891                    }
2892    
2893                    return blogsEntry;
2894            }
2895    
2896            /**
2897             * 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.
2898             *
2899             * @param groupId the group ID
2900             * @param urlTitle the url title
2901             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2902             */
2903            @Override
2904            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2905                    return fetchByG_UT(groupId, urlTitle, true);
2906            }
2907    
2908            /**
2909             * 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.
2910             *
2911             * @param groupId the group ID
2912             * @param urlTitle the url title
2913             * @param retrieveFromCache whether to retrieve from the finder cache
2914             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2915             */
2916            @Override
2917            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2918                    boolean retrieveFromCache) {
2919                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2920    
2921                    Object result = null;
2922    
2923                    if (retrieveFromCache) {
2924                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_UT,
2925                                            finderArgs, this);
2926                    }
2927    
2928                    if (result instanceof BlogsEntry) {
2929                            BlogsEntry blogsEntry = (BlogsEntry)result;
2930    
2931                            if ((groupId != blogsEntry.getGroupId()) ||
2932                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
2933                                    result = null;
2934                            }
2935                    }
2936    
2937                    if (result == null) {
2938                            StringBundler query = new StringBundler(4);
2939    
2940                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2941    
2942                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2943    
2944                            boolean bindUrlTitle = false;
2945    
2946                            if (urlTitle == null) {
2947                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2948                            }
2949                            else if (urlTitle.equals(StringPool.BLANK)) {
2950                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2951                            }
2952                            else {
2953                                    bindUrlTitle = true;
2954    
2955                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2956                            }
2957    
2958                            String sql = query.toString();
2959    
2960                            Session session = null;
2961    
2962                            try {
2963                                    session = openSession();
2964    
2965                                    Query q = session.createQuery(sql);
2966    
2967                                    QueryPos qPos = QueryPos.getInstance(q);
2968    
2969                                    qPos.add(groupId);
2970    
2971                                    if (bindUrlTitle) {
2972                                            qPos.add(urlTitle);
2973                                    }
2974    
2975                                    List<BlogsEntry> list = q.list();
2976    
2977                                    if (list.isEmpty()) {
2978                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2979                                                    finderArgs, list);
2980                                    }
2981                                    else {
2982                                            BlogsEntry blogsEntry = list.get(0);
2983    
2984                                            result = blogsEntry;
2985    
2986                                            cacheResult(blogsEntry);
2987    
2988                                            if ((blogsEntry.getGroupId() != groupId) ||
2989                                                            (blogsEntry.getUrlTitle() == null) ||
2990                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
2991                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2992                                                            finderArgs, blogsEntry);
2993                                            }
2994                                    }
2995                            }
2996                            catch (Exception e) {
2997                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, finderArgs);
2998    
2999                                    throw processException(e);
3000                            }
3001                            finally {
3002                                    closeSession(session);
3003                            }
3004                    }
3005    
3006                    if (result instanceof List<?>) {
3007                            return null;
3008                    }
3009                    else {
3010                            return (BlogsEntry)result;
3011                    }
3012            }
3013    
3014            /**
3015             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
3016             *
3017             * @param groupId the group ID
3018             * @param urlTitle the url title
3019             * @return the blogs entry that was removed
3020             */
3021            @Override
3022            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
3023                    throws NoSuchEntryException {
3024                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
3025    
3026                    return remove(blogsEntry);
3027            }
3028    
3029            /**
3030             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
3031             *
3032             * @param groupId the group ID
3033             * @param urlTitle the url title
3034             * @return the number of matching blogs entries
3035             */
3036            @Override
3037            public int countByG_UT(long groupId, String urlTitle) {
3038                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
3039    
3040                    Object[] finderArgs = new Object[] { groupId, urlTitle };
3041    
3042                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3043    
3044                    if (count == null) {
3045                            StringBundler query = new StringBundler(3);
3046    
3047                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3048    
3049                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
3050    
3051                            boolean bindUrlTitle = false;
3052    
3053                            if (urlTitle == null) {
3054                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
3055                            }
3056                            else if (urlTitle.equals(StringPool.BLANK)) {
3057                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
3058                            }
3059                            else {
3060                                    bindUrlTitle = true;
3061    
3062                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
3063                            }
3064    
3065                            String sql = query.toString();
3066    
3067                            Session session = null;
3068    
3069                            try {
3070                                    session = openSession();
3071    
3072                                    Query q = session.createQuery(sql);
3073    
3074                                    QueryPos qPos = QueryPos.getInstance(q);
3075    
3076                                    qPos.add(groupId);
3077    
3078                                    if (bindUrlTitle) {
3079                                            qPos.add(urlTitle);
3080                                    }
3081    
3082                                    count = (Long)q.uniqueResult();
3083    
3084                                    finderCache.putResult(finderPath, finderArgs, count);
3085                            }
3086                            catch (Exception e) {
3087                                    finderCache.removeResult(finderPath, finderArgs);
3088    
3089                                    throw processException(e);
3090                            }
3091                            finally {
3092                                    closeSession(session);
3093                            }
3094                    }
3095    
3096                    return count.intValue();
3097            }
3098    
3099            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3100            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3101            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3102            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3103            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3104                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3105                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3106                            new String[] {
3107                                    Long.class.getName(), Date.class.getName(),
3108                                    
3109                            Integer.class.getName(), Integer.class.getName(),
3110                                    OrderByComparator.class.getName()
3111                            });
3112            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3113                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3114                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3115                            new String[] { Long.class.getName(), Date.class.getName() });
3116    
3117            /**
3118             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3119             *
3120             * @param groupId the group ID
3121             * @param displayDate the display date
3122             * @return the matching blogs entries
3123             */
3124            @Override
3125            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3126                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3127                            QueryUtil.ALL_POS, null);
3128            }
3129    
3130            /**
3131             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3132             *
3133             * <p>
3134             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3135             * </p>
3136             *
3137             * @param groupId the group ID
3138             * @param displayDate the display date
3139             * @param start the lower bound of the range of blogs entries
3140             * @param end the upper bound of the range of blogs entries (not inclusive)
3141             * @return the range of matching blogs entries
3142             */
3143            @Override
3144            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3145                    int start, int end) {
3146                    return findByG_LtD(groupId, displayDate, start, end, null);
3147            }
3148    
3149            /**
3150             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3151             *
3152             * <p>
3153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3154             * </p>
3155             *
3156             * @param groupId the group ID
3157             * @param displayDate the display date
3158             * @param start the lower bound of the range of blogs entries
3159             * @param end the upper bound of the range of blogs entries (not inclusive)
3160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3161             * @return the ordered range of matching blogs entries
3162             */
3163            @Override
3164            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3165                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3166                    return findByG_LtD(groupId, displayDate, start, end, orderByComparator,
3167                            true);
3168            }
3169    
3170            /**
3171             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3172             *
3173             * <p>
3174             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3175             * </p>
3176             *
3177             * @param groupId the group ID
3178             * @param displayDate the display date
3179             * @param start the lower bound of the range of blogs entries
3180             * @param end the upper bound of the range of blogs entries (not inclusive)
3181             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3182             * @param retrieveFromCache whether to retrieve from the finder cache
3183             * @return the ordered range of matching blogs entries
3184             */
3185            @Override
3186            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3187                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
3188                    boolean retrieveFromCache) {
3189                    boolean pagination = true;
3190                    FinderPath finderPath = null;
3191                    Object[] finderArgs = null;
3192    
3193                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3194                    finderArgs = new Object[] {
3195                                    groupId, displayDate,
3196                                    
3197                                    start, end, orderByComparator
3198                            };
3199    
3200                    List<BlogsEntry> list = null;
3201    
3202                    if (retrieveFromCache) {
3203                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
3204                                            finderArgs, this);
3205    
3206                            if ((list != null) && !list.isEmpty()) {
3207                                    for (BlogsEntry blogsEntry : list) {
3208                                            if ((groupId != blogsEntry.getGroupId()) ||
3209                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
3210                                                                                                                                            .getTime())) {
3211                                                    list = null;
3212    
3213                                                    break;
3214                                            }
3215                                    }
3216                            }
3217                    }
3218    
3219                    if (list == null) {
3220                            StringBundler query = null;
3221    
3222                            if (orderByComparator != null) {
3223                                    query = new StringBundler(4 +
3224                                                    (orderByComparator.getOrderByFields().length * 3));
3225                            }
3226                            else {
3227                                    query = new StringBundler(4);
3228                            }
3229    
3230                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3231    
3232                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3233    
3234                            boolean bindDisplayDate = false;
3235    
3236                            if (displayDate == null) {
3237                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3238                            }
3239                            else {
3240                                    bindDisplayDate = true;
3241    
3242                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3243                            }
3244    
3245                            if (orderByComparator != null) {
3246                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3247                                            orderByComparator);
3248                            }
3249                            else
3250                             if (pagination) {
3251                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3252                            }
3253    
3254                            String sql = query.toString();
3255    
3256                            Session session = null;
3257    
3258                            try {
3259                                    session = openSession();
3260    
3261                                    Query q = session.createQuery(sql);
3262    
3263                                    QueryPos qPos = QueryPos.getInstance(q);
3264    
3265                                    qPos.add(groupId);
3266    
3267                                    if (bindDisplayDate) {
3268                                            qPos.add(new Timestamp(displayDate.getTime()));
3269                                    }
3270    
3271                                    if (!pagination) {
3272                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3273                                                            start, end, false);
3274    
3275                                            Collections.sort(list);
3276    
3277                                            list = Collections.unmodifiableList(list);
3278                                    }
3279                                    else {
3280                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3281                                                            start, end);
3282                                    }
3283    
3284                                    cacheResult(list);
3285    
3286                                    finderCache.putResult(finderPath, finderArgs, list);
3287                            }
3288                            catch (Exception e) {
3289                                    finderCache.removeResult(finderPath, finderArgs);
3290    
3291                                    throw processException(e);
3292                            }
3293                            finally {
3294                                    closeSession(session);
3295                            }
3296                    }
3297    
3298                    return list;
3299            }
3300    
3301            /**
3302             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3303             *
3304             * @param groupId the group ID
3305             * @param displayDate the display date
3306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3307             * @return the first matching blogs entry
3308             * @throws NoSuchEntryException if a matching blogs entry could not be found
3309             */
3310            @Override
3311            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3312                    OrderByComparator<BlogsEntry> orderByComparator)
3313                    throws NoSuchEntryException {
3314                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3315                                    orderByComparator);
3316    
3317                    if (blogsEntry != null) {
3318                            return blogsEntry;
3319                    }
3320    
3321                    StringBundler msg = new StringBundler(6);
3322    
3323                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3324    
3325                    msg.append("groupId=");
3326                    msg.append(groupId);
3327    
3328                    msg.append(", displayDate=");
3329                    msg.append(displayDate);
3330    
3331                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3332    
3333                    throw new NoSuchEntryException(msg.toString());
3334            }
3335    
3336            /**
3337             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3338             *
3339             * @param groupId the group ID
3340             * @param displayDate the display date
3341             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3342             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3343             */
3344            @Override
3345            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3346                    OrderByComparator<BlogsEntry> orderByComparator) {
3347                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3348                                    orderByComparator);
3349    
3350                    if (!list.isEmpty()) {
3351                            return list.get(0);
3352                    }
3353    
3354                    return null;
3355            }
3356    
3357            /**
3358             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3359             *
3360             * @param groupId the group ID
3361             * @param displayDate the display date
3362             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3363             * @return the last matching blogs entry
3364             * @throws NoSuchEntryException if a matching blogs entry could not be found
3365             */
3366            @Override
3367            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3368                    OrderByComparator<BlogsEntry> orderByComparator)
3369                    throws NoSuchEntryException {
3370                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3371                                    orderByComparator);
3372    
3373                    if (blogsEntry != null) {
3374                            return blogsEntry;
3375                    }
3376    
3377                    StringBundler msg = new StringBundler(6);
3378    
3379                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3380    
3381                    msg.append("groupId=");
3382                    msg.append(groupId);
3383    
3384                    msg.append(", displayDate=");
3385                    msg.append(displayDate);
3386    
3387                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3388    
3389                    throw new NoSuchEntryException(msg.toString());
3390            }
3391    
3392            /**
3393             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3394             *
3395             * @param groupId the group ID
3396             * @param displayDate the display date
3397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3398             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3399             */
3400            @Override
3401            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3402                    OrderByComparator<BlogsEntry> orderByComparator) {
3403                    int count = countByG_LtD(groupId, displayDate);
3404    
3405                    if (count == 0) {
3406                            return null;
3407                    }
3408    
3409                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3410                                    count, orderByComparator);
3411    
3412                    if (!list.isEmpty()) {
3413                            return list.get(0);
3414                    }
3415    
3416                    return null;
3417            }
3418    
3419            /**
3420             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3421             *
3422             * @param entryId the primary key of the current blogs entry
3423             * @param groupId the group ID
3424             * @param displayDate the display date
3425             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3426             * @return the previous, current, and next blogs entry
3427             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3428             */
3429            @Override
3430            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3431                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3432                    throws NoSuchEntryException {
3433                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3434    
3435                    Session session = null;
3436    
3437                    try {
3438                            session = openSession();
3439    
3440                            BlogsEntry[] array = new BlogsEntryImpl[3];
3441    
3442                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3443                                            displayDate, orderByComparator, true);
3444    
3445                            array[1] = blogsEntry;
3446    
3447                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3448                                            displayDate, orderByComparator, false);
3449    
3450                            return array;
3451                    }
3452                    catch (Exception e) {
3453                            throw processException(e);
3454                    }
3455                    finally {
3456                            closeSession(session);
3457                    }
3458            }
3459    
3460            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3461                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3462                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3463                    StringBundler query = null;
3464    
3465                    if (orderByComparator != null) {
3466                            query = new StringBundler(6 +
3467                                            (orderByComparator.getOrderByFields().length * 6));
3468                    }
3469                    else {
3470                            query = new StringBundler(3);
3471                    }
3472    
3473                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3474    
3475                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3476    
3477                    boolean bindDisplayDate = false;
3478    
3479                    if (displayDate == null) {
3480                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3481                    }
3482                    else {
3483                            bindDisplayDate = true;
3484    
3485                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3486                    }
3487    
3488                    if (orderByComparator != null) {
3489                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3490    
3491                            if (orderByConditionFields.length > 0) {
3492                                    query.append(WHERE_AND);
3493                            }
3494    
3495                            for (int i = 0; i < orderByConditionFields.length; i++) {
3496                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3497                                    query.append(orderByConditionFields[i]);
3498    
3499                                    if ((i + 1) < orderByConditionFields.length) {
3500                                            if (orderByComparator.isAscending() ^ previous) {
3501                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3502                                            }
3503                                            else {
3504                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3505                                            }
3506                                    }
3507                                    else {
3508                                            if (orderByComparator.isAscending() ^ previous) {
3509                                                    query.append(WHERE_GREATER_THAN);
3510                                            }
3511                                            else {
3512                                                    query.append(WHERE_LESSER_THAN);
3513                                            }
3514                                    }
3515                            }
3516    
3517                            query.append(ORDER_BY_CLAUSE);
3518    
3519                            String[] orderByFields = orderByComparator.getOrderByFields();
3520    
3521                            for (int i = 0; i < orderByFields.length; i++) {
3522                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3523                                    query.append(orderByFields[i]);
3524    
3525                                    if ((i + 1) < orderByFields.length) {
3526                                            if (orderByComparator.isAscending() ^ previous) {
3527                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3528                                            }
3529                                            else {
3530                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3531                                            }
3532                                    }
3533                                    else {
3534                                            if (orderByComparator.isAscending() ^ previous) {
3535                                                    query.append(ORDER_BY_ASC);
3536                                            }
3537                                            else {
3538                                                    query.append(ORDER_BY_DESC);
3539                                            }
3540                                    }
3541                            }
3542                    }
3543                    else {
3544                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3545                    }
3546    
3547                    String sql = query.toString();
3548    
3549                    Query q = session.createQuery(sql);
3550    
3551                    q.setFirstResult(0);
3552                    q.setMaxResults(2);
3553    
3554                    QueryPos qPos = QueryPos.getInstance(q);
3555    
3556                    qPos.add(groupId);
3557    
3558                    if (bindDisplayDate) {
3559                            qPos.add(new Timestamp(displayDate.getTime()));
3560                    }
3561    
3562                    if (orderByComparator != null) {
3563                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3564    
3565                            for (Object value : values) {
3566                                    qPos.add(value);
3567                            }
3568                    }
3569    
3570                    List<BlogsEntry> list = q.list();
3571    
3572                    if (list.size() == 2) {
3573                            return list.get(1);
3574                    }
3575                    else {
3576                            return null;
3577                    }
3578            }
3579    
3580            /**
3581             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3582             *
3583             * @param groupId the group ID
3584             * @param displayDate the display date
3585             * @return the matching blogs entries that the user has permission to view
3586             */
3587            @Override
3588            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3589                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3590                            QueryUtil.ALL_POS, null);
3591            }
3592    
3593            /**
3594             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3595             *
3596             * <p>
3597             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3598             * </p>
3599             *
3600             * @param groupId the group ID
3601             * @param displayDate the display date
3602             * @param start the lower bound of the range of blogs entries
3603             * @param end the upper bound of the range of blogs entries (not inclusive)
3604             * @return the range of matching blogs entries that the user has permission to view
3605             */
3606            @Override
3607            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3608                    int start, int end) {
3609                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3610            }
3611    
3612            /**
3613             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3614             *
3615             * <p>
3616             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3617             * </p>
3618             *
3619             * @param groupId the group ID
3620             * @param displayDate the display date
3621             * @param start the lower bound of the range of blogs entries
3622             * @param end the upper bound of the range of blogs entries (not inclusive)
3623             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3624             * @return the ordered range of matching blogs entries that the user has permission to view
3625             */
3626            @Override
3627            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3628                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3629                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3630                            return findByG_LtD(groupId, displayDate, start, end,
3631                                    orderByComparator);
3632                    }
3633    
3634                    StringBundler query = null;
3635    
3636                    if (orderByComparator != null) {
3637                            query = new StringBundler(4 +
3638                                            (orderByComparator.getOrderByFields().length * 3));
3639                    }
3640                    else {
3641                            query = new StringBundler(4);
3642                    }
3643    
3644                    if (getDB().isSupportsInlineDistinct()) {
3645                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3646                    }
3647                    else {
3648                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3649                    }
3650    
3651                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3652    
3653                    boolean bindDisplayDate = false;
3654    
3655                    if (displayDate == null) {
3656                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3657                    }
3658                    else {
3659                            bindDisplayDate = true;
3660    
3661                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3662                    }
3663    
3664                    if (!getDB().isSupportsInlineDistinct()) {
3665                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3666                    }
3667    
3668                    if (orderByComparator != null) {
3669                            if (getDB().isSupportsInlineDistinct()) {
3670                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3671                                            orderByComparator, true);
3672                            }
3673                            else {
3674                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3675                                            orderByComparator, true);
3676                            }
3677                    }
3678                    else {
3679                            if (getDB().isSupportsInlineDistinct()) {
3680                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3681                            }
3682                            else {
3683                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3684                            }
3685                    }
3686    
3687                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3688                                    BlogsEntry.class.getName(),
3689                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3690    
3691                    Session session = null;
3692    
3693                    try {
3694                            session = openSession();
3695    
3696                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3697    
3698                            if (getDB().isSupportsInlineDistinct()) {
3699                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3700                            }
3701                            else {
3702                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3703                            }
3704    
3705                            QueryPos qPos = QueryPos.getInstance(q);
3706    
3707                            qPos.add(groupId);
3708    
3709                            if (bindDisplayDate) {
3710                                    qPos.add(new Timestamp(displayDate.getTime()));
3711                            }
3712    
3713                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3714                    }
3715                    catch (Exception e) {
3716                            throw processException(e);
3717                    }
3718                    finally {
3719                            closeSession(session);
3720                    }
3721            }
3722    
3723            /**
3724             * 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;.
3725             *
3726             * @param entryId the primary key of the current blogs entry
3727             * @param groupId the group ID
3728             * @param displayDate the display date
3729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3730             * @return the previous, current, and next blogs entry
3731             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3732             */
3733            @Override
3734            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3735                    long groupId, Date displayDate,
3736                    OrderByComparator<BlogsEntry> orderByComparator)
3737                    throws NoSuchEntryException {
3738                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3739                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3740                                    orderByComparator);
3741                    }
3742    
3743                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3744    
3745                    Session session = null;
3746    
3747                    try {
3748                            session = openSession();
3749    
3750                            BlogsEntry[] array = new BlogsEntryImpl[3];
3751    
3752                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3753                                            groupId, displayDate, orderByComparator, true);
3754    
3755                            array[1] = blogsEntry;
3756    
3757                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3758                                            groupId, displayDate, orderByComparator, false);
3759    
3760                            return array;
3761                    }
3762                    catch (Exception e) {
3763                            throw processException(e);
3764                    }
3765                    finally {
3766                            closeSession(session);
3767                    }
3768            }
3769    
3770            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3771                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3772                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3773                    StringBundler query = null;
3774    
3775                    if (orderByComparator != null) {
3776                            query = new StringBundler(6 +
3777                                            (orderByComparator.getOrderByFields().length * 6));
3778                    }
3779                    else {
3780                            query = new StringBundler(3);
3781                    }
3782    
3783                    if (getDB().isSupportsInlineDistinct()) {
3784                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3785                    }
3786                    else {
3787                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3788                    }
3789    
3790                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3791    
3792                    boolean bindDisplayDate = false;
3793    
3794                    if (displayDate == null) {
3795                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3796                    }
3797                    else {
3798                            bindDisplayDate = true;
3799    
3800                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3801                    }
3802    
3803                    if (!getDB().isSupportsInlineDistinct()) {
3804                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3805                    }
3806    
3807                    if (orderByComparator != null) {
3808                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3809    
3810                            if (orderByConditionFields.length > 0) {
3811                                    query.append(WHERE_AND);
3812                            }
3813    
3814                            for (int i = 0; i < orderByConditionFields.length; i++) {
3815                                    if (getDB().isSupportsInlineDistinct()) {
3816                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3817                                    }
3818                                    else {
3819                                            query.append(_ORDER_BY_ENTITY_TABLE);
3820                                    }
3821    
3822                                    query.append(orderByConditionFields[i]);
3823    
3824                                    if ((i + 1) < orderByConditionFields.length) {
3825                                            if (orderByComparator.isAscending() ^ previous) {
3826                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3827                                            }
3828                                            else {
3829                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3830                                            }
3831                                    }
3832                                    else {
3833                                            if (orderByComparator.isAscending() ^ previous) {
3834                                                    query.append(WHERE_GREATER_THAN);
3835                                            }
3836                                            else {
3837                                                    query.append(WHERE_LESSER_THAN);
3838                                            }
3839                                    }
3840                            }
3841    
3842                            query.append(ORDER_BY_CLAUSE);
3843    
3844                            String[] orderByFields = orderByComparator.getOrderByFields();
3845    
3846                            for (int i = 0; i < orderByFields.length; i++) {
3847                                    if (getDB().isSupportsInlineDistinct()) {
3848                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3849                                    }
3850                                    else {
3851                                            query.append(_ORDER_BY_ENTITY_TABLE);
3852                                    }
3853    
3854                                    query.append(orderByFields[i]);
3855    
3856                                    if ((i + 1) < orderByFields.length) {
3857                                            if (orderByComparator.isAscending() ^ previous) {
3858                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3859                                            }
3860                                            else {
3861                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3862                                            }
3863                                    }
3864                                    else {
3865                                            if (orderByComparator.isAscending() ^ previous) {
3866                                                    query.append(ORDER_BY_ASC);
3867                                            }
3868                                            else {
3869                                                    query.append(ORDER_BY_DESC);
3870                                            }
3871                                    }
3872                            }
3873                    }
3874                    else {
3875                            if (getDB().isSupportsInlineDistinct()) {
3876                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3877                            }
3878                            else {
3879                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3880                            }
3881                    }
3882    
3883                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3884                                    BlogsEntry.class.getName(),
3885                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3886    
3887                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3888    
3889                    q.setFirstResult(0);
3890                    q.setMaxResults(2);
3891    
3892                    if (getDB().isSupportsInlineDistinct()) {
3893                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3894                    }
3895                    else {
3896                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3897                    }
3898    
3899                    QueryPos qPos = QueryPos.getInstance(q);
3900    
3901                    qPos.add(groupId);
3902    
3903                    if (bindDisplayDate) {
3904                            qPos.add(new Timestamp(displayDate.getTime()));
3905                    }
3906    
3907                    if (orderByComparator != null) {
3908                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3909    
3910                            for (Object value : values) {
3911                                    qPos.add(value);
3912                            }
3913                    }
3914    
3915                    List<BlogsEntry> list = q.list();
3916    
3917                    if (list.size() == 2) {
3918                            return list.get(1);
3919                    }
3920                    else {
3921                            return null;
3922                    }
3923            }
3924    
3925            /**
3926             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3927             *
3928             * @param groupId the group ID
3929             * @param displayDate the display date
3930             */
3931            @Override
3932            public void removeByG_LtD(long groupId, Date displayDate) {
3933                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3934                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3935                            remove(blogsEntry);
3936                    }
3937            }
3938    
3939            /**
3940             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3941             *
3942             * @param groupId the group ID
3943             * @param displayDate the display date
3944             * @return the number of matching blogs entries
3945             */
3946            @Override
3947            public int countByG_LtD(long groupId, Date displayDate) {
3948                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3949    
3950                    Object[] finderArgs = new Object[] { groupId, displayDate };
3951    
3952                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3953    
3954                    if (count == null) {
3955                            StringBundler query = new StringBundler(3);
3956    
3957                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3958    
3959                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3960    
3961                            boolean bindDisplayDate = false;
3962    
3963                            if (displayDate == null) {
3964                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3965                            }
3966                            else {
3967                                    bindDisplayDate = true;
3968    
3969                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3970                            }
3971    
3972                            String sql = query.toString();
3973    
3974                            Session session = null;
3975    
3976                            try {
3977                                    session = openSession();
3978    
3979                                    Query q = session.createQuery(sql);
3980    
3981                                    QueryPos qPos = QueryPos.getInstance(q);
3982    
3983                                    qPos.add(groupId);
3984    
3985                                    if (bindDisplayDate) {
3986                                            qPos.add(new Timestamp(displayDate.getTime()));
3987                                    }
3988    
3989                                    count = (Long)q.uniqueResult();
3990    
3991                                    finderCache.putResult(finderPath, finderArgs, count);
3992                            }
3993                            catch (Exception e) {
3994                                    finderCache.removeResult(finderPath, finderArgs);
3995    
3996                                    throw processException(e);
3997                            }
3998                            finally {
3999                                    closeSession(session);
4000                            }
4001                    }
4002    
4003                    return count.intValue();
4004            }
4005    
4006            /**
4007             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4008             *
4009             * @param groupId the group ID
4010             * @param displayDate the display date
4011             * @return the number of matching blogs entries that the user has permission to view
4012             */
4013            @Override
4014            public int filterCountByG_LtD(long groupId, Date displayDate) {
4015                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4016                            return countByG_LtD(groupId, displayDate);
4017                    }
4018    
4019                    StringBundler query = new StringBundler(3);
4020    
4021                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4022    
4023                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4024    
4025                    boolean bindDisplayDate = false;
4026    
4027                    if (displayDate == null) {
4028                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4029                    }
4030                    else {
4031                            bindDisplayDate = true;
4032    
4033                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4034                    }
4035    
4036                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4037                                    BlogsEntry.class.getName(),
4038                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4039    
4040                    Session session = null;
4041    
4042                    try {
4043                            session = openSession();
4044    
4045                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4046    
4047                            q.addScalar(COUNT_COLUMN_NAME,
4048                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4049    
4050                            QueryPos qPos = QueryPos.getInstance(q);
4051    
4052                            qPos.add(groupId);
4053    
4054                            if (bindDisplayDate) {
4055                                    qPos.add(new Timestamp(displayDate.getTime()));
4056                            }
4057    
4058                            Long count = (Long)q.uniqueResult();
4059    
4060                            return count.intValue();
4061                    }
4062                    catch (Exception e) {
4063                            throw processException(e);
4064                    }
4065                    finally {
4066                            closeSession(session);
4067                    }
4068            }
4069    
4070            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4071            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
4072            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
4073            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4074                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4075                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4076                            new String[] {
4077                                    Long.class.getName(), Integer.class.getName(),
4078                                    
4079                            Integer.class.getName(), Integer.class.getName(),
4080                                    OrderByComparator.class.getName()
4081                            });
4082            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4083                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4085                            new String[] { Long.class.getName(), Integer.class.getName() },
4086                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4087                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4088                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4089                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4090            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4091                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4093                            new String[] { Long.class.getName(), Integer.class.getName() });
4094    
4095            /**
4096             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
4097             *
4098             * @param groupId the group ID
4099             * @param status the status
4100             * @return the matching blogs entries
4101             */
4102            @Override
4103            public List<BlogsEntry> findByG_S(long groupId, int status) {
4104                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4105                            null);
4106            }
4107    
4108            /**
4109             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
4110             *
4111             * <p>
4112             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4113             * </p>
4114             *
4115             * @param groupId the group ID
4116             * @param status the status
4117             * @param start the lower bound of the range of blogs entries
4118             * @param end the upper bound of the range of blogs entries (not inclusive)
4119             * @return the range of matching blogs entries
4120             */
4121            @Override
4122            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4123                    int end) {
4124                    return findByG_S(groupId, status, start, end, null);
4125            }
4126    
4127            /**
4128             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4129             *
4130             * <p>
4131             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4132             * </p>
4133             *
4134             * @param groupId the group ID
4135             * @param status the status
4136             * @param start the lower bound of the range of blogs entries
4137             * @param end the upper bound of the range of blogs entries (not inclusive)
4138             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4139             * @return the ordered range of matching blogs entries
4140             */
4141            @Override
4142            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4143                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4144                    return findByG_S(groupId, status, start, end, orderByComparator, true);
4145            }
4146    
4147            /**
4148             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4149             *
4150             * <p>
4151             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4152             * </p>
4153             *
4154             * @param groupId the group ID
4155             * @param status the status
4156             * @param start the lower bound of the range of blogs entries
4157             * @param end the upper bound of the range of blogs entries (not inclusive)
4158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4159             * @param retrieveFromCache whether to retrieve from the finder cache
4160             * @return the ordered range of matching blogs entries
4161             */
4162            @Override
4163            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4164                    int end, OrderByComparator<BlogsEntry> orderByComparator,
4165                    boolean retrieveFromCache) {
4166                    boolean pagination = true;
4167                    FinderPath finderPath = null;
4168                    Object[] finderArgs = null;
4169    
4170                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4171                                    (orderByComparator == null)) {
4172                            pagination = false;
4173                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4174                            finderArgs = new Object[] { groupId, status };
4175                    }
4176                    else {
4177                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4178                            finderArgs = new Object[] {
4179                                            groupId, status,
4180                                            
4181                                            start, end, orderByComparator
4182                                    };
4183                    }
4184    
4185                    List<BlogsEntry> list = null;
4186    
4187                    if (retrieveFromCache) {
4188                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
4189                                            finderArgs, this);
4190    
4191                            if ((list != null) && !list.isEmpty()) {
4192                                    for (BlogsEntry blogsEntry : list) {
4193                                            if ((groupId != blogsEntry.getGroupId()) ||
4194                                                            (status != blogsEntry.getStatus())) {
4195                                                    list = null;
4196    
4197                                                    break;
4198                                            }
4199                                    }
4200                            }
4201                    }
4202    
4203                    if (list == null) {
4204                            StringBundler query = null;
4205    
4206                            if (orderByComparator != null) {
4207                                    query = new StringBundler(4 +
4208                                                    (orderByComparator.getOrderByFields().length * 3));
4209                            }
4210                            else {
4211                                    query = new StringBundler(4);
4212                            }
4213    
4214                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4215    
4216                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4217    
4218                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4219    
4220                            if (orderByComparator != null) {
4221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4222                                            orderByComparator);
4223                            }
4224                            else
4225                             if (pagination) {
4226                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4227                            }
4228    
4229                            String sql = query.toString();
4230    
4231                            Session session = null;
4232    
4233                            try {
4234                                    session = openSession();
4235    
4236                                    Query q = session.createQuery(sql);
4237    
4238                                    QueryPos qPos = QueryPos.getInstance(q);
4239    
4240                                    qPos.add(groupId);
4241    
4242                                    qPos.add(status);
4243    
4244                                    if (!pagination) {
4245                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4246                                                            start, end, false);
4247    
4248                                            Collections.sort(list);
4249    
4250                                            list = Collections.unmodifiableList(list);
4251                                    }
4252                                    else {
4253                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4254                                                            start, end);
4255                                    }
4256    
4257                                    cacheResult(list);
4258    
4259                                    finderCache.putResult(finderPath, finderArgs, list);
4260                            }
4261                            catch (Exception e) {
4262                                    finderCache.removeResult(finderPath, finderArgs);
4263    
4264                                    throw processException(e);
4265                            }
4266                            finally {
4267                                    closeSession(session);
4268                            }
4269                    }
4270    
4271                    return list;
4272            }
4273    
4274            /**
4275             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4276             *
4277             * @param groupId the group ID
4278             * @param status the status
4279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4280             * @return the first matching blogs entry
4281             * @throws NoSuchEntryException if a matching blogs entry could not be found
4282             */
4283            @Override
4284            public BlogsEntry findByG_S_First(long groupId, int status,
4285                    OrderByComparator<BlogsEntry> orderByComparator)
4286                    throws NoSuchEntryException {
4287                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4288                                    orderByComparator);
4289    
4290                    if (blogsEntry != null) {
4291                            return blogsEntry;
4292                    }
4293    
4294                    StringBundler msg = new StringBundler(6);
4295    
4296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4297    
4298                    msg.append("groupId=");
4299                    msg.append(groupId);
4300    
4301                    msg.append(", status=");
4302                    msg.append(status);
4303    
4304                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4305    
4306                    throw new NoSuchEntryException(msg.toString());
4307            }
4308    
4309            /**
4310             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4311             *
4312             * @param groupId the group ID
4313             * @param status the status
4314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4315             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4316             */
4317            @Override
4318            public BlogsEntry fetchByG_S_First(long groupId, int status,
4319                    OrderByComparator<BlogsEntry> orderByComparator) {
4320                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4321                                    orderByComparator);
4322    
4323                    if (!list.isEmpty()) {
4324                            return list.get(0);
4325                    }
4326    
4327                    return null;
4328            }
4329    
4330            /**
4331             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4332             *
4333             * @param groupId the group ID
4334             * @param status the status
4335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4336             * @return the last matching blogs entry
4337             * @throws NoSuchEntryException if a matching blogs entry could not be found
4338             */
4339            @Override
4340            public BlogsEntry findByG_S_Last(long groupId, int status,
4341                    OrderByComparator<BlogsEntry> orderByComparator)
4342                    throws NoSuchEntryException {
4343                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4344                                    orderByComparator);
4345    
4346                    if (blogsEntry != null) {
4347                            return blogsEntry;
4348                    }
4349    
4350                    StringBundler msg = new StringBundler(6);
4351    
4352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4353    
4354                    msg.append("groupId=");
4355                    msg.append(groupId);
4356    
4357                    msg.append(", status=");
4358                    msg.append(status);
4359    
4360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4361    
4362                    throw new NoSuchEntryException(msg.toString());
4363            }
4364    
4365            /**
4366             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4367             *
4368             * @param groupId the group ID
4369             * @param status the status
4370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4371             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4372             */
4373            @Override
4374            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4375                    OrderByComparator<BlogsEntry> orderByComparator) {
4376                    int count = countByG_S(groupId, status);
4377    
4378                    if (count == 0) {
4379                            return null;
4380                    }
4381    
4382                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4383                                    orderByComparator);
4384    
4385                    if (!list.isEmpty()) {
4386                            return list.get(0);
4387                    }
4388    
4389                    return null;
4390            }
4391    
4392            /**
4393             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4394             *
4395             * @param entryId the primary key of the current blogs entry
4396             * @param groupId the group ID
4397             * @param status the status
4398             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4399             * @return the previous, current, and next blogs entry
4400             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4401             */
4402            @Override
4403            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4404                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4405                    throws NoSuchEntryException {
4406                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4407    
4408                    Session session = null;
4409    
4410                    try {
4411                            session = openSession();
4412    
4413                            BlogsEntry[] array = new BlogsEntryImpl[3];
4414    
4415                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4416                                            status, orderByComparator, true);
4417    
4418                            array[1] = blogsEntry;
4419    
4420                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4421                                            status, orderByComparator, false);
4422    
4423                            return array;
4424                    }
4425                    catch (Exception e) {
4426                            throw processException(e);
4427                    }
4428                    finally {
4429                            closeSession(session);
4430                    }
4431            }
4432    
4433            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4434                    BlogsEntry blogsEntry, long groupId, int status,
4435                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4436                    StringBundler query = null;
4437    
4438                    if (orderByComparator != null) {
4439                            query = new StringBundler(6 +
4440                                            (orderByComparator.getOrderByFields().length * 6));
4441                    }
4442                    else {
4443                            query = new StringBundler(3);
4444                    }
4445    
4446                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4447    
4448                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4449    
4450                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4451    
4452                    if (orderByComparator != null) {
4453                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4454    
4455                            if (orderByConditionFields.length > 0) {
4456                                    query.append(WHERE_AND);
4457                            }
4458    
4459                            for (int i = 0; i < orderByConditionFields.length; i++) {
4460                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4461                                    query.append(orderByConditionFields[i]);
4462    
4463                                    if ((i + 1) < orderByConditionFields.length) {
4464                                            if (orderByComparator.isAscending() ^ previous) {
4465                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4466                                            }
4467                                            else {
4468                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4469                                            }
4470                                    }
4471                                    else {
4472                                            if (orderByComparator.isAscending() ^ previous) {
4473                                                    query.append(WHERE_GREATER_THAN);
4474                                            }
4475                                            else {
4476                                                    query.append(WHERE_LESSER_THAN);
4477                                            }
4478                                    }
4479                            }
4480    
4481                            query.append(ORDER_BY_CLAUSE);
4482    
4483                            String[] orderByFields = orderByComparator.getOrderByFields();
4484    
4485                            for (int i = 0; i < orderByFields.length; i++) {
4486                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4487                                    query.append(orderByFields[i]);
4488    
4489                                    if ((i + 1) < orderByFields.length) {
4490                                            if (orderByComparator.isAscending() ^ previous) {
4491                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4492                                            }
4493                                            else {
4494                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4495                                            }
4496                                    }
4497                                    else {
4498                                            if (orderByComparator.isAscending() ^ previous) {
4499                                                    query.append(ORDER_BY_ASC);
4500                                            }
4501                                            else {
4502                                                    query.append(ORDER_BY_DESC);
4503                                            }
4504                                    }
4505                            }
4506                    }
4507                    else {
4508                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4509                    }
4510    
4511                    String sql = query.toString();
4512    
4513                    Query q = session.createQuery(sql);
4514    
4515                    q.setFirstResult(0);
4516                    q.setMaxResults(2);
4517    
4518                    QueryPos qPos = QueryPos.getInstance(q);
4519    
4520                    qPos.add(groupId);
4521    
4522                    qPos.add(status);
4523    
4524                    if (orderByComparator != null) {
4525                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4526    
4527                            for (Object value : values) {
4528                                    qPos.add(value);
4529                            }
4530                    }
4531    
4532                    List<BlogsEntry> list = q.list();
4533    
4534                    if (list.size() == 2) {
4535                            return list.get(1);
4536                    }
4537                    else {
4538                            return null;
4539                    }
4540            }
4541    
4542            /**
4543             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4544             *
4545             * @param groupId the group ID
4546             * @param status the status
4547             * @return the matching blogs entries that the user has permission to view
4548             */
4549            @Override
4550            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4551                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4552                            QueryUtil.ALL_POS, null);
4553            }
4554    
4555            /**
4556             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4557             *
4558             * <p>
4559             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4560             * </p>
4561             *
4562             * @param groupId the group ID
4563             * @param status the status
4564             * @param start the lower bound of the range of blogs entries
4565             * @param end the upper bound of the range of blogs entries (not inclusive)
4566             * @return the range of matching blogs entries that the user has permission to view
4567             */
4568            @Override
4569            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4570                    int start, int end) {
4571                    return filterFindByG_S(groupId, status, start, end, null);
4572            }
4573    
4574            /**
4575             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4576             *
4577             * <p>
4578             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4579             * </p>
4580             *
4581             * @param groupId the group ID
4582             * @param status the status
4583             * @param start the lower bound of the range of blogs entries
4584             * @param end the upper bound of the range of blogs entries (not inclusive)
4585             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4586             * @return the ordered range of matching blogs entries that the user has permission to view
4587             */
4588            @Override
4589            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4590                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4591                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4592                            return findByG_S(groupId, status, start, end, orderByComparator);
4593                    }
4594    
4595                    StringBundler query = null;
4596    
4597                    if (orderByComparator != null) {
4598                            query = new StringBundler(4 +
4599                                            (orderByComparator.getOrderByFields().length * 3));
4600                    }
4601                    else {
4602                            query = new StringBundler(4);
4603                    }
4604    
4605                    if (getDB().isSupportsInlineDistinct()) {
4606                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4607                    }
4608                    else {
4609                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4610                    }
4611    
4612                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4613    
4614                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4615    
4616                    if (!getDB().isSupportsInlineDistinct()) {
4617                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4618                    }
4619    
4620                    if (orderByComparator != null) {
4621                            if (getDB().isSupportsInlineDistinct()) {
4622                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4623                                            orderByComparator, true);
4624                            }
4625                            else {
4626                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4627                                            orderByComparator, true);
4628                            }
4629                    }
4630                    else {
4631                            if (getDB().isSupportsInlineDistinct()) {
4632                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4633                            }
4634                            else {
4635                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4636                            }
4637                    }
4638    
4639                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4640                                    BlogsEntry.class.getName(),
4641                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4642    
4643                    Session session = null;
4644    
4645                    try {
4646                            session = openSession();
4647    
4648                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4649    
4650                            if (getDB().isSupportsInlineDistinct()) {
4651                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4652                            }
4653                            else {
4654                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4655                            }
4656    
4657                            QueryPos qPos = QueryPos.getInstance(q);
4658    
4659                            qPos.add(groupId);
4660    
4661                            qPos.add(status);
4662    
4663                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4664                    }
4665                    catch (Exception e) {
4666                            throw processException(e);
4667                    }
4668                    finally {
4669                            closeSession(session);
4670                    }
4671            }
4672    
4673            /**
4674             * 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;.
4675             *
4676             * @param entryId the primary key of the current blogs entry
4677             * @param groupId the group ID
4678             * @param status the status
4679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4680             * @return the previous, current, and next blogs entry
4681             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4682             */
4683            @Override
4684            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4685                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4686                    throws NoSuchEntryException {
4687                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4688                            return findByG_S_PrevAndNext(entryId, groupId, status,
4689                                    orderByComparator);
4690                    }
4691    
4692                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4693    
4694                    Session session = null;
4695    
4696                    try {
4697                            session = openSession();
4698    
4699                            BlogsEntry[] array = new BlogsEntryImpl[3];
4700    
4701                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4702                                            status, orderByComparator, true);
4703    
4704                            array[1] = blogsEntry;
4705    
4706                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4707                                            status, orderByComparator, false);
4708    
4709                            return array;
4710                    }
4711                    catch (Exception e) {
4712                            throw processException(e);
4713                    }
4714                    finally {
4715                            closeSession(session);
4716                    }
4717            }
4718    
4719            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4720                    BlogsEntry blogsEntry, long groupId, int status,
4721                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4722                    StringBundler query = null;
4723    
4724                    if (orderByComparator != null) {
4725                            query = new StringBundler(6 +
4726                                            (orderByComparator.getOrderByFields().length * 6));
4727                    }
4728                    else {
4729                            query = new StringBundler(3);
4730                    }
4731    
4732                    if (getDB().isSupportsInlineDistinct()) {
4733                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4734                    }
4735                    else {
4736                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4737                    }
4738    
4739                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4740    
4741                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4742    
4743                    if (!getDB().isSupportsInlineDistinct()) {
4744                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4745                    }
4746    
4747                    if (orderByComparator != null) {
4748                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4749    
4750                            if (orderByConditionFields.length > 0) {
4751                                    query.append(WHERE_AND);
4752                            }
4753    
4754                            for (int i = 0; i < orderByConditionFields.length; i++) {
4755                                    if (getDB().isSupportsInlineDistinct()) {
4756                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4757                                    }
4758                                    else {
4759                                            query.append(_ORDER_BY_ENTITY_TABLE);
4760                                    }
4761    
4762                                    query.append(orderByConditionFields[i]);
4763    
4764                                    if ((i + 1) < orderByConditionFields.length) {
4765                                            if (orderByComparator.isAscending() ^ previous) {
4766                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4767                                            }
4768                                            else {
4769                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4770                                            }
4771                                    }
4772                                    else {
4773                                            if (orderByComparator.isAscending() ^ previous) {
4774                                                    query.append(WHERE_GREATER_THAN);
4775                                            }
4776                                            else {
4777                                                    query.append(WHERE_LESSER_THAN);
4778                                            }
4779                                    }
4780                            }
4781    
4782                            query.append(ORDER_BY_CLAUSE);
4783    
4784                            String[] orderByFields = orderByComparator.getOrderByFields();
4785    
4786                            for (int i = 0; i < orderByFields.length; i++) {
4787                                    if (getDB().isSupportsInlineDistinct()) {
4788                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4789                                    }
4790                                    else {
4791                                            query.append(_ORDER_BY_ENTITY_TABLE);
4792                                    }
4793    
4794                                    query.append(orderByFields[i]);
4795    
4796                                    if ((i + 1) < orderByFields.length) {
4797                                            if (orderByComparator.isAscending() ^ previous) {
4798                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4799                                            }
4800                                            else {
4801                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4802                                            }
4803                                    }
4804                                    else {
4805                                            if (orderByComparator.isAscending() ^ previous) {
4806                                                    query.append(ORDER_BY_ASC);
4807                                            }
4808                                            else {
4809                                                    query.append(ORDER_BY_DESC);
4810                                            }
4811                                    }
4812                            }
4813                    }
4814                    else {
4815                            if (getDB().isSupportsInlineDistinct()) {
4816                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4817                            }
4818                            else {
4819                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4820                            }
4821                    }
4822    
4823                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4824                                    BlogsEntry.class.getName(),
4825                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4826    
4827                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4828    
4829                    q.setFirstResult(0);
4830                    q.setMaxResults(2);
4831    
4832                    if (getDB().isSupportsInlineDistinct()) {
4833                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4834                    }
4835                    else {
4836                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4837                    }
4838    
4839                    QueryPos qPos = QueryPos.getInstance(q);
4840    
4841                    qPos.add(groupId);
4842    
4843                    qPos.add(status);
4844    
4845                    if (orderByComparator != null) {
4846                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4847    
4848                            for (Object value : values) {
4849                                    qPos.add(value);
4850                            }
4851                    }
4852    
4853                    List<BlogsEntry> list = q.list();
4854    
4855                    if (list.size() == 2) {
4856                            return list.get(1);
4857                    }
4858                    else {
4859                            return null;
4860                    }
4861            }
4862    
4863            /**
4864             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4865             *
4866             * @param groupId the group ID
4867             * @param status the status
4868             */
4869            @Override
4870            public void removeByG_S(long groupId, int status) {
4871                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4872                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4873                            remove(blogsEntry);
4874                    }
4875            }
4876    
4877            /**
4878             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4879             *
4880             * @param groupId the group ID
4881             * @param status the status
4882             * @return the number of matching blogs entries
4883             */
4884            @Override
4885            public int countByG_S(long groupId, int status) {
4886                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4887    
4888                    Object[] finderArgs = new Object[] { groupId, status };
4889    
4890                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4891    
4892                    if (count == null) {
4893                            StringBundler query = new StringBundler(3);
4894    
4895                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4896    
4897                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4898    
4899                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4900    
4901                            String sql = query.toString();
4902    
4903                            Session session = null;
4904    
4905                            try {
4906                                    session = openSession();
4907    
4908                                    Query q = session.createQuery(sql);
4909    
4910                                    QueryPos qPos = QueryPos.getInstance(q);
4911    
4912                                    qPos.add(groupId);
4913    
4914                                    qPos.add(status);
4915    
4916                                    count = (Long)q.uniqueResult();
4917    
4918                                    finderCache.putResult(finderPath, finderArgs, count);
4919                            }
4920                            catch (Exception e) {
4921                                    finderCache.removeResult(finderPath, finderArgs);
4922    
4923                                    throw processException(e);
4924                            }
4925                            finally {
4926                                    closeSession(session);
4927                            }
4928                    }
4929    
4930                    return count.intValue();
4931            }
4932    
4933            /**
4934             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4935             *
4936             * @param groupId the group ID
4937             * @param status the status
4938             * @return the number of matching blogs entries that the user has permission to view
4939             */
4940            @Override
4941            public int filterCountByG_S(long groupId, int status) {
4942                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4943                            return countByG_S(groupId, status);
4944                    }
4945    
4946                    StringBundler query = new StringBundler(3);
4947    
4948                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4949    
4950                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4951    
4952                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4953    
4954                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4955                                    BlogsEntry.class.getName(),
4956                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4957    
4958                    Session session = null;
4959    
4960                    try {
4961                            session = openSession();
4962    
4963                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4964    
4965                            q.addScalar(COUNT_COLUMN_NAME,
4966                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4967    
4968                            QueryPos qPos = QueryPos.getInstance(q);
4969    
4970                            qPos.add(groupId);
4971    
4972                            qPos.add(status);
4973    
4974                            Long count = (Long)q.uniqueResult();
4975    
4976                            return count.intValue();
4977                    }
4978                    catch (Exception e) {
4979                            throw processException(e);
4980                    }
4981                    finally {
4982                            closeSession(session);
4983                    }
4984            }
4985    
4986            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4987            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
4988            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4989                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4990                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
4991                            new String[] {
4992                                    Long.class.getName(), Integer.class.getName(),
4993                                    
4994                            Integer.class.getName(), Integer.class.getName(),
4995                                    OrderByComparator.class.getName()
4996                            });
4997            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4998                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4999                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
5000                            new String[] { Long.class.getName(), Integer.class.getName() });
5001    
5002            /**
5003             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5004             *
5005             * @param groupId the group ID
5006             * @param status the status
5007             * @return the matching blogs entries
5008             */
5009            @Override
5010            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
5011                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
5012                            QueryUtil.ALL_POS, null);
5013            }
5014    
5015            /**
5016             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5017             *
5018             * <p>
5019             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5020             * </p>
5021             *
5022             * @param groupId the group ID
5023             * @param status the status
5024             * @param start the lower bound of the range of blogs entries
5025             * @param end the upper bound of the range of blogs entries (not inclusive)
5026             * @return the range of matching blogs entries
5027             */
5028            @Override
5029            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5030                    int end) {
5031                    return findByG_NotS(groupId, status, start, end, null);
5032            }
5033    
5034            /**
5035             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5036             *
5037             * <p>
5038             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5039             * </p>
5040             *
5041             * @param groupId the group ID
5042             * @param status the status
5043             * @param start the lower bound of the range of blogs entries
5044             * @param end the upper bound of the range of blogs entries (not inclusive)
5045             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5046             * @return the ordered range of matching blogs entries
5047             */
5048            @Override
5049            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5050                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5051                    return findByG_NotS(groupId, status, start, end, orderByComparator, true);
5052            }
5053    
5054            /**
5055             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5056             *
5057             * <p>
5058             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5059             * </p>
5060             *
5061             * @param groupId the group ID
5062             * @param status the status
5063             * @param start the lower bound of the range of blogs entries
5064             * @param end the upper bound of the range of blogs entries (not inclusive)
5065             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5066             * @param retrieveFromCache whether to retrieve from the finder cache
5067             * @return the ordered range of matching blogs entries
5068             */
5069            @Override
5070            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5071                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5072                    boolean retrieveFromCache) {
5073                    boolean pagination = true;
5074                    FinderPath finderPath = null;
5075                    Object[] finderArgs = null;
5076    
5077                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
5078                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
5079    
5080                    List<BlogsEntry> list = null;
5081    
5082                    if (retrieveFromCache) {
5083                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
5084                                            finderArgs, this);
5085    
5086                            if ((list != null) && !list.isEmpty()) {
5087                                    for (BlogsEntry blogsEntry : list) {
5088                                            if ((groupId != blogsEntry.getGroupId()) ||
5089                                                            (status == blogsEntry.getStatus())) {
5090                                                    list = null;
5091    
5092                                                    break;
5093                                            }
5094                                    }
5095                            }
5096                    }
5097    
5098                    if (list == null) {
5099                            StringBundler query = null;
5100    
5101                            if (orderByComparator != null) {
5102                                    query = new StringBundler(4 +
5103                                                    (orderByComparator.getOrderByFields().length * 3));
5104                            }
5105                            else {
5106                                    query = new StringBundler(4);
5107                            }
5108    
5109                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5110    
5111                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5112    
5113                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5114    
5115                            if (orderByComparator != null) {
5116                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5117                                            orderByComparator);
5118                            }
5119                            else
5120                             if (pagination) {
5121                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5122                            }
5123    
5124                            String sql = query.toString();
5125    
5126                            Session session = null;
5127    
5128                            try {
5129                                    session = openSession();
5130    
5131                                    Query q = session.createQuery(sql);
5132    
5133                                    QueryPos qPos = QueryPos.getInstance(q);
5134    
5135                                    qPos.add(groupId);
5136    
5137                                    qPos.add(status);
5138    
5139                                    if (!pagination) {
5140                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5141                                                            start, end, false);
5142    
5143                                            Collections.sort(list);
5144    
5145                                            list = Collections.unmodifiableList(list);
5146                                    }
5147                                    else {
5148                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5149                                                            start, end);
5150                                    }
5151    
5152                                    cacheResult(list);
5153    
5154                                    finderCache.putResult(finderPath, finderArgs, list);
5155                            }
5156                            catch (Exception e) {
5157                                    finderCache.removeResult(finderPath, finderArgs);
5158    
5159                                    throw processException(e);
5160                            }
5161                            finally {
5162                                    closeSession(session);
5163                            }
5164                    }
5165    
5166                    return list;
5167            }
5168    
5169            /**
5170             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5171             *
5172             * @param groupId the group ID
5173             * @param status the status
5174             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5175             * @return the first matching blogs entry
5176             * @throws NoSuchEntryException if a matching blogs entry could not be found
5177             */
5178            @Override
5179            public BlogsEntry findByG_NotS_First(long groupId, int status,
5180                    OrderByComparator<BlogsEntry> orderByComparator)
5181                    throws NoSuchEntryException {
5182                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5183                                    orderByComparator);
5184    
5185                    if (blogsEntry != null) {
5186                            return blogsEntry;
5187                    }
5188    
5189                    StringBundler msg = new StringBundler(6);
5190    
5191                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5192    
5193                    msg.append("groupId=");
5194                    msg.append(groupId);
5195    
5196                    msg.append(", status=");
5197                    msg.append(status);
5198    
5199                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5200    
5201                    throw new NoSuchEntryException(msg.toString());
5202            }
5203    
5204            /**
5205             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5206             *
5207             * @param groupId the group ID
5208             * @param status the status
5209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5210             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5211             */
5212            @Override
5213            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5214                    OrderByComparator<BlogsEntry> orderByComparator) {
5215                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5216                                    orderByComparator);
5217    
5218                    if (!list.isEmpty()) {
5219                            return list.get(0);
5220                    }
5221    
5222                    return null;
5223            }
5224    
5225            /**
5226             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5227             *
5228             * @param groupId the group ID
5229             * @param status the status
5230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5231             * @return the last matching blogs entry
5232             * @throws NoSuchEntryException if a matching blogs entry could not be found
5233             */
5234            @Override
5235            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5236                    OrderByComparator<BlogsEntry> orderByComparator)
5237                    throws NoSuchEntryException {
5238                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5239                                    orderByComparator);
5240    
5241                    if (blogsEntry != null) {
5242                            return blogsEntry;
5243                    }
5244    
5245                    StringBundler msg = new StringBundler(6);
5246    
5247                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5248    
5249                    msg.append("groupId=");
5250                    msg.append(groupId);
5251    
5252                    msg.append(", status=");
5253                    msg.append(status);
5254    
5255                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5256    
5257                    throw new NoSuchEntryException(msg.toString());
5258            }
5259    
5260            /**
5261             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5262             *
5263             * @param groupId the group ID
5264             * @param status the status
5265             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5266             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5267             */
5268            @Override
5269            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5270                    OrderByComparator<BlogsEntry> orderByComparator) {
5271                    int count = countByG_NotS(groupId, status);
5272    
5273                    if (count == 0) {
5274                            return null;
5275                    }
5276    
5277                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5278                                    orderByComparator);
5279    
5280                    if (!list.isEmpty()) {
5281                            return list.get(0);
5282                    }
5283    
5284                    return null;
5285            }
5286    
5287            /**
5288             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5289             *
5290             * @param entryId the primary key of the current blogs entry
5291             * @param groupId the group ID
5292             * @param status the status
5293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5294             * @return the previous, current, and next blogs entry
5295             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5296             */
5297            @Override
5298            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5299                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5300                    throws NoSuchEntryException {
5301                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5302    
5303                    Session session = null;
5304    
5305                    try {
5306                            session = openSession();
5307    
5308                            BlogsEntry[] array = new BlogsEntryImpl[3];
5309    
5310                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5311                                            status, orderByComparator, true);
5312    
5313                            array[1] = blogsEntry;
5314    
5315                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5316                                            status, orderByComparator, false);
5317    
5318                            return array;
5319                    }
5320                    catch (Exception e) {
5321                            throw processException(e);
5322                    }
5323                    finally {
5324                            closeSession(session);
5325                    }
5326            }
5327    
5328            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5329                    BlogsEntry blogsEntry, long groupId, int status,
5330                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5331                    StringBundler query = null;
5332    
5333                    if (orderByComparator != null) {
5334                            query = new StringBundler(6 +
5335                                            (orderByComparator.getOrderByFields().length * 6));
5336                    }
5337                    else {
5338                            query = new StringBundler(3);
5339                    }
5340    
5341                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5342    
5343                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5344    
5345                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5346    
5347                    if (orderByComparator != null) {
5348                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5349    
5350                            if (orderByConditionFields.length > 0) {
5351                                    query.append(WHERE_AND);
5352                            }
5353    
5354                            for (int i = 0; i < orderByConditionFields.length; i++) {
5355                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5356                                    query.append(orderByConditionFields[i]);
5357    
5358                                    if ((i + 1) < orderByConditionFields.length) {
5359                                            if (orderByComparator.isAscending() ^ previous) {
5360                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5361                                            }
5362                                            else {
5363                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5364                                            }
5365                                    }
5366                                    else {
5367                                            if (orderByComparator.isAscending() ^ previous) {
5368                                                    query.append(WHERE_GREATER_THAN);
5369                                            }
5370                                            else {
5371                                                    query.append(WHERE_LESSER_THAN);
5372                                            }
5373                                    }
5374                            }
5375    
5376                            query.append(ORDER_BY_CLAUSE);
5377    
5378                            String[] orderByFields = orderByComparator.getOrderByFields();
5379    
5380                            for (int i = 0; i < orderByFields.length; i++) {
5381                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5382                                    query.append(orderByFields[i]);
5383    
5384                                    if ((i + 1) < orderByFields.length) {
5385                                            if (orderByComparator.isAscending() ^ previous) {
5386                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5387                                            }
5388                                            else {
5389                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5390                                            }
5391                                    }
5392                                    else {
5393                                            if (orderByComparator.isAscending() ^ previous) {
5394                                                    query.append(ORDER_BY_ASC);
5395                                            }
5396                                            else {
5397                                                    query.append(ORDER_BY_DESC);
5398                                            }
5399                                    }
5400                            }
5401                    }
5402                    else {
5403                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5404                    }
5405    
5406                    String sql = query.toString();
5407    
5408                    Query q = session.createQuery(sql);
5409    
5410                    q.setFirstResult(0);
5411                    q.setMaxResults(2);
5412    
5413                    QueryPos qPos = QueryPos.getInstance(q);
5414    
5415                    qPos.add(groupId);
5416    
5417                    qPos.add(status);
5418    
5419                    if (orderByComparator != null) {
5420                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5421    
5422                            for (Object value : values) {
5423                                    qPos.add(value);
5424                            }
5425                    }
5426    
5427                    List<BlogsEntry> list = q.list();
5428    
5429                    if (list.size() == 2) {
5430                            return list.get(1);
5431                    }
5432                    else {
5433                            return null;
5434                    }
5435            }
5436    
5437            /**
5438             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5439             *
5440             * @param groupId the group ID
5441             * @param status the status
5442             * @return the matching blogs entries that the user has permission to view
5443             */
5444            @Override
5445            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5446                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5447                            QueryUtil.ALL_POS, null);
5448            }
5449    
5450            /**
5451             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5452             *
5453             * <p>
5454             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5455             * </p>
5456             *
5457             * @param groupId the group ID
5458             * @param status the status
5459             * @param start the lower bound of the range of blogs entries
5460             * @param end the upper bound of the range of blogs entries (not inclusive)
5461             * @return the range of matching blogs entries that the user has permission to view
5462             */
5463            @Override
5464            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5465                    int start, int end) {
5466                    return filterFindByG_NotS(groupId, status, start, end, null);
5467            }
5468    
5469            /**
5470             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5471             *
5472             * <p>
5473             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5474             * </p>
5475             *
5476             * @param groupId the group ID
5477             * @param status the status
5478             * @param start the lower bound of the range of blogs entries
5479             * @param end the upper bound of the range of blogs entries (not inclusive)
5480             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5481             * @return the ordered range of matching blogs entries that the user has permission to view
5482             */
5483            @Override
5484            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5485                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5486                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5487                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5488                    }
5489    
5490                    StringBundler query = null;
5491    
5492                    if (orderByComparator != null) {
5493                            query = new StringBundler(4 +
5494                                            (orderByComparator.getOrderByFields().length * 3));
5495                    }
5496                    else {
5497                            query = new StringBundler(4);
5498                    }
5499    
5500                    if (getDB().isSupportsInlineDistinct()) {
5501                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5502                    }
5503                    else {
5504                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5505                    }
5506    
5507                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5508    
5509                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5510    
5511                    if (!getDB().isSupportsInlineDistinct()) {
5512                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5513                    }
5514    
5515                    if (orderByComparator != null) {
5516                            if (getDB().isSupportsInlineDistinct()) {
5517                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5518                                            orderByComparator, true);
5519                            }
5520                            else {
5521                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5522                                            orderByComparator, true);
5523                            }
5524                    }
5525                    else {
5526                            if (getDB().isSupportsInlineDistinct()) {
5527                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5528                            }
5529                            else {
5530                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5531                            }
5532                    }
5533    
5534                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5535                                    BlogsEntry.class.getName(),
5536                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5537    
5538                    Session session = null;
5539    
5540                    try {
5541                            session = openSession();
5542    
5543                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5544    
5545                            if (getDB().isSupportsInlineDistinct()) {
5546                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5547                            }
5548                            else {
5549                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5550                            }
5551    
5552                            QueryPos qPos = QueryPos.getInstance(q);
5553    
5554                            qPos.add(groupId);
5555    
5556                            qPos.add(status);
5557    
5558                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5559                    }
5560                    catch (Exception e) {
5561                            throw processException(e);
5562                    }
5563                    finally {
5564                            closeSession(session);
5565                    }
5566            }
5567    
5568            /**
5569             * 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;.
5570             *
5571             * @param entryId the primary key of the current blogs entry
5572             * @param groupId the group ID
5573             * @param status the status
5574             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5575             * @return the previous, current, and next blogs entry
5576             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5577             */
5578            @Override
5579            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5580                    long groupId, int status,
5581                    OrderByComparator<BlogsEntry> orderByComparator)
5582                    throws NoSuchEntryException {
5583                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5584                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5585                                    orderByComparator);
5586                    }
5587    
5588                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5589    
5590                    Session session = null;
5591    
5592                    try {
5593                            session = openSession();
5594    
5595                            BlogsEntry[] array = new BlogsEntryImpl[3];
5596    
5597                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5598                                            groupId, status, orderByComparator, true);
5599    
5600                            array[1] = blogsEntry;
5601    
5602                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5603                                            groupId, status, orderByComparator, false);
5604    
5605                            return array;
5606                    }
5607                    catch (Exception e) {
5608                            throw processException(e);
5609                    }
5610                    finally {
5611                            closeSession(session);
5612                    }
5613            }
5614    
5615            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5616                    BlogsEntry blogsEntry, long groupId, int status,
5617                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5618                    StringBundler query = null;
5619    
5620                    if (orderByComparator != null) {
5621                            query = new StringBundler(6 +
5622                                            (orderByComparator.getOrderByFields().length * 6));
5623                    }
5624                    else {
5625                            query = new StringBundler(3);
5626                    }
5627    
5628                    if (getDB().isSupportsInlineDistinct()) {
5629                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5630                    }
5631                    else {
5632                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5633                    }
5634    
5635                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5636    
5637                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5638    
5639                    if (!getDB().isSupportsInlineDistinct()) {
5640                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5641                    }
5642    
5643                    if (orderByComparator != null) {
5644                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5645    
5646                            if (orderByConditionFields.length > 0) {
5647                                    query.append(WHERE_AND);
5648                            }
5649    
5650                            for (int i = 0; i < orderByConditionFields.length; i++) {
5651                                    if (getDB().isSupportsInlineDistinct()) {
5652                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5653                                    }
5654                                    else {
5655                                            query.append(_ORDER_BY_ENTITY_TABLE);
5656                                    }
5657    
5658                                    query.append(orderByConditionFields[i]);
5659    
5660                                    if ((i + 1) < orderByConditionFields.length) {
5661                                            if (orderByComparator.isAscending() ^ previous) {
5662                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5663                                            }
5664                                            else {
5665                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5666                                            }
5667                                    }
5668                                    else {
5669                                            if (orderByComparator.isAscending() ^ previous) {
5670                                                    query.append(WHERE_GREATER_THAN);
5671                                            }
5672                                            else {
5673                                                    query.append(WHERE_LESSER_THAN);
5674                                            }
5675                                    }
5676                            }
5677    
5678                            query.append(ORDER_BY_CLAUSE);
5679    
5680                            String[] orderByFields = orderByComparator.getOrderByFields();
5681    
5682                            for (int i = 0; i < orderByFields.length; i++) {
5683                                    if (getDB().isSupportsInlineDistinct()) {
5684                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5685                                    }
5686                                    else {
5687                                            query.append(_ORDER_BY_ENTITY_TABLE);
5688                                    }
5689    
5690                                    query.append(orderByFields[i]);
5691    
5692                                    if ((i + 1) < orderByFields.length) {
5693                                            if (orderByComparator.isAscending() ^ previous) {
5694                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5695                                            }
5696                                            else {
5697                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5698                                            }
5699                                    }
5700                                    else {
5701                                            if (orderByComparator.isAscending() ^ previous) {
5702                                                    query.append(ORDER_BY_ASC);
5703                                            }
5704                                            else {
5705                                                    query.append(ORDER_BY_DESC);
5706                                            }
5707                                    }
5708                            }
5709                    }
5710                    else {
5711                            if (getDB().isSupportsInlineDistinct()) {
5712                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5713                            }
5714                            else {
5715                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5716                            }
5717                    }
5718    
5719                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5720                                    BlogsEntry.class.getName(),
5721                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5722    
5723                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5724    
5725                    q.setFirstResult(0);
5726                    q.setMaxResults(2);
5727    
5728                    if (getDB().isSupportsInlineDistinct()) {
5729                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5730                    }
5731                    else {
5732                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5733                    }
5734    
5735                    QueryPos qPos = QueryPos.getInstance(q);
5736    
5737                    qPos.add(groupId);
5738    
5739                    qPos.add(status);
5740    
5741                    if (orderByComparator != null) {
5742                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5743    
5744                            for (Object value : values) {
5745                                    qPos.add(value);
5746                            }
5747                    }
5748    
5749                    List<BlogsEntry> list = q.list();
5750    
5751                    if (list.size() == 2) {
5752                            return list.get(1);
5753                    }
5754                    else {
5755                            return null;
5756                    }
5757            }
5758    
5759            /**
5760             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5761             *
5762             * @param groupId the group ID
5763             * @param status the status
5764             */
5765            @Override
5766            public void removeByG_NotS(long groupId, int status) {
5767                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5768                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5769                            remove(blogsEntry);
5770                    }
5771            }
5772    
5773            /**
5774             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5775             *
5776             * @param groupId the group ID
5777             * @param status the status
5778             * @return the number of matching blogs entries
5779             */
5780            @Override
5781            public int countByG_NotS(long groupId, int status) {
5782                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5783    
5784                    Object[] finderArgs = new Object[] { groupId, status };
5785    
5786                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5787    
5788                    if (count == null) {
5789                            StringBundler query = new StringBundler(3);
5790    
5791                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5792    
5793                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5794    
5795                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5796    
5797                            String sql = query.toString();
5798    
5799                            Session session = null;
5800    
5801                            try {
5802                                    session = openSession();
5803    
5804                                    Query q = session.createQuery(sql);
5805    
5806                                    QueryPos qPos = QueryPos.getInstance(q);
5807    
5808                                    qPos.add(groupId);
5809    
5810                                    qPos.add(status);
5811    
5812                                    count = (Long)q.uniqueResult();
5813    
5814                                    finderCache.putResult(finderPath, finderArgs, count);
5815                            }
5816                            catch (Exception e) {
5817                                    finderCache.removeResult(finderPath, finderArgs);
5818    
5819                                    throw processException(e);
5820                            }
5821                            finally {
5822                                    closeSession(session);
5823                            }
5824                    }
5825    
5826                    return count.intValue();
5827            }
5828    
5829            /**
5830             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5831             *
5832             * @param groupId the group ID
5833             * @param status the status
5834             * @return the number of matching blogs entries that the user has permission to view
5835             */
5836            @Override
5837            public int filterCountByG_NotS(long groupId, int status) {
5838                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5839                            return countByG_NotS(groupId, status);
5840                    }
5841    
5842                    StringBundler query = new StringBundler(3);
5843    
5844                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5845    
5846                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5847    
5848                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5849    
5850                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5851                                    BlogsEntry.class.getName(),
5852                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5853    
5854                    Session session = null;
5855    
5856                    try {
5857                            session = openSession();
5858    
5859                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5860    
5861                            q.addScalar(COUNT_COLUMN_NAME,
5862                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5863    
5864                            QueryPos qPos = QueryPos.getInstance(q);
5865    
5866                            qPos.add(groupId);
5867    
5868                            qPos.add(status);
5869    
5870                            Long count = (Long)q.uniqueResult();
5871    
5872                            return count.intValue();
5873                    }
5874                    catch (Exception e) {
5875                            throw processException(e);
5876                    }
5877                    finally {
5878                            closeSession(session);
5879                    }
5880            }
5881    
5882            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5883            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5884            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5885                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5886                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5887                            new String[] {
5888                                    Long.class.getName(), Long.class.getName(),
5889                                    
5890                            Integer.class.getName(), Integer.class.getName(),
5891                                    OrderByComparator.class.getName()
5892                            });
5893            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5894                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5895                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5896                            new String[] { Long.class.getName(), Long.class.getName() },
5897                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5898                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5899                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5900                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5901            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5902                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5903                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5904                            new String[] { Long.class.getName(), Long.class.getName() });
5905    
5906            /**
5907             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5908             *
5909             * @param companyId the company ID
5910             * @param userId the user ID
5911             * @return the matching blogs entries
5912             */
5913            @Override
5914            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5915                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5916                            QueryUtil.ALL_POS, null);
5917            }
5918    
5919            /**
5920             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5921             *
5922             * <p>
5923             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5924             * </p>
5925             *
5926             * @param companyId the company ID
5927             * @param userId the user ID
5928             * @param start the lower bound of the range of blogs entries
5929             * @param end the upper bound of the range of blogs entries (not inclusive)
5930             * @return the range of matching blogs entries
5931             */
5932            @Override
5933            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5934                    int end) {
5935                    return findByC_U(companyId, userId, start, end, null);
5936            }
5937    
5938            /**
5939             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5940             *
5941             * <p>
5942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5943             * </p>
5944             *
5945             * @param companyId the company ID
5946             * @param userId the user ID
5947             * @param start the lower bound of the range of blogs entries
5948             * @param end the upper bound of the range of blogs entries (not inclusive)
5949             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5950             * @return the ordered range of matching blogs entries
5951             */
5952            @Override
5953            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5954                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5955                    return findByC_U(companyId, userId, start, end, orderByComparator, true);
5956            }
5957    
5958            /**
5959             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5960             *
5961             * <p>
5962             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5963             * </p>
5964             *
5965             * @param companyId the company ID
5966             * @param userId the user ID
5967             * @param start the lower bound of the range of blogs entries
5968             * @param end the upper bound of the range of blogs entries (not inclusive)
5969             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5970             * @param retrieveFromCache whether to retrieve from the finder cache
5971             * @return the ordered range of matching blogs entries
5972             */
5973            @Override
5974            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5975                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5976                    boolean retrieveFromCache) {
5977                    boolean pagination = true;
5978                    FinderPath finderPath = null;
5979                    Object[] finderArgs = null;
5980    
5981                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5982                                    (orderByComparator == null)) {
5983                            pagination = false;
5984                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
5985                            finderArgs = new Object[] { companyId, userId };
5986                    }
5987                    else {
5988                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
5989                            finderArgs = new Object[] {
5990                                            companyId, userId,
5991                                            
5992                                            start, end, orderByComparator
5993                                    };
5994                    }
5995    
5996                    List<BlogsEntry> list = null;
5997    
5998                    if (retrieveFromCache) {
5999                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6000                                            finderArgs, this);
6001    
6002                            if ((list != null) && !list.isEmpty()) {
6003                                    for (BlogsEntry blogsEntry : list) {
6004                                            if ((companyId != blogsEntry.getCompanyId()) ||
6005                                                            (userId != blogsEntry.getUserId())) {
6006                                                    list = null;
6007    
6008                                                    break;
6009                                            }
6010                                    }
6011                            }
6012                    }
6013    
6014                    if (list == null) {
6015                            StringBundler query = null;
6016    
6017                            if (orderByComparator != null) {
6018                                    query = new StringBundler(4 +
6019                                                    (orderByComparator.getOrderByFields().length * 3));
6020                            }
6021                            else {
6022                                    query = new StringBundler(4);
6023                            }
6024    
6025                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6026    
6027                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6028    
6029                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6030    
6031                            if (orderByComparator != null) {
6032                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6033                                            orderByComparator);
6034                            }
6035                            else
6036                             if (pagination) {
6037                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6038                            }
6039    
6040                            String sql = query.toString();
6041    
6042                            Session session = null;
6043    
6044                            try {
6045                                    session = openSession();
6046    
6047                                    Query q = session.createQuery(sql);
6048    
6049                                    QueryPos qPos = QueryPos.getInstance(q);
6050    
6051                                    qPos.add(companyId);
6052    
6053                                    qPos.add(userId);
6054    
6055                                    if (!pagination) {
6056                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6057                                                            start, end, false);
6058    
6059                                            Collections.sort(list);
6060    
6061                                            list = Collections.unmodifiableList(list);
6062                                    }
6063                                    else {
6064                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6065                                                            start, end);
6066                                    }
6067    
6068                                    cacheResult(list);
6069    
6070                                    finderCache.putResult(finderPath, finderArgs, list);
6071                            }
6072                            catch (Exception e) {
6073                                    finderCache.removeResult(finderPath, finderArgs);
6074    
6075                                    throw processException(e);
6076                            }
6077                            finally {
6078                                    closeSession(session);
6079                            }
6080                    }
6081    
6082                    return list;
6083            }
6084    
6085            /**
6086             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6087             *
6088             * @param companyId the company ID
6089             * @param userId the user ID
6090             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6091             * @return the first matching blogs entry
6092             * @throws NoSuchEntryException if a matching blogs entry could not be found
6093             */
6094            @Override
6095            public BlogsEntry findByC_U_First(long companyId, long userId,
6096                    OrderByComparator<BlogsEntry> orderByComparator)
6097                    throws NoSuchEntryException {
6098                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
6099                                    orderByComparator);
6100    
6101                    if (blogsEntry != null) {
6102                            return blogsEntry;
6103                    }
6104    
6105                    StringBundler msg = new StringBundler(6);
6106    
6107                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6108    
6109                    msg.append("companyId=");
6110                    msg.append(companyId);
6111    
6112                    msg.append(", userId=");
6113                    msg.append(userId);
6114    
6115                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6116    
6117                    throw new NoSuchEntryException(msg.toString());
6118            }
6119    
6120            /**
6121             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6122             *
6123             * @param companyId the company ID
6124             * @param userId the user ID
6125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6126             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6127             */
6128            @Override
6129            public BlogsEntry fetchByC_U_First(long companyId, long userId,
6130                    OrderByComparator<BlogsEntry> orderByComparator) {
6131                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
6132                                    orderByComparator);
6133    
6134                    if (!list.isEmpty()) {
6135                            return list.get(0);
6136                    }
6137    
6138                    return null;
6139            }
6140    
6141            /**
6142             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6143             *
6144             * @param companyId the company ID
6145             * @param userId the user ID
6146             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6147             * @return the last matching blogs entry
6148             * @throws NoSuchEntryException if a matching blogs entry could not be found
6149             */
6150            @Override
6151            public BlogsEntry findByC_U_Last(long companyId, long userId,
6152                    OrderByComparator<BlogsEntry> orderByComparator)
6153                    throws NoSuchEntryException {
6154                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
6155                                    orderByComparator);
6156    
6157                    if (blogsEntry != null) {
6158                            return blogsEntry;
6159                    }
6160    
6161                    StringBundler msg = new StringBundler(6);
6162    
6163                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6164    
6165                    msg.append("companyId=");
6166                    msg.append(companyId);
6167    
6168                    msg.append(", userId=");
6169                    msg.append(userId);
6170    
6171                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6172    
6173                    throw new NoSuchEntryException(msg.toString());
6174            }
6175    
6176            /**
6177             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6178             *
6179             * @param companyId the company ID
6180             * @param userId the user ID
6181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6182             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6183             */
6184            @Override
6185            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
6186                    OrderByComparator<BlogsEntry> orderByComparator) {
6187                    int count = countByC_U(companyId, userId);
6188    
6189                    if (count == 0) {
6190                            return null;
6191                    }
6192    
6193                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
6194                                    orderByComparator);
6195    
6196                    if (!list.isEmpty()) {
6197                            return list.get(0);
6198                    }
6199    
6200                    return null;
6201            }
6202    
6203            /**
6204             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6205             *
6206             * @param entryId the primary key of the current blogs entry
6207             * @param companyId the company ID
6208             * @param userId the user ID
6209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6210             * @return the previous, current, and next blogs entry
6211             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6212             */
6213            @Override
6214            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6215                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6216                    throws NoSuchEntryException {
6217                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6218    
6219                    Session session = null;
6220    
6221                    try {
6222                            session = openSession();
6223    
6224                            BlogsEntry[] array = new BlogsEntryImpl[3];
6225    
6226                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6227                                            userId, orderByComparator, true);
6228    
6229                            array[1] = blogsEntry;
6230    
6231                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6232                                            userId, orderByComparator, false);
6233    
6234                            return array;
6235                    }
6236                    catch (Exception e) {
6237                            throw processException(e);
6238                    }
6239                    finally {
6240                            closeSession(session);
6241                    }
6242            }
6243    
6244            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6245                    BlogsEntry blogsEntry, long companyId, long userId,
6246                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6247                    StringBundler query = null;
6248    
6249                    if (orderByComparator != null) {
6250                            query = new StringBundler(6 +
6251                                            (orderByComparator.getOrderByFields().length * 6));
6252                    }
6253                    else {
6254                            query = new StringBundler(3);
6255                    }
6256    
6257                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6258    
6259                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6260    
6261                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6262    
6263                    if (orderByComparator != null) {
6264                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6265    
6266                            if (orderByConditionFields.length > 0) {
6267                                    query.append(WHERE_AND);
6268                            }
6269    
6270                            for (int i = 0; i < orderByConditionFields.length; i++) {
6271                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6272                                    query.append(orderByConditionFields[i]);
6273    
6274                                    if ((i + 1) < orderByConditionFields.length) {
6275                                            if (orderByComparator.isAscending() ^ previous) {
6276                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6277                                            }
6278                                            else {
6279                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6280                                            }
6281                                    }
6282                                    else {
6283                                            if (orderByComparator.isAscending() ^ previous) {
6284                                                    query.append(WHERE_GREATER_THAN);
6285                                            }
6286                                            else {
6287                                                    query.append(WHERE_LESSER_THAN);
6288                                            }
6289                                    }
6290                            }
6291    
6292                            query.append(ORDER_BY_CLAUSE);
6293    
6294                            String[] orderByFields = orderByComparator.getOrderByFields();
6295    
6296                            for (int i = 0; i < orderByFields.length; i++) {
6297                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6298                                    query.append(orderByFields[i]);
6299    
6300                                    if ((i + 1) < orderByFields.length) {
6301                                            if (orderByComparator.isAscending() ^ previous) {
6302                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6303                                            }
6304                                            else {
6305                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6306                                            }
6307                                    }
6308                                    else {
6309                                            if (orderByComparator.isAscending() ^ previous) {
6310                                                    query.append(ORDER_BY_ASC);
6311                                            }
6312                                            else {
6313                                                    query.append(ORDER_BY_DESC);
6314                                            }
6315                                    }
6316                            }
6317                    }
6318                    else {
6319                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6320                    }
6321    
6322                    String sql = query.toString();
6323    
6324                    Query q = session.createQuery(sql);
6325    
6326                    q.setFirstResult(0);
6327                    q.setMaxResults(2);
6328    
6329                    QueryPos qPos = QueryPos.getInstance(q);
6330    
6331                    qPos.add(companyId);
6332    
6333                    qPos.add(userId);
6334    
6335                    if (orderByComparator != null) {
6336                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6337    
6338                            for (Object value : values) {
6339                                    qPos.add(value);
6340                            }
6341                    }
6342    
6343                    List<BlogsEntry> list = q.list();
6344    
6345                    if (list.size() == 2) {
6346                            return list.get(1);
6347                    }
6348                    else {
6349                            return null;
6350                    }
6351            }
6352    
6353            /**
6354             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6355             *
6356             * @param companyId the company ID
6357             * @param userId the user ID
6358             */
6359            @Override
6360            public void removeByC_U(long companyId, long userId) {
6361                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6362                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6363                            remove(blogsEntry);
6364                    }
6365            }
6366    
6367            /**
6368             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6369             *
6370             * @param companyId the company ID
6371             * @param userId the user ID
6372             * @return the number of matching blogs entries
6373             */
6374            @Override
6375            public int countByC_U(long companyId, long userId) {
6376                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6377    
6378                    Object[] finderArgs = new Object[] { companyId, userId };
6379    
6380                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6381    
6382                    if (count == null) {
6383                            StringBundler query = new StringBundler(3);
6384    
6385                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6386    
6387                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6388    
6389                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6390    
6391                            String sql = query.toString();
6392    
6393                            Session session = null;
6394    
6395                            try {
6396                                    session = openSession();
6397    
6398                                    Query q = session.createQuery(sql);
6399    
6400                                    QueryPos qPos = QueryPos.getInstance(q);
6401    
6402                                    qPos.add(companyId);
6403    
6404                                    qPos.add(userId);
6405    
6406                                    count = (Long)q.uniqueResult();
6407    
6408                                    finderCache.putResult(finderPath, finderArgs, count);
6409                            }
6410                            catch (Exception e) {
6411                                    finderCache.removeResult(finderPath, finderArgs);
6412    
6413                                    throw processException(e);
6414                            }
6415                            finally {
6416                                    closeSession(session);
6417                            }
6418                    }
6419    
6420                    return count.intValue();
6421            }
6422    
6423            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6424            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6425            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6426                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6427                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6428                            new String[] {
6429                                    Long.class.getName(), Date.class.getName(),
6430                                    
6431                            Integer.class.getName(), Integer.class.getName(),
6432                                    OrderByComparator.class.getName()
6433                            });
6434            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6435                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6436                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6437                            new String[] { Long.class.getName(), Date.class.getName() });
6438    
6439            /**
6440             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6441             *
6442             * @param companyId the company ID
6443             * @param displayDate the display date
6444             * @return the matching blogs entries
6445             */
6446            @Override
6447            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6448                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6449                            QueryUtil.ALL_POS, null);
6450            }
6451    
6452            /**
6453             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6454             *
6455             * <p>
6456             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6457             * </p>
6458             *
6459             * @param companyId the company ID
6460             * @param displayDate the display date
6461             * @param start the lower bound of the range of blogs entries
6462             * @param end the upper bound of the range of blogs entries (not inclusive)
6463             * @return the range of matching blogs entries
6464             */
6465            @Override
6466            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6467                    int start, int end) {
6468                    return findByC_LtD(companyId, displayDate, start, end, null);
6469            }
6470    
6471            /**
6472             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6473             *
6474             * <p>
6475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6476             * </p>
6477             *
6478             * @param companyId the company ID
6479             * @param displayDate the display date
6480             * @param start the lower bound of the range of blogs entries
6481             * @param end the upper bound of the range of blogs entries (not inclusive)
6482             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6483             * @return the ordered range of matching blogs entries
6484             */
6485            @Override
6486            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6487                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6488                    return findByC_LtD(companyId, displayDate, start, end,
6489                            orderByComparator, true);
6490            }
6491    
6492            /**
6493             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6494             *
6495             * <p>
6496             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6497             * </p>
6498             *
6499             * @param companyId the company ID
6500             * @param displayDate the display date
6501             * @param start the lower bound of the range of blogs entries
6502             * @param end the upper bound of the range of blogs entries (not inclusive)
6503             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6504             * @param retrieveFromCache whether to retrieve from the finder cache
6505             * @return the ordered range of matching blogs entries
6506             */
6507            @Override
6508            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6509                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
6510                    boolean retrieveFromCache) {
6511                    boolean pagination = true;
6512                    FinderPath finderPath = null;
6513                    Object[] finderArgs = null;
6514    
6515                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6516                    finderArgs = new Object[] {
6517                                    companyId, displayDate,
6518                                    
6519                                    start, end, orderByComparator
6520                            };
6521    
6522                    List<BlogsEntry> list = null;
6523    
6524                    if (retrieveFromCache) {
6525                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6526                                            finderArgs, this);
6527    
6528                            if ((list != null) && !list.isEmpty()) {
6529                                    for (BlogsEntry blogsEntry : list) {
6530                                            if ((companyId != blogsEntry.getCompanyId()) ||
6531                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
6532                                                                                                                                            .getTime())) {
6533                                                    list = null;
6534    
6535                                                    break;
6536                                            }
6537                                    }
6538                            }
6539                    }
6540    
6541                    if (list == null) {
6542                            StringBundler query = null;
6543    
6544                            if (orderByComparator != null) {
6545                                    query = new StringBundler(4 +
6546                                                    (orderByComparator.getOrderByFields().length * 3));
6547                            }
6548                            else {
6549                                    query = new StringBundler(4);
6550                            }
6551    
6552                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6553    
6554                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6555    
6556                            boolean bindDisplayDate = false;
6557    
6558                            if (displayDate == null) {
6559                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6560                            }
6561                            else {
6562                                    bindDisplayDate = true;
6563    
6564                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6565                            }
6566    
6567                            if (orderByComparator != null) {
6568                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6569                                            orderByComparator);
6570                            }
6571                            else
6572                             if (pagination) {
6573                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6574                            }
6575    
6576                            String sql = query.toString();
6577    
6578                            Session session = null;
6579    
6580                            try {
6581                                    session = openSession();
6582    
6583                                    Query q = session.createQuery(sql);
6584    
6585                                    QueryPos qPos = QueryPos.getInstance(q);
6586    
6587                                    qPos.add(companyId);
6588    
6589                                    if (bindDisplayDate) {
6590                                            qPos.add(new Timestamp(displayDate.getTime()));
6591                                    }
6592    
6593                                    if (!pagination) {
6594                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6595                                                            start, end, false);
6596    
6597                                            Collections.sort(list);
6598    
6599                                            list = Collections.unmodifiableList(list);
6600                                    }
6601                                    else {
6602                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6603                                                            start, end);
6604                                    }
6605    
6606                                    cacheResult(list);
6607    
6608                                    finderCache.putResult(finderPath, finderArgs, list);
6609                            }
6610                            catch (Exception e) {
6611                                    finderCache.removeResult(finderPath, finderArgs);
6612    
6613                                    throw processException(e);
6614                            }
6615                            finally {
6616                                    closeSession(session);
6617                            }
6618                    }
6619    
6620                    return list;
6621            }
6622    
6623            /**
6624             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6625             *
6626             * @param companyId the company ID
6627             * @param displayDate the display date
6628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6629             * @return the first matching blogs entry
6630             * @throws NoSuchEntryException if a matching blogs entry could not be found
6631             */
6632            @Override
6633            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6634                    OrderByComparator<BlogsEntry> orderByComparator)
6635                    throws NoSuchEntryException {
6636                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6637                                    orderByComparator);
6638    
6639                    if (blogsEntry != null) {
6640                            return blogsEntry;
6641                    }
6642    
6643                    StringBundler msg = new StringBundler(6);
6644    
6645                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6646    
6647                    msg.append("companyId=");
6648                    msg.append(companyId);
6649    
6650                    msg.append(", displayDate=");
6651                    msg.append(displayDate);
6652    
6653                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6654    
6655                    throw new NoSuchEntryException(msg.toString());
6656            }
6657    
6658            /**
6659             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6660             *
6661             * @param companyId the company ID
6662             * @param displayDate the display date
6663             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6664             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6665             */
6666            @Override
6667            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6668                    OrderByComparator<BlogsEntry> orderByComparator) {
6669                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6670                                    orderByComparator);
6671    
6672                    if (!list.isEmpty()) {
6673                            return list.get(0);
6674                    }
6675    
6676                    return null;
6677            }
6678    
6679            /**
6680             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6681             *
6682             * @param companyId the company ID
6683             * @param displayDate the display date
6684             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6685             * @return the last matching blogs entry
6686             * @throws NoSuchEntryException if a matching blogs entry could not be found
6687             */
6688            @Override
6689            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6690                    OrderByComparator<BlogsEntry> orderByComparator)
6691                    throws NoSuchEntryException {
6692                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6693                                    orderByComparator);
6694    
6695                    if (blogsEntry != null) {
6696                            return blogsEntry;
6697                    }
6698    
6699                    StringBundler msg = new StringBundler(6);
6700    
6701                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6702    
6703                    msg.append("companyId=");
6704                    msg.append(companyId);
6705    
6706                    msg.append(", displayDate=");
6707                    msg.append(displayDate);
6708    
6709                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6710    
6711                    throw new NoSuchEntryException(msg.toString());
6712            }
6713    
6714            /**
6715             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6716             *
6717             * @param companyId the company ID
6718             * @param displayDate the display date
6719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6720             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6721             */
6722            @Override
6723            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6724                    OrderByComparator<BlogsEntry> orderByComparator) {
6725                    int count = countByC_LtD(companyId, displayDate);
6726    
6727                    if (count == 0) {
6728                            return null;
6729                    }
6730    
6731                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6732                                    count, orderByComparator);
6733    
6734                    if (!list.isEmpty()) {
6735                            return list.get(0);
6736                    }
6737    
6738                    return null;
6739            }
6740    
6741            /**
6742             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6743             *
6744             * @param entryId the primary key of the current blogs entry
6745             * @param companyId the company ID
6746             * @param displayDate the display date
6747             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6748             * @return the previous, current, and next blogs entry
6749             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6750             */
6751            @Override
6752            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6753                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6754                    throws NoSuchEntryException {
6755                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6756    
6757                    Session session = null;
6758    
6759                    try {
6760                            session = openSession();
6761    
6762                            BlogsEntry[] array = new BlogsEntryImpl[3];
6763    
6764                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6765                                            displayDate, orderByComparator, true);
6766    
6767                            array[1] = blogsEntry;
6768    
6769                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6770                                            displayDate, orderByComparator, false);
6771    
6772                            return array;
6773                    }
6774                    catch (Exception e) {
6775                            throw processException(e);
6776                    }
6777                    finally {
6778                            closeSession(session);
6779                    }
6780            }
6781    
6782            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6783                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6784                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6785                    StringBundler query = null;
6786    
6787                    if (orderByComparator != null) {
6788                            query = new StringBundler(6 +
6789                                            (orderByComparator.getOrderByFields().length * 6));
6790                    }
6791                    else {
6792                            query = new StringBundler(3);
6793                    }
6794    
6795                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6796    
6797                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6798    
6799                    boolean bindDisplayDate = false;
6800    
6801                    if (displayDate == null) {
6802                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6803                    }
6804                    else {
6805                            bindDisplayDate = true;
6806    
6807                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6808                    }
6809    
6810                    if (orderByComparator != null) {
6811                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6812    
6813                            if (orderByConditionFields.length > 0) {
6814                                    query.append(WHERE_AND);
6815                            }
6816    
6817                            for (int i = 0; i < orderByConditionFields.length; i++) {
6818                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6819                                    query.append(orderByConditionFields[i]);
6820    
6821                                    if ((i + 1) < orderByConditionFields.length) {
6822                                            if (orderByComparator.isAscending() ^ previous) {
6823                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6824                                            }
6825                                            else {
6826                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6827                                            }
6828                                    }
6829                                    else {
6830                                            if (orderByComparator.isAscending() ^ previous) {
6831                                                    query.append(WHERE_GREATER_THAN);
6832                                            }
6833                                            else {
6834                                                    query.append(WHERE_LESSER_THAN);
6835                                            }
6836                                    }
6837                            }
6838    
6839                            query.append(ORDER_BY_CLAUSE);
6840    
6841                            String[] orderByFields = orderByComparator.getOrderByFields();
6842    
6843                            for (int i = 0; i < orderByFields.length; i++) {
6844                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6845                                    query.append(orderByFields[i]);
6846    
6847                                    if ((i + 1) < orderByFields.length) {
6848                                            if (orderByComparator.isAscending() ^ previous) {
6849                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6850                                            }
6851                                            else {
6852                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6853                                            }
6854                                    }
6855                                    else {
6856                                            if (orderByComparator.isAscending() ^ previous) {
6857                                                    query.append(ORDER_BY_ASC);
6858                                            }
6859                                            else {
6860                                                    query.append(ORDER_BY_DESC);
6861                                            }
6862                                    }
6863                            }
6864                    }
6865                    else {
6866                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6867                    }
6868    
6869                    String sql = query.toString();
6870    
6871                    Query q = session.createQuery(sql);
6872    
6873                    q.setFirstResult(0);
6874                    q.setMaxResults(2);
6875    
6876                    QueryPos qPos = QueryPos.getInstance(q);
6877    
6878                    qPos.add(companyId);
6879    
6880                    if (bindDisplayDate) {
6881                            qPos.add(new Timestamp(displayDate.getTime()));
6882                    }
6883    
6884                    if (orderByComparator != null) {
6885                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6886    
6887                            for (Object value : values) {
6888                                    qPos.add(value);
6889                            }
6890                    }
6891    
6892                    List<BlogsEntry> list = q.list();
6893    
6894                    if (list.size() == 2) {
6895                            return list.get(1);
6896                    }
6897                    else {
6898                            return null;
6899                    }
6900            }
6901    
6902            /**
6903             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6904             *
6905             * @param companyId the company ID
6906             * @param displayDate the display date
6907             */
6908            @Override
6909            public void removeByC_LtD(long companyId, Date displayDate) {
6910                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6911                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6912                            remove(blogsEntry);
6913                    }
6914            }
6915    
6916            /**
6917             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6918             *
6919             * @param companyId the company ID
6920             * @param displayDate the display date
6921             * @return the number of matching blogs entries
6922             */
6923            @Override
6924            public int countByC_LtD(long companyId, Date displayDate) {
6925                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6926    
6927                    Object[] finderArgs = new Object[] { companyId, displayDate };
6928    
6929                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6930    
6931                    if (count == null) {
6932                            StringBundler query = new StringBundler(3);
6933    
6934                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6935    
6936                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6937    
6938                            boolean bindDisplayDate = false;
6939    
6940                            if (displayDate == null) {
6941                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6942                            }
6943                            else {
6944                                    bindDisplayDate = true;
6945    
6946                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6947                            }
6948    
6949                            String sql = query.toString();
6950    
6951                            Session session = null;
6952    
6953                            try {
6954                                    session = openSession();
6955    
6956                                    Query q = session.createQuery(sql);
6957    
6958                                    QueryPos qPos = QueryPos.getInstance(q);
6959    
6960                                    qPos.add(companyId);
6961    
6962                                    if (bindDisplayDate) {
6963                                            qPos.add(new Timestamp(displayDate.getTime()));
6964                                    }
6965    
6966                                    count = (Long)q.uniqueResult();
6967    
6968                                    finderCache.putResult(finderPath, finderArgs, count);
6969                            }
6970                            catch (Exception e) {
6971                                    finderCache.removeResult(finderPath, finderArgs);
6972    
6973                                    throw processException(e);
6974                            }
6975                            finally {
6976                                    closeSession(session);
6977                            }
6978                    }
6979    
6980                    return count.intValue();
6981            }
6982    
6983            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6984            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
6985            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
6986            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6987                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6988                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
6989                            new String[] {
6990                                    Long.class.getName(), Integer.class.getName(),
6991                                    
6992                            Integer.class.getName(), Integer.class.getName(),
6993                                    OrderByComparator.class.getName()
6994                            });
6995            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6996                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6997                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
6998                            new String[] { Long.class.getName(), Integer.class.getName() },
6999                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
7000                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
7001                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
7002                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
7003            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7004                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7005                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
7006                            new String[] { Long.class.getName(), Integer.class.getName() });
7007    
7008            /**
7009             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
7010             *
7011             * @param companyId the company ID
7012             * @param status the status
7013             * @return the matching blogs entries
7014             */
7015            @Override
7016            public List<BlogsEntry> findByC_S(long companyId, int status) {
7017                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
7018                            QueryUtil.ALL_POS, null);
7019            }
7020    
7021            /**
7022             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
7023             *
7024             * <p>
7025             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7026             * </p>
7027             *
7028             * @param companyId the company ID
7029             * @param status the status
7030             * @param start the lower bound of the range of blogs entries
7031             * @param end the upper bound of the range of blogs entries (not inclusive)
7032             * @return the range of matching blogs entries
7033             */
7034            @Override
7035            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7036                    int end) {
7037                    return findByC_S(companyId, status, start, end, null);
7038            }
7039    
7040            /**
7041             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7042             *
7043             * <p>
7044             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7045             * </p>
7046             *
7047             * @param companyId the company ID
7048             * @param status the status
7049             * @param start the lower bound of the range of blogs entries
7050             * @param end the upper bound of the range of blogs entries (not inclusive)
7051             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7052             * @return the ordered range of matching blogs entries
7053             */
7054            @Override
7055            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7056                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7057                    return findByC_S(companyId, status, start, end, orderByComparator, true);
7058            }
7059    
7060            /**
7061             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7062             *
7063             * <p>
7064             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7065             * </p>
7066             *
7067             * @param companyId the company ID
7068             * @param status the status
7069             * @param start the lower bound of the range of blogs entries
7070             * @param end the upper bound of the range of blogs entries (not inclusive)
7071             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7072             * @param retrieveFromCache whether to retrieve from the finder cache
7073             * @return the ordered range of matching blogs entries
7074             */
7075            @Override
7076            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7077                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7078                    boolean retrieveFromCache) {
7079                    boolean pagination = true;
7080                    FinderPath finderPath = null;
7081                    Object[] finderArgs = null;
7082    
7083                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7084                                    (orderByComparator == null)) {
7085                            pagination = false;
7086                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
7087                            finderArgs = new Object[] { companyId, status };
7088                    }
7089                    else {
7090                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
7091                            finderArgs = new Object[] {
7092                                            companyId, status,
7093                                            
7094                                            start, end, orderByComparator
7095                                    };
7096                    }
7097    
7098                    List<BlogsEntry> list = null;
7099    
7100                    if (retrieveFromCache) {
7101                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7102                                            finderArgs, this);
7103    
7104                            if ((list != null) && !list.isEmpty()) {
7105                                    for (BlogsEntry blogsEntry : list) {
7106                                            if ((companyId != blogsEntry.getCompanyId()) ||
7107                                                            (status != blogsEntry.getStatus())) {
7108                                                    list = null;
7109    
7110                                                    break;
7111                                            }
7112                                    }
7113                            }
7114                    }
7115    
7116                    if (list == null) {
7117                            StringBundler query = null;
7118    
7119                            if (orderByComparator != null) {
7120                                    query = new StringBundler(4 +
7121                                                    (orderByComparator.getOrderByFields().length * 3));
7122                            }
7123                            else {
7124                                    query = new StringBundler(4);
7125                            }
7126    
7127                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7128    
7129                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7130    
7131                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7132    
7133                            if (orderByComparator != null) {
7134                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7135                                            orderByComparator);
7136                            }
7137                            else
7138                             if (pagination) {
7139                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7140                            }
7141    
7142                            String sql = query.toString();
7143    
7144                            Session session = null;
7145    
7146                            try {
7147                                    session = openSession();
7148    
7149                                    Query q = session.createQuery(sql);
7150    
7151                                    QueryPos qPos = QueryPos.getInstance(q);
7152    
7153                                    qPos.add(companyId);
7154    
7155                                    qPos.add(status);
7156    
7157                                    if (!pagination) {
7158                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7159                                                            start, end, false);
7160    
7161                                            Collections.sort(list);
7162    
7163                                            list = Collections.unmodifiableList(list);
7164                                    }
7165                                    else {
7166                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7167                                                            start, end);
7168                                    }
7169    
7170                                    cacheResult(list);
7171    
7172                                    finderCache.putResult(finderPath, finderArgs, list);
7173                            }
7174                            catch (Exception e) {
7175                                    finderCache.removeResult(finderPath, finderArgs);
7176    
7177                                    throw processException(e);
7178                            }
7179                            finally {
7180                                    closeSession(session);
7181                            }
7182                    }
7183    
7184                    return list;
7185            }
7186    
7187            /**
7188             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7189             *
7190             * @param companyId the company ID
7191             * @param status the status
7192             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7193             * @return the first matching blogs entry
7194             * @throws NoSuchEntryException if a matching blogs entry could not be found
7195             */
7196            @Override
7197            public BlogsEntry findByC_S_First(long companyId, int status,
7198                    OrderByComparator<BlogsEntry> orderByComparator)
7199                    throws NoSuchEntryException {
7200                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
7201                                    orderByComparator);
7202    
7203                    if (blogsEntry != null) {
7204                            return blogsEntry;
7205                    }
7206    
7207                    StringBundler msg = new StringBundler(6);
7208    
7209                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7210    
7211                    msg.append("companyId=");
7212                    msg.append(companyId);
7213    
7214                    msg.append(", status=");
7215                    msg.append(status);
7216    
7217                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7218    
7219                    throw new NoSuchEntryException(msg.toString());
7220            }
7221    
7222            /**
7223             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7224             *
7225             * @param companyId the company ID
7226             * @param status the status
7227             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7228             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7229             */
7230            @Override
7231            public BlogsEntry fetchByC_S_First(long companyId, int status,
7232                    OrderByComparator<BlogsEntry> orderByComparator) {
7233                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
7234                                    orderByComparator);
7235    
7236                    if (!list.isEmpty()) {
7237                            return list.get(0);
7238                    }
7239    
7240                    return null;
7241            }
7242    
7243            /**
7244             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7245             *
7246             * @param companyId the company ID
7247             * @param status the status
7248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7249             * @return the last matching blogs entry
7250             * @throws NoSuchEntryException if a matching blogs entry could not be found
7251             */
7252            @Override
7253            public BlogsEntry findByC_S_Last(long companyId, int status,
7254                    OrderByComparator<BlogsEntry> orderByComparator)
7255                    throws NoSuchEntryException {
7256                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7257                                    orderByComparator);
7258    
7259                    if (blogsEntry != null) {
7260                            return blogsEntry;
7261                    }
7262    
7263                    StringBundler msg = new StringBundler(6);
7264    
7265                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7266    
7267                    msg.append("companyId=");
7268                    msg.append(companyId);
7269    
7270                    msg.append(", status=");
7271                    msg.append(status);
7272    
7273                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7274    
7275                    throw new NoSuchEntryException(msg.toString());
7276            }
7277    
7278            /**
7279             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7280             *
7281             * @param companyId the company ID
7282             * @param status the status
7283             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7284             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7285             */
7286            @Override
7287            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7288                    OrderByComparator<BlogsEntry> orderByComparator) {
7289                    int count = countByC_S(companyId, status);
7290    
7291                    if (count == 0) {
7292                            return null;
7293                    }
7294    
7295                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7296                                    orderByComparator);
7297    
7298                    if (!list.isEmpty()) {
7299                            return list.get(0);
7300                    }
7301    
7302                    return null;
7303            }
7304    
7305            /**
7306             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7307             *
7308             * @param entryId the primary key of the current blogs entry
7309             * @param companyId the company ID
7310             * @param status the status
7311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7312             * @return the previous, current, and next blogs entry
7313             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7314             */
7315            @Override
7316            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7317                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7318                    throws NoSuchEntryException {
7319                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7320    
7321                    Session session = null;
7322    
7323                    try {
7324                            session = openSession();
7325    
7326                            BlogsEntry[] array = new BlogsEntryImpl[3];
7327    
7328                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7329                                            status, orderByComparator, true);
7330    
7331                            array[1] = blogsEntry;
7332    
7333                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7334                                            status, orderByComparator, false);
7335    
7336                            return array;
7337                    }
7338                    catch (Exception e) {
7339                            throw processException(e);
7340                    }
7341                    finally {
7342                            closeSession(session);
7343                    }
7344            }
7345    
7346            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7347                    BlogsEntry blogsEntry, long companyId, int status,
7348                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7349                    StringBundler query = null;
7350    
7351                    if (orderByComparator != null) {
7352                            query = new StringBundler(6 +
7353                                            (orderByComparator.getOrderByFields().length * 6));
7354                    }
7355                    else {
7356                            query = new StringBundler(3);
7357                    }
7358    
7359                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7360    
7361                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7362    
7363                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7364    
7365                    if (orderByComparator != null) {
7366                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7367    
7368                            if (orderByConditionFields.length > 0) {
7369                                    query.append(WHERE_AND);
7370                            }
7371    
7372                            for (int i = 0; i < orderByConditionFields.length; i++) {
7373                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7374                                    query.append(orderByConditionFields[i]);
7375    
7376                                    if ((i + 1) < orderByConditionFields.length) {
7377                                            if (orderByComparator.isAscending() ^ previous) {
7378                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7379                                            }
7380                                            else {
7381                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7382                                            }
7383                                    }
7384                                    else {
7385                                            if (orderByComparator.isAscending() ^ previous) {
7386                                                    query.append(WHERE_GREATER_THAN);
7387                                            }
7388                                            else {
7389                                                    query.append(WHERE_LESSER_THAN);
7390                                            }
7391                                    }
7392                            }
7393    
7394                            query.append(ORDER_BY_CLAUSE);
7395    
7396                            String[] orderByFields = orderByComparator.getOrderByFields();
7397    
7398                            for (int i = 0; i < orderByFields.length; i++) {
7399                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7400                                    query.append(orderByFields[i]);
7401    
7402                                    if ((i + 1) < orderByFields.length) {
7403                                            if (orderByComparator.isAscending() ^ previous) {
7404                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7405                                            }
7406                                            else {
7407                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7408                                            }
7409                                    }
7410                                    else {
7411                                            if (orderByComparator.isAscending() ^ previous) {
7412                                                    query.append(ORDER_BY_ASC);
7413                                            }
7414                                            else {
7415                                                    query.append(ORDER_BY_DESC);
7416                                            }
7417                                    }
7418                            }
7419                    }
7420                    else {
7421                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7422                    }
7423    
7424                    String sql = query.toString();
7425    
7426                    Query q = session.createQuery(sql);
7427    
7428                    q.setFirstResult(0);
7429                    q.setMaxResults(2);
7430    
7431                    QueryPos qPos = QueryPos.getInstance(q);
7432    
7433                    qPos.add(companyId);
7434    
7435                    qPos.add(status);
7436    
7437                    if (orderByComparator != null) {
7438                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7439    
7440                            for (Object value : values) {
7441                                    qPos.add(value);
7442                            }
7443                    }
7444    
7445                    List<BlogsEntry> list = q.list();
7446    
7447                    if (list.size() == 2) {
7448                            return list.get(1);
7449                    }
7450                    else {
7451                            return null;
7452                    }
7453            }
7454    
7455            /**
7456             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7457             *
7458             * @param companyId the company ID
7459             * @param status the status
7460             */
7461            @Override
7462            public void removeByC_S(long companyId, int status) {
7463                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7464                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7465                            remove(blogsEntry);
7466                    }
7467            }
7468    
7469            /**
7470             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7471             *
7472             * @param companyId the company ID
7473             * @param status the status
7474             * @return the number of matching blogs entries
7475             */
7476            @Override
7477            public int countByC_S(long companyId, int status) {
7478                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7479    
7480                    Object[] finderArgs = new Object[] { companyId, status };
7481    
7482                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7483    
7484                    if (count == null) {
7485                            StringBundler query = new StringBundler(3);
7486    
7487                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7488    
7489                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7490    
7491                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7492    
7493                            String sql = query.toString();
7494    
7495                            Session session = null;
7496    
7497                            try {
7498                                    session = openSession();
7499    
7500                                    Query q = session.createQuery(sql);
7501    
7502                                    QueryPos qPos = QueryPos.getInstance(q);
7503    
7504                                    qPos.add(companyId);
7505    
7506                                    qPos.add(status);
7507    
7508                                    count = (Long)q.uniqueResult();
7509    
7510                                    finderCache.putResult(finderPath, finderArgs, count);
7511                            }
7512                            catch (Exception e) {
7513                                    finderCache.removeResult(finderPath, finderArgs);
7514    
7515                                    throw processException(e);
7516                            }
7517                            finally {
7518                                    closeSession(session);
7519                            }
7520                    }
7521    
7522                    return count.intValue();
7523            }
7524    
7525            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7526            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7527            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7528                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7529                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7530                            new String[] {
7531                                    Long.class.getName(), Integer.class.getName(),
7532                                    
7533                            Integer.class.getName(), Integer.class.getName(),
7534                                    OrderByComparator.class.getName()
7535                            });
7536            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7537                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7538                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7539                            new String[] { Long.class.getName(), Integer.class.getName() });
7540    
7541            /**
7542             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7543             *
7544             * @param companyId the company ID
7545             * @param status the status
7546             * @return the matching blogs entries
7547             */
7548            @Override
7549            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7550                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7551                            QueryUtil.ALL_POS, null);
7552            }
7553    
7554            /**
7555             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7556             *
7557             * <p>
7558             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7559             * </p>
7560             *
7561             * @param companyId the company ID
7562             * @param status the status
7563             * @param start the lower bound of the range of blogs entries
7564             * @param end the upper bound of the range of blogs entries (not inclusive)
7565             * @return the range of matching blogs entries
7566             */
7567            @Override
7568            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7569                    int end) {
7570                    return findByC_NotS(companyId, status, start, end, null);
7571            }
7572    
7573            /**
7574             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7575             *
7576             * <p>
7577             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7578             * </p>
7579             *
7580             * @param companyId the company ID
7581             * @param status the status
7582             * @param start the lower bound of the range of blogs entries
7583             * @param end the upper bound of the range of blogs entries (not inclusive)
7584             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7585             * @return the ordered range of matching blogs entries
7586             */
7587            @Override
7588            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7589                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7590                    return findByC_NotS(companyId, status, start, end, orderByComparator,
7591                            true);
7592            }
7593    
7594            /**
7595             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7596             *
7597             * <p>
7598             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7599             * </p>
7600             *
7601             * @param companyId the company ID
7602             * @param status the status
7603             * @param start the lower bound of the range of blogs entries
7604             * @param end the upper bound of the range of blogs entries (not inclusive)
7605             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7606             * @param retrieveFromCache whether to retrieve from the finder cache
7607             * @return the ordered range of matching blogs entries
7608             */
7609            @Override
7610            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7611                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7612                    boolean retrieveFromCache) {
7613                    boolean pagination = true;
7614                    FinderPath finderPath = null;
7615                    Object[] finderArgs = null;
7616    
7617                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7618                    finderArgs = new Object[] {
7619                                    companyId, status,
7620                                    
7621                                    start, end, orderByComparator
7622                            };
7623    
7624                    List<BlogsEntry> list = null;
7625    
7626                    if (retrieveFromCache) {
7627                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7628                                            finderArgs, this);
7629    
7630                            if ((list != null) && !list.isEmpty()) {
7631                                    for (BlogsEntry blogsEntry : list) {
7632                                            if ((companyId != blogsEntry.getCompanyId()) ||
7633                                                            (status == blogsEntry.getStatus())) {
7634                                                    list = null;
7635    
7636                                                    break;
7637                                            }
7638                                    }
7639                            }
7640                    }
7641    
7642                    if (list == null) {
7643                            StringBundler query = null;
7644    
7645                            if (orderByComparator != null) {
7646                                    query = new StringBundler(4 +
7647                                                    (orderByComparator.getOrderByFields().length * 3));
7648                            }
7649                            else {
7650                                    query = new StringBundler(4);
7651                            }
7652    
7653                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7654    
7655                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7656    
7657                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7658    
7659                            if (orderByComparator != null) {
7660                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7661                                            orderByComparator);
7662                            }
7663                            else
7664                             if (pagination) {
7665                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7666                            }
7667    
7668                            String sql = query.toString();
7669    
7670                            Session session = null;
7671    
7672                            try {
7673                                    session = openSession();
7674    
7675                                    Query q = session.createQuery(sql);
7676    
7677                                    QueryPos qPos = QueryPos.getInstance(q);
7678    
7679                                    qPos.add(companyId);
7680    
7681                                    qPos.add(status);
7682    
7683                                    if (!pagination) {
7684                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7685                                                            start, end, false);
7686    
7687                                            Collections.sort(list);
7688    
7689                                            list = Collections.unmodifiableList(list);
7690                                    }
7691                                    else {
7692                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7693                                                            start, end);
7694                                    }
7695    
7696                                    cacheResult(list);
7697    
7698                                    finderCache.putResult(finderPath, finderArgs, list);
7699                            }
7700                            catch (Exception e) {
7701                                    finderCache.removeResult(finderPath, finderArgs);
7702    
7703                                    throw processException(e);
7704                            }
7705                            finally {
7706                                    closeSession(session);
7707                            }
7708                    }
7709    
7710                    return list;
7711            }
7712    
7713            /**
7714             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7715             *
7716             * @param companyId the company ID
7717             * @param status the status
7718             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7719             * @return the first matching blogs entry
7720             * @throws NoSuchEntryException if a matching blogs entry could not be found
7721             */
7722            @Override
7723            public BlogsEntry findByC_NotS_First(long companyId, int status,
7724                    OrderByComparator<BlogsEntry> orderByComparator)
7725                    throws NoSuchEntryException {
7726                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7727                                    orderByComparator);
7728    
7729                    if (blogsEntry != null) {
7730                            return blogsEntry;
7731                    }
7732    
7733                    StringBundler msg = new StringBundler(6);
7734    
7735                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7736    
7737                    msg.append("companyId=");
7738                    msg.append(companyId);
7739    
7740                    msg.append(", status=");
7741                    msg.append(status);
7742    
7743                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7744    
7745                    throw new NoSuchEntryException(msg.toString());
7746            }
7747    
7748            /**
7749             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7750             *
7751             * @param companyId the company ID
7752             * @param status the status
7753             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7754             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7755             */
7756            @Override
7757            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7758                    OrderByComparator<BlogsEntry> orderByComparator) {
7759                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7760                                    orderByComparator);
7761    
7762                    if (!list.isEmpty()) {
7763                            return list.get(0);
7764                    }
7765    
7766                    return null;
7767            }
7768    
7769            /**
7770             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7771             *
7772             * @param companyId the company ID
7773             * @param status the status
7774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7775             * @return the last matching blogs entry
7776             * @throws NoSuchEntryException if a matching blogs entry could not be found
7777             */
7778            @Override
7779            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7780                    OrderByComparator<BlogsEntry> orderByComparator)
7781                    throws NoSuchEntryException {
7782                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7783                                    orderByComparator);
7784    
7785                    if (blogsEntry != null) {
7786                            return blogsEntry;
7787                    }
7788    
7789                    StringBundler msg = new StringBundler(6);
7790    
7791                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7792    
7793                    msg.append("companyId=");
7794                    msg.append(companyId);
7795    
7796                    msg.append(", status=");
7797                    msg.append(status);
7798    
7799                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7800    
7801                    throw new NoSuchEntryException(msg.toString());
7802            }
7803    
7804            /**
7805             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7806             *
7807             * @param companyId the company ID
7808             * @param status the status
7809             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7810             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7811             */
7812            @Override
7813            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7814                    OrderByComparator<BlogsEntry> orderByComparator) {
7815                    int count = countByC_NotS(companyId, status);
7816    
7817                    if (count == 0) {
7818                            return null;
7819                    }
7820    
7821                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7822                                    count, orderByComparator);
7823    
7824                    if (!list.isEmpty()) {
7825                            return list.get(0);
7826                    }
7827    
7828                    return null;
7829            }
7830    
7831            /**
7832             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7833             *
7834             * @param entryId the primary key of the current blogs entry
7835             * @param companyId the company ID
7836             * @param status the status
7837             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7838             * @return the previous, current, and next blogs entry
7839             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7840             */
7841            @Override
7842            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7843                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7844                    throws NoSuchEntryException {
7845                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7846    
7847                    Session session = null;
7848    
7849                    try {
7850                            session = openSession();
7851    
7852                            BlogsEntry[] array = new BlogsEntryImpl[3];
7853    
7854                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7855                                            status, orderByComparator, true);
7856    
7857                            array[1] = blogsEntry;
7858    
7859                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7860                                            status, orderByComparator, false);
7861    
7862                            return array;
7863                    }
7864                    catch (Exception e) {
7865                            throw processException(e);
7866                    }
7867                    finally {
7868                            closeSession(session);
7869                    }
7870            }
7871    
7872            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7873                    BlogsEntry blogsEntry, long companyId, int status,
7874                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7875                    StringBundler query = null;
7876    
7877                    if (orderByComparator != null) {
7878                            query = new StringBundler(6 +
7879                                            (orderByComparator.getOrderByFields().length * 6));
7880                    }
7881                    else {
7882                            query = new StringBundler(3);
7883                    }
7884    
7885                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7886    
7887                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7888    
7889                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7890    
7891                    if (orderByComparator != null) {
7892                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7893    
7894                            if (orderByConditionFields.length > 0) {
7895                                    query.append(WHERE_AND);
7896                            }
7897    
7898                            for (int i = 0; i < orderByConditionFields.length; i++) {
7899                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7900                                    query.append(orderByConditionFields[i]);
7901    
7902                                    if ((i + 1) < orderByConditionFields.length) {
7903                                            if (orderByComparator.isAscending() ^ previous) {
7904                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7905                                            }
7906                                            else {
7907                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7908                                            }
7909                                    }
7910                                    else {
7911                                            if (orderByComparator.isAscending() ^ previous) {
7912                                                    query.append(WHERE_GREATER_THAN);
7913                                            }
7914                                            else {
7915                                                    query.append(WHERE_LESSER_THAN);
7916                                            }
7917                                    }
7918                            }
7919    
7920                            query.append(ORDER_BY_CLAUSE);
7921    
7922                            String[] orderByFields = orderByComparator.getOrderByFields();
7923    
7924                            for (int i = 0; i < orderByFields.length; i++) {
7925                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7926                                    query.append(orderByFields[i]);
7927    
7928                                    if ((i + 1) < orderByFields.length) {
7929                                            if (orderByComparator.isAscending() ^ previous) {
7930                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7931                                            }
7932                                            else {
7933                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7934                                            }
7935                                    }
7936                                    else {
7937                                            if (orderByComparator.isAscending() ^ previous) {
7938                                                    query.append(ORDER_BY_ASC);
7939                                            }
7940                                            else {
7941                                                    query.append(ORDER_BY_DESC);
7942                                            }
7943                                    }
7944                            }
7945                    }
7946                    else {
7947                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7948                    }
7949    
7950                    String sql = query.toString();
7951    
7952                    Query q = session.createQuery(sql);
7953    
7954                    q.setFirstResult(0);
7955                    q.setMaxResults(2);
7956    
7957                    QueryPos qPos = QueryPos.getInstance(q);
7958    
7959                    qPos.add(companyId);
7960    
7961                    qPos.add(status);
7962    
7963                    if (orderByComparator != null) {
7964                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7965    
7966                            for (Object value : values) {
7967                                    qPos.add(value);
7968                            }
7969                    }
7970    
7971                    List<BlogsEntry> list = q.list();
7972    
7973                    if (list.size() == 2) {
7974                            return list.get(1);
7975                    }
7976                    else {
7977                            return null;
7978                    }
7979            }
7980    
7981            /**
7982             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
7983             *
7984             * @param companyId the company ID
7985             * @param status the status
7986             */
7987            @Override
7988            public void removeByC_NotS(long companyId, int status) {
7989                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
7990                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7991                            remove(blogsEntry);
7992                    }
7993            }
7994    
7995            /**
7996             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
7997             *
7998             * @param companyId the company ID
7999             * @param status the status
8000             * @return the number of matching blogs entries
8001             */
8002            @Override
8003            public int countByC_NotS(long companyId, int status) {
8004                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
8005    
8006                    Object[] finderArgs = new Object[] { companyId, status };
8007    
8008                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8009    
8010                    if (count == null) {
8011                            StringBundler query = new StringBundler(3);
8012    
8013                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8014    
8015                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
8016    
8017                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
8018    
8019                            String sql = query.toString();
8020    
8021                            Session session = null;
8022    
8023                            try {
8024                                    session = openSession();
8025    
8026                                    Query q = session.createQuery(sql);
8027    
8028                                    QueryPos qPos = QueryPos.getInstance(q);
8029    
8030                                    qPos.add(companyId);
8031    
8032                                    qPos.add(status);
8033    
8034                                    count = (Long)q.uniqueResult();
8035    
8036                                    finderCache.putResult(finderPath, finderArgs, count);
8037                            }
8038                            catch (Exception e) {
8039                                    finderCache.removeResult(finderPath, finderArgs);
8040    
8041                                    throw processException(e);
8042                            }
8043                            finally {
8044                                    closeSession(session);
8045                            }
8046                    }
8047    
8048                    return count.intValue();
8049            }
8050    
8051            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8052            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
8053            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8054                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8055                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
8056                            new String[] {
8057                                    Date.class.getName(), Integer.class.getName(),
8058                                    
8059                            Integer.class.getName(), Integer.class.getName(),
8060                                    OrderByComparator.class.getName()
8061                            });
8062            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8063                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8064                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
8065                            new String[] { Date.class.getName(), Integer.class.getName() });
8066    
8067            /**
8068             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8069             *
8070             * @param displayDate the display date
8071             * @param status the status
8072             * @return the matching blogs entries
8073             */
8074            @Override
8075            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
8076                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
8077                            QueryUtil.ALL_POS, null);
8078            }
8079    
8080            /**
8081             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8082             *
8083             * <p>
8084             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8085             * </p>
8086             *
8087             * @param displayDate the display date
8088             * @param status the status
8089             * @param start the lower bound of the range of blogs entries
8090             * @param end the upper bound of the range of blogs entries (not inclusive)
8091             * @return the range of matching blogs entries
8092             */
8093            @Override
8094            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8095                    int start, int end) {
8096                    return findByLtD_S(displayDate, status, start, end, null);
8097            }
8098    
8099            /**
8100             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8101             *
8102             * <p>
8103             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8104             * </p>
8105             *
8106             * @param displayDate the display date
8107             * @param status the status
8108             * @param start the lower bound of the range of blogs entries
8109             * @param end the upper bound of the range of blogs entries (not inclusive)
8110             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8111             * @return the ordered range of matching blogs entries
8112             */
8113            @Override
8114            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8115                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
8116                    return findByLtD_S(displayDate, status, start, end, orderByComparator,
8117                            true);
8118            }
8119    
8120            /**
8121             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8122             *
8123             * <p>
8124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8125             * </p>
8126             *
8127             * @param displayDate the display date
8128             * @param status the status
8129             * @param start the lower bound of the range of blogs entries
8130             * @param end the upper bound of the range of blogs entries (not inclusive)
8131             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8132             * @param retrieveFromCache whether to retrieve from the finder cache
8133             * @return the ordered range of matching blogs entries
8134             */
8135            @Override
8136            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8137                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
8138                    boolean retrieveFromCache) {
8139                    boolean pagination = true;
8140                    FinderPath finderPath = null;
8141                    Object[] finderArgs = null;
8142    
8143                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
8144                    finderArgs = new Object[] {
8145                                    displayDate, status,
8146                                    
8147                                    start, end, orderByComparator
8148                            };
8149    
8150                    List<BlogsEntry> list = null;
8151    
8152                    if (retrieveFromCache) {
8153                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8154                                            finderArgs, this);
8155    
8156                            if ((list != null) && !list.isEmpty()) {
8157                                    for (BlogsEntry blogsEntry : list) {
8158                                            if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
8159                                                                                                                                    .getTime()) ||
8160                                                            (status != blogsEntry.getStatus())) {
8161                                                    list = null;
8162    
8163                                                    break;
8164                                            }
8165                                    }
8166                            }
8167                    }
8168    
8169                    if (list == null) {
8170                            StringBundler query = null;
8171    
8172                            if (orderByComparator != null) {
8173                                    query = new StringBundler(4 +
8174                                                    (orderByComparator.getOrderByFields().length * 3));
8175                            }
8176                            else {
8177                                    query = new StringBundler(4);
8178                            }
8179    
8180                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8181    
8182                            boolean bindDisplayDate = false;
8183    
8184                            if (displayDate == null) {
8185                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8186                            }
8187                            else {
8188                                    bindDisplayDate = true;
8189    
8190                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8191                            }
8192    
8193                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8194    
8195                            if (orderByComparator != null) {
8196                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8197                                            orderByComparator);
8198                            }
8199                            else
8200                             if (pagination) {
8201                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8202                            }
8203    
8204                            String sql = query.toString();
8205    
8206                            Session session = null;
8207    
8208                            try {
8209                                    session = openSession();
8210    
8211                                    Query q = session.createQuery(sql);
8212    
8213                                    QueryPos qPos = QueryPos.getInstance(q);
8214    
8215                                    if (bindDisplayDate) {
8216                                            qPos.add(new Timestamp(displayDate.getTime()));
8217                                    }
8218    
8219                                    qPos.add(status);
8220    
8221                                    if (!pagination) {
8222                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8223                                                            start, end, false);
8224    
8225                                            Collections.sort(list);
8226    
8227                                            list = Collections.unmodifiableList(list);
8228                                    }
8229                                    else {
8230                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8231                                                            start, end);
8232                                    }
8233    
8234                                    cacheResult(list);
8235    
8236                                    finderCache.putResult(finderPath, finderArgs, list);
8237                            }
8238                            catch (Exception e) {
8239                                    finderCache.removeResult(finderPath, finderArgs);
8240    
8241                                    throw processException(e);
8242                            }
8243                            finally {
8244                                    closeSession(session);
8245                            }
8246                    }
8247    
8248                    return list;
8249            }
8250    
8251            /**
8252             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8253             *
8254             * @param displayDate the display date
8255             * @param status the status
8256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8257             * @return the first matching blogs entry
8258             * @throws NoSuchEntryException if a matching blogs entry could not be found
8259             */
8260            @Override
8261            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8262                    OrderByComparator<BlogsEntry> orderByComparator)
8263                    throws NoSuchEntryException {
8264                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8265                                    orderByComparator);
8266    
8267                    if (blogsEntry != null) {
8268                            return blogsEntry;
8269                    }
8270    
8271                    StringBundler msg = new StringBundler(6);
8272    
8273                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8274    
8275                    msg.append("displayDate=");
8276                    msg.append(displayDate);
8277    
8278                    msg.append(", status=");
8279                    msg.append(status);
8280    
8281                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8282    
8283                    throw new NoSuchEntryException(msg.toString());
8284            }
8285    
8286            /**
8287             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8288             *
8289             * @param displayDate the display date
8290             * @param status the status
8291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8292             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8293             */
8294            @Override
8295            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8296                    OrderByComparator<BlogsEntry> orderByComparator) {
8297                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8298                                    orderByComparator);
8299    
8300                    if (!list.isEmpty()) {
8301                            return list.get(0);
8302                    }
8303    
8304                    return null;
8305            }
8306    
8307            /**
8308             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8309             *
8310             * @param displayDate the display date
8311             * @param status the status
8312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8313             * @return the last matching blogs entry
8314             * @throws NoSuchEntryException if a matching blogs entry could not be found
8315             */
8316            @Override
8317            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8318                    OrderByComparator<BlogsEntry> orderByComparator)
8319                    throws NoSuchEntryException {
8320                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8321                                    orderByComparator);
8322    
8323                    if (blogsEntry != null) {
8324                            return blogsEntry;
8325                    }
8326    
8327                    StringBundler msg = new StringBundler(6);
8328    
8329                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8330    
8331                    msg.append("displayDate=");
8332                    msg.append(displayDate);
8333    
8334                    msg.append(", status=");
8335                    msg.append(status);
8336    
8337                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8338    
8339                    throw new NoSuchEntryException(msg.toString());
8340            }
8341    
8342            /**
8343             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8344             *
8345             * @param displayDate the display date
8346             * @param status the status
8347             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8348             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8349             */
8350            @Override
8351            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8352                    OrderByComparator<BlogsEntry> orderByComparator) {
8353                    int count = countByLtD_S(displayDate, status);
8354    
8355                    if (count == 0) {
8356                            return null;
8357                    }
8358    
8359                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8360                                    count, orderByComparator);
8361    
8362                    if (!list.isEmpty()) {
8363                            return list.get(0);
8364                    }
8365    
8366                    return null;
8367            }
8368    
8369            /**
8370             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8371             *
8372             * @param entryId the primary key of the current blogs entry
8373             * @param displayDate the display date
8374             * @param status the status
8375             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8376             * @return the previous, current, and next blogs entry
8377             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8378             */
8379            @Override
8380            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8381                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8382                    throws NoSuchEntryException {
8383                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8384    
8385                    Session session = null;
8386    
8387                    try {
8388                            session = openSession();
8389    
8390                            BlogsEntry[] array = new BlogsEntryImpl[3];
8391    
8392                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8393                                            status, orderByComparator, true);
8394    
8395                            array[1] = blogsEntry;
8396    
8397                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8398                                            status, orderByComparator, false);
8399    
8400                            return array;
8401                    }
8402                    catch (Exception e) {
8403                            throw processException(e);
8404                    }
8405                    finally {
8406                            closeSession(session);
8407                    }
8408            }
8409    
8410            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8411                    BlogsEntry blogsEntry, Date displayDate, int status,
8412                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8413                    StringBundler query = null;
8414    
8415                    if (orderByComparator != null) {
8416                            query = new StringBundler(6 +
8417                                            (orderByComparator.getOrderByFields().length * 6));
8418                    }
8419                    else {
8420                            query = new StringBundler(3);
8421                    }
8422    
8423                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8424    
8425                    boolean bindDisplayDate = false;
8426    
8427                    if (displayDate == null) {
8428                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8429                    }
8430                    else {
8431                            bindDisplayDate = true;
8432    
8433                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8434                    }
8435    
8436                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8437    
8438                    if (orderByComparator != null) {
8439                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8440    
8441                            if (orderByConditionFields.length > 0) {
8442                                    query.append(WHERE_AND);
8443                            }
8444    
8445                            for (int i = 0; i < orderByConditionFields.length; i++) {
8446                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8447                                    query.append(orderByConditionFields[i]);
8448    
8449                                    if ((i + 1) < orderByConditionFields.length) {
8450                                            if (orderByComparator.isAscending() ^ previous) {
8451                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8452                                            }
8453                                            else {
8454                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8455                                            }
8456                                    }
8457                                    else {
8458                                            if (orderByComparator.isAscending() ^ previous) {
8459                                                    query.append(WHERE_GREATER_THAN);
8460                                            }
8461                                            else {
8462                                                    query.append(WHERE_LESSER_THAN);
8463                                            }
8464                                    }
8465                            }
8466    
8467                            query.append(ORDER_BY_CLAUSE);
8468    
8469                            String[] orderByFields = orderByComparator.getOrderByFields();
8470    
8471                            for (int i = 0; i < orderByFields.length; i++) {
8472                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8473                                    query.append(orderByFields[i]);
8474    
8475                                    if ((i + 1) < orderByFields.length) {
8476                                            if (orderByComparator.isAscending() ^ previous) {
8477                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8478                                            }
8479                                            else {
8480                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8481                                            }
8482                                    }
8483                                    else {
8484                                            if (orderByComparator.isAscending() ^ previous) {
8485                                                    query.append(ORDER_BY_ASC);
8486                                            }
8487                                            else {
8488                                                    query.append(ORDER_BY_DESC);
8489                                            }
8490                                    }
8491                            }
8492                    }
8493                    else {
8494                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8495                    }
8496    
8497                    String sql = query.toString();
8498    
8499                    Query q = session.createQuery(sql);
8500    
8501                    q.setFirstResult(0);
8502                    q.setMaxResults(2);
8503    
8504                    QueryPos qPos = QueryPos.getInstance(q);
8505    
8506                    if (bindDisplayDate) {
8507                            qPos.add(new Timestamp(displayDate.getTime()));
8508                    }
8509    
8510                    qPos.add(status);
8511    
8512                    if (orderByComparator != null) {
8513                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8514    
8515                            for (Object value : values) {
8516                                    qPos.add(value);
8517                            }
8518                    }
8519    
8520                    List<BlogsEntry> list = q.list();
8521    
8522                    if (list.size() == 2) {
8523                            return list.get(1);
8524                    }
8525                    else {
8526                            return null;
8527                    }
8528            }
8529    
8530            /**
8531             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8532             *
8533             * @param displayDate the display date
8534             * @param status the status
8535             */
8536            @Override
8537            public void removeByLtD_S(Date displayDate, int status) {
8538                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8539                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8540                            remove(blogsEntry);
8541                    }
8542            }
8543    
8544            /**
8545             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8546             *
8547             * @param displayDate the display date
8548             * @param status the status
8549             * @return the number of matching blogs entries
8550             */
8551            @Override
8552            public int countByLtD_S(Date displayDate, int status) {
8553                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8554    
8555                    Object[] finderArgs = new Object[] { displayDate, status };
8556    
8557                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8558    
8559                    if (count == null) {
8560                            StringBundler query = new StringBundler(3);
8561    
8562                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8563    
8564                            boolean bindDisplayDate = false;
8565    
8566                            if (displayDate == null) {
8567                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8568                            }
8569                            else {
8570                                    bindDisplayDate = true;
8571    
8572                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8573                            }
8574    
8575                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8576    
8577                            String sql = query.toString();
8578    
8579                            Session session = null;
8580    
8581                            try {
8582                                    session = openSession();
8583    
8584                                    Query q = session.createQuery(sql);
8585    
8586                                    QueryPos qPos = QueryPos.getInstance(q);
8587    
8588                                    if (bindDisplayDate) {
8589                                            qPos.add(new Timestamp(displayDate.getTime()));
8590                                    }
8591    
8592                                    qPos.add(status);
8593    
8594                                    count = (Long)q.uniqueResult();
8595    
8596                                    finderCache.putResult(finderPath, finderArgs, count);
8597                            }
8598                            catch (Exception e) {
8599                                    finderCache.removeResult(finderPath, finderArgs);
8600    
8601                                    throw processException(e);
8602                            }
8603                            finally {
8604                                    closeSession(session);
8605                            }
8606                    }
8607    
8608                    return count.intValue();
8609            }
8610    
8611            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
8612            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8613            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8614            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8615                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8616                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8617                            new String[] {
8618                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8619                                    
8620                            Integer.class.getName(), Integer.class.getName(),
8621                                    OrderByComparator.class.getName()
8622                            });
8623            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8624                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8625                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8626                            new String[] {
8627                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8628                            });
8629    
8630            /**
8631             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8632             *
8633             * @param groupId the group ID
8634             * @param userId the user ID
8635             * @param displayDate the display date
8636             * @return the matching blogs entries
8637             */
8638            @Override
8639            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8640                    Date displayDate) {
8641                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8642                            QueryUtil.ALL_POS, null);
8643            }
8644    
8645            /**
8646             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8647             *
8648             * <p>
8649             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8650             * </p>
8651             *
8652             * @param groupId the group ID
8653             * @param userId the user ID
8654             * @param displayDate the display date
8655             * @param start the lower bound of the range of blogs entries
8656             * @param end the upper bound of the range of blogs entries (not inclusive)
8657             * @return the range of matching blogs entries
8658             */
8659            @Override
8660            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8661                    Date displayDate, int start, int end) {
8662                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8663            }
8664    
8665            /**
8666             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8667             *
8668             * <p>
8669             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8670             * </p>
8671             *
8672             * @param groupId the group ID
8673             * @param userId the user ID
8674             * @param displayDate the display date
8675             * @param start the lower bound of the range of blogs entries
8676             * @param end the upper bound of the range of blogs entries (not inclusive)
8677             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8678             * @return the ordered range of matching blogs entries
8679             */
8680            @Override
8681            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8682                    Date displayDate, int start, int end,
8683                    OrderByComparator<BlogsEntry> orderByComparator) {
8684                    return findByG_U_LtD(groupId, userId, displayDate, start, end,
8685                            orderByComparator, true);
8686            }
8687    
8688            /**
8689             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8690             *
8691             * <p>
8692             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8693             * </p>
8694             *
8695             * @param groupId the group ID
8696             * @param userId the user ID
8697             * @param displayDate the display date
8698             * @param start the lower bound of the range of blogs entries
8699             * @param end the upper bound of the range of blogs entries (not inclusive)
8700             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8701             * @param retrieveFromCache whether to retrieve from the finder cache
8702             * @return the ordered range of matching blogs entries
8703             */
8704            @Override
8705            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8706                    Date displayDate, int start, int end,
8707                    OrderByComparator<BlogsEntry> orderByComparator,
8708                    boolean retrieveFromCache) {
8709                    boolean pagination = true;
8710                    FinderPath finderPath = null;
8711                    Object[] finderArgs = null;
8712    
8713                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8714                    finderArgs = new Object[] {
8715                                    groupId, userId, displayDate,
8716                                    
8717                                    start, end, orderByComparator
8718                            };
8719    
8720                    List<BlogsEntry> list = null;
8721    
8722                    if (retrieveFromCache) {
8723                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8724                                            finderArgs, this);
8725    
8726                            if ((list != null) && !list.isEmpty()) {
8727                                    for (BlogsEntry blogsEntry : list) {
8728                                            if ((groupId != blogsEntry.getGroupId()) ||
8729                                                            (userId != blogsEntry.getUserId()) ||
8730                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
8731                                                                                                                                            .getTime())) {
8732                                                    list = null;
8733    
8734                                                    break;
8735                                            }
8736                                    }
8737                            }
8738                    }
8739    
8740                    if (list == null) {
8741                            StringBundler query = null;
8742    
8743                            if (orderByComparator != null) {
8744                                    query = new StringBundler(5 +
8745                                                    (orderByComparator.getOrderByFields().length * 3));
8746                            }
8747                            else {
8748                                    query = new StringBundler(5);
8749                            }
8750    
8751                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8752    
8753                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8754    
8755                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8756    
8757                            boolean bindDisplayDate = false;
8758    
8759                            if (displayDate == null) {
8760                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8761                            }
8762                            else {
8763                                    bindDisplayDate = true;
8764    
8765                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8766                            }
8767    
8768                            if (orderByComparator != null) {
8769                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8770                                            orderByComparator);
8771                            }
8772                            else
8773                             if (pagination) {
8774                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8775                            }
8776    
8777                            String sql = query.toString();
8778    
8779                            Session session = null;
8780    
8781                            try {
8782                                    session = openSession();
8783    
8784                                    Query q = session.createQuery(sql);
8785    
8786                                    QueryPos qPos = QueryPos.getInstance(q);
8787    
8788                                    qPos.add(groupId);
8789    
8790                                    qPos.add(userId);
8791    
8792                                    if (bindDisplayDate) {
8793                                            qPos.add(new Timestamp(displayDate.getTime()));
8794                                    }
8795    
8796                                    if (!pagination) {
8797                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8798                                                            start, end, false);
8799    
8800                                            Collections.sort(list);
8801    
8802                                            list = Collections.unmodifiableList(list);
8803                                    }
8804                                    else {
8805                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8806                                                            start, end);
8807                                    }
8808    
8809                                    cacheResult(list);
8810    
8811                                    finderCache.putResult(finderPath, finderArgs, list);
8812                            }
8813                            catch (Exception e) {
8814                                    finderCache.removeResult(finderPath, finderArgs);
8815    
8816                                    throw processException(e);
8817                            }
8818                            finally {
8819                                    closeSession(session);
8820                            }
8821                    }
8822    
8823                    return list;
8824            }
8825    
8826            /**
8827             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8828             *
8829             * @param groupId the group ID
8830             * @param userId the user ID
8831             * @param displayDate the display date
8832             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8833             * @return the first matching blogs entry
8834             * @throws NoSuchEntryException if a matching blogs entry could not be found
8835             */
8836            @Override
8837            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8838                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8839                    throws NoSuchEntryException {
8840                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8841                                    displayDate, orderByComparator);
8842    
8843                    if (blogsEntry != null) {
8844                            return blogsEntry;
8845                    }
8846    
8847                    StringBundler msg = new StringBundler(8);
8848    
8849                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8850    
8851                    msg.append("groupId=");
8852                    msg.append(groupId);
8853    
8854                    msg.append(", userId=");
8855                    msg.append(userId);
8856    
8857                    msg.append(", displayDate=");
8858                    msg.append(displayDate);
8859    
8860                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8861    
8862                    throw new NoSuchEntryException(msg.toString());
8863            }
8864    
8865            /**
8866             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8867             *
8868             * @param groupId the group ID
8869             * @param userId the user ID
8870             * @param displayDate the display date
8871             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8872             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8873             */
8874            @Override
8875            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8876                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8877                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8878                                    1, orderByComparator);
8879    
8880                    if (!list.isEmpty()) {
8881                            return list.get(0);
8882                    }
8883    
8884                    return null;
8885            }
8886    
8887            /**
8888             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8889             *
8890             * @param groupId the group ID
8891             * @param userId the user ID
8892             * @param displayDate the display date
8893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8894             * @return the last matching blogs entry
8895             * @throws NoSuchEntryException if a matching blogs entry could not be found
8896             */
8897            @Override
8898            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8899                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8900                    throws NoSuchEntryException {
8901                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8902                                    displayDate, orderByComparator);
8903    
8904                    if (blogsEntry != null) {
8905                            return blogsEntry;
8906                    }
8907    
8908                    StringBundler msg = new StringBundler(8);
8909    
8910                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8911    
8912                    msg.append("groupId=");
8913                    msg.append(groupId);
8914    
8915                    msg.append(", userId=");
8916                    msg.append(userId);
8917    
8918                    msg.append(", displayDate=");
8919                    msg.append(displayDate);
8920    
8921                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8922    
8923                    throw new NoSuchEntryException(msg.toString());
8924            }
8925    
8926            /**
8927             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8928             *
8929             * @param groupId the group ID
8930             * @param userId the user ID
8931             * @param displayDate the display date
8932             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8933             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8934             */
8935            @Override
8936            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8937                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8938                    int count = countByG_U_LtD(groupId, userId, displayDate);
8939    
8940                    if (count == 0) {
8941                            return null;
8942                    }
8943    
8944                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8945                                    count - 1, count, orderByComparator);
8946    
8947                    if (!list.isEmpty()) {
8948                            return list.get(0);
8949                    }
8950    
8951                    return null;
8952            }
8953    
8954            /**
8955             * 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;.
8956             *
8957             * @param entryId the primary key of the current blogs entry
8958             * @param groupId the group ID
8959             * @param userId the user ID
8960             * @param displayDate the display date
8961             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8962             * @return the previous, current, and next blogs entry
8963             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8964             */
8965            @Override
8966            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8967                    long userId, Date displayDate,
8968                    OrderByComparator<BlogsEntry> orderByComparator)
8969                    throws NoSuchEntryException {
8970                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8971    
8972                    Session session = null;
8973    
8974                    try {
8975                            session = openSession();
8976    
8977                            BlogsEntry[] array = new BlogsEntryImpl[3];
8978    
8979                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8980                                            userId, displayDate, orderByComparator, true);
8981    
8982                            array[1] = blogsEntry;
8983    
8984                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8985                                            userId, displayDate, orderByComparator, false);
8986    
8987                            return array;
8988                    }
8989                    catch (Exception e) {
8990                            throw processException(e);
8991                    }
8992                    finally {
8993                            closeSession(session);
8994                    }
8995            }
8996    
8997            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
8998                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
8999                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9000                    StringBundler query = null;
9001    
9002                    if (orderByComparator != null) {
9003                            query = new StringBundler(6 +
9004                                            (orderByComparator.getOrderByFields().length * 6));
9005                    }
9006                    else {
9007                            query = new StringBundler(3);
9008                    }
9009    
9010                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9011    
9012                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9013    
9014                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9015    
9016                    boolean bindDisplayDate = false;
9017    
9018                    if (displayDate == null) {
9019                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9020                    }
9021                    else {
9022                            bindDisplayDate = true;
9023    
9024                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9025                    }
9026    
9027                    if (orderByComparator != null) {
9028                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9029    
9030                            if (orderByConditionFields.length > 0) {
9031                                    query.append(WHERE_AND);
9032                            }
9033    
9034                            for (int i = 0; i < orderByConditionFields.length; i++) {
9035                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9036                                    query.append(orderByConditionFields[i]);
9037    
9038                                    if ((i + 1) < orderByConditionFields.length) {
9039                                            if (orderByComparator.isAscending() ^ previous) {
9040                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9041                                            }
9042                                            else {
9043                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9044                                            }
9045                                    }
9046                                    else {
9047                                            if (orderByComparator.isAscending() ^ previous) {
9048                                                    query.append(WHERE_GREATER_THAN);
9049                                            }
9050                                            else {
9051                                                    query.append(WHERE_LESSER_THAN);
9052                                            }
9053                                    }
9054                            }
9055    
9056                            query.append(ORDER_BY_CLAUSE);
9057    
9058                            String[] orderByFields = orderByComparator.getOrderByFields();
9059    
9060                            for (int i = 0; i < orderByFields.length; i++) {
9061                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9062                                    query.append(orderByFields[i]);
9063    
9064                                    if ((i + 1) < orderByFields.length) {
9065                                            if (orderByComparator.isAscending() ^ previous) {
9066                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9067                                            }
9068                                            else {
9069                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9070                                            }
9071                                    }
9072                                    else {
9073                                            if (orderByComparator.isAscending() ^ previous) {
9074                                                    query.append(ORDER_BY_ASC);
9075                                            }
9076                                            else {
9077                                                    query.append(ORDER_BY_DESC);
9078                                            }
9079                                    }
9080                            }
9081                    }
9082                    else {
9083                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9084                    }
9085    
9086                    String sql = query.toString();
9087    
9088                    Query q = session.createQuery(sql);
9089    
9090                    q.setFirstResult(0);
9091                    q.setMaxResults(2);
9092    
9093                    QueryPos qPos = QueryPos.getInstance(q);
9094    
9095                    qPos.add(groupId);
9096    
9097                    qPos.add(userId);
9098    
9099                    if (bindDisplayDate) {
9100                            qPos.add(new Timestamp(displayDate.getTime()));
9101                    }
9102    
9103                    if (orderByComparator != null) {
9104                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9105    
9106                            for (Object value : values) {
9107                                    qPos.add(value);
9108                            }
9109                    }
9110    
9111                    List<BlogsEntry> list = q.list();
9112    
9113                    if (list.size() == 2) {
9114                            return list.get(1);
9115                    }
9116                    else {
9117                            return null;
9118                    }
9119            }
9120    
9121            /**
9122             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9123             *
9124             * @param groupId the group ID
9125             * @param userId the user ID
9126             * @param displayDate the display date
9127             * @return the matching blogs entries that the user has permission to view
9128             */
9129            @Override
9130            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9131                    Date displayDate) {
9132                    return filterFindByG_U_LtD(groupId, userId, displayDate,
9133                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9134            }
9135    
9136            /**
9137             * 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;.
9138             *
9139             * <p>
9140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9141             * </p>
9142             *
9143             * @param groupId the group ID
9144             * @param userId the user ID
9145             * @param displayDate the display date
9146             * @param start the lower bound of the range of blogs entries
9147             * @param end the upper bound of the range of blogs entries (not inclusive)
9148             * @return the range of matching blogs entries that the user has permission to view
9149             */
9150            @Override
9151            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9152                    Date displayDate, int start, int end) {
9153                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
9154                            null);
9155            }
9156    
9157            /**
9158             * 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;.
9159             *
9160             * <p>
9161             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9162             * </p>
9163             *
9164             * @param groupId the group ID
9165             * @param userId the user ID
9166             * @param displayDate the display date
9167             * @param start the lower bound of the range of blogs entries
9168             * @param end the upper bound of the range of blogs entries (not inclusive)
9169             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9170             * @return the ordered range of matching blogs entries that the user has permission to view
9171             */
9172            @Override
9173            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9174                    Date displayDate, int start, int end,
9175                    OrderByComparator<BlogsEntry> orderByComparator) {
9176                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9177                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
9178                                    orderByComparator);
9179                    }
9180    
9181                    StringBundler query = null;
9182    
9183                    if (orderByComparator != null) {
9184                            query = new StringBundler(5 +
9185                                            (orderByComparator.getOrderByFields().length * 3));
9186                    }
9187                    else {
9188                            query = new StringBundler(5);
9189                    }
9190    
9191                    if (getDB().isSupportsInlineDistinct()) {
9192                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9193                    }
9194                    else {
9195                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9196                    }
9197    
9198                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9199    
9200                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9201    
9202                    boolean bindDisplayDate = false;
9203    
9204                    if (displayDate == null) {
9205                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9206                    }
9207                    else {
9208                            bindDisplayDate = true;
9209    
9210                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9211                    }
9212    
9213                    if (!getDB().isSupportsInlineDistinct()) {
9214                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9215                    }
9216    
9217                    if (orderByComparator != null) {
9218                            if (getDB().isSupportsInlineDistinct()) {
9219                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9220                                            orderByComparator, true);
9221                            }
9222                            else {
9223                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9224                                            orderByComparator, true);
9225                            }
9226                    }
9227                    else {
9228                            if (getDB().isSupportsInlineDistinct()) {
9229                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9230                            }
9231                            else {
9232                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9233                            }
9234                    }
9235    
9236                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9237                                    BlogsEntry.class.getName(),
9238                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9239    
9240                    Session session = null;
9241    
9242                    try {
9243                            session = openSession();
9244    
9245                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9246    
9247                            if (getDB().isSupportsInlineDistinct()) {
9248                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9249                            }
9250                            else {
9251                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9252                            }
9253    
9254                            QueryPos qPos = QueryPos.getInstance(q);
9255    
9256                            qPos.add(groupId);
9257    
9258                            qPos.add(userId);
9259    
9260                            if (bindDisplayDate) {
9261                                    qPos.add(new Timestamp(displayDate.getTime()));
9262                            }
9263    
9264                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9265                    }
9266                    catch (Exception e) {
9267                            throw processException(e);
9268                    }
9269                    finally {
9270                            closeSession(session);
9271                    }
9272            }
9273    
9274            /**
9275             * 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;.
9276             *
9277             * @param entryId the primary key of the current blogs entry
9278             * @param groupId the group ID
9279             * @param userId the user ID
9280             * @param displayDate the display date
9281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9282             * @return the previous, current, and next blogs entry
9283             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9284             */
9285            @Override
9286            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
9287                    long groupId, long userId, Date displayDate,
9288                    OrderByComparator<BlogsEntry> orderByComparator)
9289                    throws NoSuchEntryException {
9290                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9291                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
9292                                    displayDate, orderByComparator);
9293                    }
9294    
9295                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9296    
9297                    Session session = null;
9298    
9299                    try {
9300                            session = openSession();
9301    
9302                            BlogsEntry[] array = new BlogsEntryImpl[3];
9303    
9304                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9305                                            groupId, userId, displayDate, orderByComparator, true);
9306    
9307                            array[1] = blogsEntry;
9308    
9309                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9310                                            groupId, userId, displayDate, orderByComparator, false);
9311    
9312                            return array;
9313                    }
9314                    catch (Exception e) {
9315                            throw processException(e);
9316                    }
9317                    finally {
9318                            closeSession(session);
9319                    }
9320            }
9321    
9322            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
9323                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9324                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9325                    StringBundler query = null;
9326    
9327                    if (orderByComparator != null) {
9328                            query = new StringBundler(6 +
9329                                            (orderByComparator.getOrderByFields().length * 6));
9330                    }
9331                    else {
9332                            query = new StringBundler(3);
9333                    }
9334    
9335                    if (getDB().isSupportsInlineDistinct()) {
9336                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9337                    }
9338                    else {
9339                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9340                    }
9341    
9342                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9343    
9344                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9345    
9346                    boolean bindDisplayDate = false;
9347    
9348                    if (displayDate == null) {
9349                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9350                    }
9351                    else {
9352                            bindDisplayDate = true;
9353    
9354                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9355                    }
9356    
9357                    if (!getDB().isSupportsInlineDistinct()) {
9358                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9359                    }
9360    
9361                    if (orderByComparator != null) {
9362                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9363    
9364                            if (orderByConditionFields.length > 0) {
9365                                    query.append(WHERE_AND);
9366                            }
9367    
9368                            for (int i = 0; i < orderByConditionFields.length; i++) {
9369                                    if (getDB().isSupportsInlineDistinct()) {
9370                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9371                                    }
9372                                    else {
9373                                            query.append(_ORDER_BY_ENTITY_TABLE);
9374                                    }
9375    
9376                                    query.append(orderByConditionFields[i]);
9377    
9378                                    if ((i + 1) < orderByConditionFields.length) {
9379                                            if (orderByComparator.isAscending() ^ previous) {
9380                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9381                                            }
9382                                            else {
9383                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9384                                            }
9385                                    }
9386                                    else {
9387                                            if (orderByComparator.isAscending() ^ previous) {
9388                                                    query.append(WHERE_GREATER_THAN);
9389                                            }
9390                                            else {
9391                                                    query.append(WHERE_LESSER_THAN);
9392                                            }
9393                                    }
9394                            }
9395    
9396                            query.append(ORDER_BY_CLAUSE);
9397    
9398                            String[] orderByFields = orderByComparator.getOrderByFields();
9399    
9400                            for (int i = 0; i < orderByFields.length; i++) {
9401                                    if (getDB().isSupportsInlineDistinct()) {
9402                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9403                                    }
9404                                    else {
9405                                            query.append(_ORDER_BY_ENTITY_TABLE);
9406                                    }
9407    
9408                                    query.append(orderByFields[i]);
9409    
9410                                    if ((i + 1) < orderByFields.length) {
9411                                            if (orderByComparator.isAscending() ^ previous) {
9412                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9413                                            }
9414                                            else {
9415                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9416                                            }
9417                                    }
9418                                    else {
9419                                            if (orderByComparator.isAscending() ^ previous) {
9420                                                    query.append(ORDER_BY_ASC);
9421                                            }
9422                                            else {
9423                                                    query.append(ORDER_BY_DESC);
9424                                            }
9425                                    }
9426                            }
9427                    }
9428                    else {
9429                            if (getDB().isSupportsInlineDistinct()) {
9430                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9431                            }
9432                            else {
9433                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9434                            }
9435                    }
9436    
9437                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9438                                    BlogsEntry.class.getName(),
9439                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9440    
9441                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9442    
9443                    q.setFirstResult(0);
9444                    q.setMaxResults(2);
9445    
9446                    if (getDB().isSupportsInlineDistinct()) {
9447                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9448                    }
9449                    else {
9450                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9451                    }
9452    
9453                    QueryPos qPos = QueryPos.getInstance(q);
9454    
9455                    qPos.add(groupId);
9456    
9457                    qPos.add(userId);
9458    
9459                    if (bindDisplayDate) {
9460                            qPos.add(new Timestamp(displayDate.getTime()));
9461                    }
9462    
9463                    if (orderByComparator != null) {
9464                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9465    
9466                            for (Object value : values) {
9467                                    qPos.add(value);
9468                            }
9469                    }
9470    
9471                    List<BlogsEntry> list = q.list();
9472    
9473                    if (list.size() == 2) {
9474                            return list.get(1);
9475                    }
9476                    else {
9477                            return null;
9478                    }
9479            }
9480    
9481            /**
9482             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9483             *
9484             * @param groupId the group ID
9485             * @param userId the user ID
9486             * @param displayDate the display date
9487             */
9488            @Override
9489            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9490                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9491                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9492                            remove(blogsEntry);
9493                    }
9494            }
9495    
9496            /**
9497             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9498             *
9499             * @param groupId the group ID
9500             * @param userId the user ID
9501             * @param displayDate the display date
9502             * @return the number of matching blogs entries
9503             */
9504            @Override
9505            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9506                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9507    
9508                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9509    
9510                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9511    
9512                    if (count == null) {
9513                            StringBundler query = new StringBundler(4);
9514    
9515                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9516    
9517                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9518    
9519                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9520    
9521                            boolean bindDisplayDate = false;
9522    
9523                            if (displayDate == null) {
9524                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9525                            }
9526                            else {
9527                                    bindDisplayDate = true;
9528    
9529                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9530                            }
9531    
9532                            String sql = query.toString();
9533    
9534                            Session session = null;
9535    
9536                            try {
9537                                    session = openSession();
9538    
9539                                    Query q = session.createQuery(sql);
9540    
9541                                    QueryPos qPos = QueryPos.getInstance(q);
9542    
9543                                    qPos.add(groupId);
9544    
9545                                    qPos.add(userId);
9546    
9547                                    if (bindDisplayDate) {
9548                                            qPos.add(new Timestamp(displayDate.getTime()));
9549                                    }
9550    
9551                                    count = (Long)q.uniqueResult();
9552    
9553                                    finderCache.putResult(finderPath, finderArgs, count);
9554                            }
9555                            catch (Exception e) {
9556                                    finderCache.removeResult(finderPath, finderArgs);
9557    
9558                                    throw processException(e);
9559                            }
9560                            finally {
9561                                    closeSession(session);
9562                            }
9563                    }
9564    
9565                    return count.intValue();
9566            }
9567    
9568            /**
9569             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9570             *
9571             * @param groupId the group ID
9572             * @param userId the user ID
9573             * @param displayDate the display date
9574             * @return the number of matching blogs entries that the user has permission to view
9575             */
9576            @Override
9577            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9578                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9579                            return countByG_U_LtD(groupId, userId, displayDate);
9580                    }
9581    
9582                    StringBundler query = new StringBundler(4);
9583    
9584                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9585    
9586                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9587    
9588                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9589    
9590                    boolean bindDisplayDate = false;
9591    
9592                    if (displayDate == null) {
9593                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9594                    }
9595                    else {
9596                            bindDisplayDate = true;
9597    
9598                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9599                    }
9600    
9601                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9602                                    BlogsEntry.class.getName(),
9603                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9604    
9605                    Session session = null;
9606    
9607                    try {
9608                            session = openSession();
9609    
9610                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9611    
9612                            q.addScalar(COUNT_COLUMN_NAME,
9613                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9614    
9615                            QueryPos qPos = QueryPos.getInstance(q);
9616    
9617                            qPos.add(groupId);
9618    
9619                            qPos.add(userId);
9620    
9621                            if (bindDisplayDate) {
9622                                    qPos.add(new Timestamp(displayDate.getTime()));
9623                            }
9624    
9625                            Long count = (Long)q.uniqueResult();
9626    
9627                            return count.intValue();
9628                    }
9629                    catch (Exception e) {
9630                            throw processException(e);
9631                    }
9632                    finally {
9633                            closeSession(session);
9634                    }
9635            }
9636    
9637            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9638            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9639            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
9640            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9641            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9642                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9643                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9644                            new String[] {
9645                                    Long.class.getName(), Long.class.getName(),
9646                                    Integer.class.getName(),
9647                                    
9648                            Integer.class.getName(), Integer.class.getName(),
9649                                    OrderByComparator.class.getName()
9650                            });
9651            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9652                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9653                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9654                            new String[] {
9655                                    Long.class.getName(), Long.class.getName(),
9656                                    Integer.class.getName()
9657                            },
9658                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9659                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9660                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9661                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9662                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9663            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9664                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9665                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9666                            new String[] {
9667                                    Long.class.getName(), Long.class.getName(),
9668                                    Integer.class.getName()
9669                            });
9670    
9671            /**
9672             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9673             *
9674             * @param groupId the group ID
9675             * @param userId the user ID
9676             * @param status the status
9677             * @return the matching blogs entries
9678             */
9679            @Override
9680            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9681                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9682                            QueryUtil.ALL_POS, null);
9683            }
9684    
9685            /**
9686             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9687             *
9688             * <p>
9689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9690             * </p>
9691             *
9692             * @param groupId the group ID
9693             * @param userId the user ID
9694             * @param status the status
9695             * @param start the lower bound of the range of blogs entries
9696             * @param end the upper bound of the range of blogs entries (not inclusive)
9697             * @return the range of matching blogs entries
9698             */
9699            @Override
9700            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9701                    int start, int end) {
9702                    return findByG_U_S(groupId, userId, status, start, end, null);
9703            }
9704    
9705            /**
9706             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9707             *
9708             * <p>
9709             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9710             * </p>
9711             *
9712             * @param groupId the group ID
9713             * @param userId the user ID
9714             * @param status the status
9715             * @param start the lower bound of the range of blogs entries
9716             * @param end the upper bound of the range of blogs entries (not inclusive)
9717             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9718             * @return the ordered range of matching blogs entries
9719             */
9720            @Override
9721            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9722                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9723                    return findByG_U_S(groupId, userId, status, start, end,
9724                            orderByComparator, true);
9725            }
9726    
9727            /**
9728             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9729             *
9730             * <p>
9731             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9732             * </p>
9733             *
9734             * @param groupId the group ID
9735             * @param userId the user ID
9736             * @param status the status
9737             * @param start the lower bound of the range of blogs entries
9738             * @param end the upper bound of the range of blogs entries (not inclusive)
9739             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9740             * @param retrieveFromCache whether to retrieve from the finder cache
9741             * @return the ordered range of matching blogs entries
9742             */
9743            @Override
9744            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9745                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
9746                    boolean retrieveFromCache) {
9747                    boolean pagination = true;
9748                    FinderPath finderPath = null;
9749                    Object[] finderArgs = null;
9750    
9751                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9752                                    (orderByComparator == null)) {
9753                            pagination = false;
9754                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9755                            finderArgs = new Object[] { groupId, userId, status };
9756                    }
9757                    else {
9758                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9759                            finderArgs = new Object[] {
9760                                            groupId, userId, status,
9761                                            
9762                                            start, end, orderByComparator
9763                                    };
9764                    }
9765    
9766                    List<BlogsEntry> list = null;
9767    
9768                    if (retrieveFromCache) {
9769                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
9770                                            finderArgs, this);
9771    
9772                            if ((list != null) && !list.isEmpty()) {
9773                                    for (BlogsEntry blogsEntry : list) {
9774                                            if ((groupId != blogsEntry.getGroupId()) ||
9775                                                            (userId != blogsEntry.getUserId()) ||
9776                                                            (status != blogsEntry.getStatus())) {
9777                                                    list = null;
9778    
9779                                                    break;
9780                                            }
9781                                    }
9782                            }
9783                    }
9784    
9785                    if (list == null) {
9786                            StringBundler query = null;
9787    
9788                            if (orderByComparator != null) {
9789                                    query = new StringBundler(5 +
9790                                                    (orderByComparator.getOrderByFields().length * 3));
9791                            }
9792                            else {
9793                                    query = new StringBundler(5);
9794                            }
9795    
9796                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9797    
9798                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9799    
9800                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9801    
9802                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9803    
9804                            if (orderByComparator != null) {
9805                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9806                                            orderByComparator);
9807                            }
9808                            else
9809                             if (pagination) {
9810                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9811                            }
9812    
9813                            String sql = query.toString();
9814    
9815                            Session session = null;
9816    
9817                            try {
9818                                    session = openSession();
9819    
9820                                    Query q = session.createQuery(sql);
9821    
9822                                    QueryPos qPos = QueryPos.getInstance(q);
9823    
9824                                    qPos.add(groupId);
9825    
9826                                    qPos.add(userId);
9827    
9828                                    qPos.add(status);
9829    
9830                                    if (!pagination) {
9831                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9832                                                            start, end, false);
9833    
9834                                            Collections.sort(list);
9835    
9836                                            list = Collections.unmodifiableList(list);
9837                                    }
9838                                    else {
9839                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9840                                                            start, end);
9841                                    }
9842    
9843                                    cacheResult(list);
9844    
9845                                    finderCache.putResult(finderPath, finderArgs, list);
9846                            }
9847                            catch (Exception e) {
9848                                    finderCache.removeResult(finderPath, finderArgs);
9849    
9850                                    throw processException(e);
9851                            }
9852                            finally {
9853                                    closeSession(session);
9854                            }
9855                    }
9856    
9857                    return list;
9858            }
9859    
9860            /**
9861             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9862             *
9863             * @param groupId the group ID
9864             * @param userId the user ID
9865             * @param status the status
9866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9867             * @return the first matching blogs entry
9868             * @throws NoSuchEntryException if a matching blogs entry could not be found
9869             */
9870            @Override
9871            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9872                    OrderByComparator<BlogsEntry> orderByComparator)
9873                    throws NoSuchEntryException {
9874                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9875                                    orderByComparator);
9876    
9877                    if (blogsEntry != null) {
9878                            return blogsEntry;
9879                    }
9880    
9881                    StringBundler msg = new StringBundler(8);
9882    
9883                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9884    
9885                    msg.append("groupId=");
9886                    msg.append(groupId);
9887    
9888                    msg.append(", userId=");
9889                    msg.append(userId);
9890    
9891                    msg.append(", status=");
9892                    msg.append(status);
9893    
9894                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9895    
9896                    throw new NoSuchEntryException(msg.toString());
9897            }
9898    
9899            /**
9900             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9901             *
9902             * @param groupId the group ID
9903             * @param userId the user ID
9904             * @param status the status
9905             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9906             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9907             */
9908            @Override
9909            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9910                    OrderByComparator<BlogsEntry> orderByComparator) {
9911                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9912                                    orderByComparator);
9913    
9914                    if (!list.isEmpty()) {
9915                            return list.get(0);
9916                    }
9917    
9918                    return null;
9919            }
9920    
9921            /**
9922             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9923             *
9924             * @param groupId the group ID
9925             * @param userId the user ID
9926             * @param status the status
9927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9928             * @return the last matching blogs entry
9929             * @throws NoSuchEntryException if a matching blogs entry could not be found
9930             */
9931            @Override
9932            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9933                    OrderByComparator<BlogsEntry> orderByComparator)
9934                    throws NoSuchEntryException {
9935                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9936                                    orderByComparator);
9937    
9938                    if (blogsEntry != null) {
9939                            return blogsEntry;
9940                    }
9941    
9942                    StringBundler msg = new StringBundler(8);
9943    
9944                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9945    
9946                    msg.append("groupId=");
9947                    msg.append(groupId);
9948    
9949                    msg.append(", userId=");
9950                    msg.append(userId);
9951    
9952                    msg.append(", status=");
9953                    msg.append(status);
9954    
9955                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9956    
9957                    throw new NoSuchEntryException(msg.toString());
9958            }
9959    
9960            /**
9961             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9962             *
9963             * @param groupId the group ID
9964             * @param userId the user ID
9965             * @param status the status
9966             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9967             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9968             */
9969            @Override
9970            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
9971                    OrderByComparator<BlogsEntry> orderByComparator) {
9972                    int count = countByG_U_S(groupId, userId, status);
9973    
9974                    if (count == 0) {
9975                            return null;
9976                    }
9977    
9978                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
9979                                    count, orderByComparator);
9980    
9981                    if (!list.isEmpty()) {
9982                            return list.get(0);
9983                    }
9984    
9985                    return null;
9986            }
9987    
9988            /**
9989             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9990             *
9991             * @param entryId the primary key of the current blogs entry
9992             * @param groupId the group ID
9993             * @param userId the user ID
9994             * @param status the status
9995             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9996             * @return the previous, current, and next blogs entry
9997             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9998             */
9999            @Override
10000            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
10001                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10002                    throws NoSuchEntryException {
10003                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10004    
10005                    Session session = null;
10006    
10007                    try {
10008                            session = openSession();
10009    
10010                            BlogsEntry[] array = new BlogsEntryImpl[3];
10011    
10012                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10013                                            userId, status, orderByComparator, true);
10014    
10015                            array[1] = blogsEntry;
10016    
10017                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10018                                            userId, status, orderByComparator, false);
10019    
10020                            return array;
10021                    }
10022                    catch (Exception e) {
10023                            throw processException(e);
10024                    }
10025                    finally {
10026                            closeSession(session);
10027                    }
10028            }
10029    
10030            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
10031                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10032                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10033                    StringBundler query = null;
10034    
10035                    if (orderByComparator != null) {
10036                            query = new StringBundler(6 +
10037                                            (orderByComparator.getOrderByFields().length * 6));
10038                    }
10039                    else {
10040                            query = new StringBundler(3);
10041                    }
10042    
10043                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10044    
10045                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10046    
10047                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10048    
10049                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10050    
10051                    if (orderByComparator != null) {
10052                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10053    
10054                            if (orderByConditionFields.length > 0) {
10055                                    query.append(WHERE_AND);
10056                            }
10057    
10058                            for (int i = 0; i < orderByConditionFields.length; i++) {
10059                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10060                                    query.append(orderByConditionFields[i]);
10061    
10062                                    if ((i + 1) < orderByConditionFields.length) {
10063                                            if (orderByComparator.isAscending() ^ previous) {
10064                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10065                                            }
10066                                            else {
10067                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10068                                            }
10069                                    }
10070                                    else {
10071                                            if (orderByComparator.isAscending() ^ previous) {
10072                                                    query.append(WHERE_GREATER_THAN);
10073                                            }
10074                                            else {
10075                                                    query.append(WHERE_LESSER_THAN);
10076                                            }
10077                                    }
10078                            }
10079    
10080                            query.append(ORDER_BY_CLAUSE);
10081    
10082                            String[] orderByFields = orderByComparator.getOrderByFields();
10083    
10084                            for (int i = 0; i < orderByFields.length; i++) {
10085                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10086                                    query.append(orderByFields[i]);
10087    
10088                                    if ((i + 1) < orderByFields.length) {
10089                                            if (orderByComparator.isAscending() ^ previous) {
10090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10091                                            }
10092                                            else {
10093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10094                                            }
10095                                    }
10096                                    else {
10097                                            if (orderByComparator.isAscending() ^ previous) {
10098                                                    query.append(ORDER_BY_ASC);
10099                                            }
10100                                            else {
10101                                                    query.append(ORDER_BY_DESC);
10102                                            }
10103                                    }
10104                            }
10105                    }
10106                    else {
10107                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10108                    }
10109    
10110                    String sql = query.toString();
10111    
10112                    Query q = session.createQuery(sql);
10113    
10114                    q.setFirstResult(0);
10115                    q.setMaxResults(2);
10116    
10117                    QueryPos qPos = QueryPos.getInstance(q);
10118    
10119                    qPos.add(groupId);
10120    
10121                    qPos.add(userId);
10122    
10123                    qPos.add(status);
10124    
10125                    if (orderByComparator != null) {
10126                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10127    
10128                            for (Object value : values) {
10129                                    qPos.add(value);
10130                            }
10131                    }
10132    
10133                    List<BlogsEntry> list = q.list();
10134    
10135                    if (list.size() == 2) {
10136                            return list.get(1);
10137                    }
10138                    else {
10139                            return null;
10140                    }
10141            }
10142    
10143            /**
10144             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10145             *
10146             * @param groupId the group ID
10147             * @param userId the user ID
10148             * @param status the status
10149             * @return the matching blogs entries that the user has permission to view
10150             */
10151            @Override
10152            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10153                    int status) {
10154                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
10155                            QueryUtil.ALL_POS, null);
10156            }
10157    
10158            /**
10159             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10160             *
10161             * <p>
10162             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10163             * </p>
10164             *
10165             * @param groupId the group ID
10166             * @param userId the user ID
10167             * @param status the status
10168             * @param start the lower bound of the range of blogs entries
10169             * @param end the upper bound of the range of blogs entries (not inclusive)
10170             * @return the range of matching blogs entries that the user has permission to view
10171             */
10172            @Override
10173            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10174                    int status, int start, int end) {
10175                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
10176            }
10177    
10178            /**
10179             * 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;.
10180             *
10181             * <p>
10182             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10183             * </p>
10184             *
10185             * @param groupId the group ID
10186             * @param userId the user ID
10187             * @param status the status
10188             * @param start the lower bound of the range of blogs entries
10189             * @param end the upper bound of the range of blogs entries (not inclusive)
10190             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10191             * @return the ordered range of matching blogs entries that the user has permission to view
10192             */
10193            @Override
10194            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10195                    int status, int start, int end,
10196                    OrderByComparator<BlogsEntry> orderByComparator) {
10197                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10198                            return findByG_U_S(groupId, userId, status, start, end,
10199                                    orderByComparator);
10200                    }
10201    
10202                    StringBundler query = null;
10203    
10204                    if (orderByComparator != null) {
10205                            query = new StringBundler(5 +
10206                                            (orderByComparator.getOrderByFields().length * 3));
10207                    }
10208                    else {
10209                            query = new StringBundler(5);
10210                    }
10211    
10212                    if (getDB().isSupportsInlineDistinct()) {
10213                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10214                    }
10215                    else {
10216                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10217                    }
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                    if (!getDB().isSupportsInlineDistinct()) {
10226                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10227                    }
10228    
10229                    if (orderByComparator != null) {
10230                            if (getDB().isSupportsInlineDistinct()) {
10231                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10232                                            orderByComparator, true);
10233                            }
10234                            else {
10235                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10236                                            orderByComparator, true);
10237                            }
10238                    }
10239                    else {
10240                            if (getDB().isSupportsInlineDistinct()) {
10241                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10242                            }
10243                            else {
10244                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10245                            }
10246                    }
10247    
10248                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10249                                    BlogsEntry.class.getName(),
10250                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10251    
10252                    Session session = null;
10253    
10254                    try {
10255                            session = openSession();
10256    
10257                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10258    
10259                            if (getDB().isSupportsInlineDistinct()) {
10260                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10261                            }
10262                            else {
10263                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10264                            }
10265    
10266                            QueryPos qPos = QueryPos.getInstance(q);
10267    
10268                            qPos.add(groupId);
10269    
10270                            qPos.add(userId);
10271    
10272                            qPos.add(status);
10273    
10274                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10275                    }
10276                    catch (Exception e) {
10277                            throw processException(e);
10278                    }
10279                    finally {
10280                            closeSession(session);
10281                    }
10282            }
10283    
10284            /**
10285             * 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;.
10286             *
10287             * @param entryId the primary key of the current blogs entry
10288             * @param groupId the group ID
10289             * @param userId the user ID
10290             * @param status the status
10291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10292             * @return the previous, current, and next blogs entry
10293             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10294             */
10295            @Override
10296            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
10297                    long groupId, long userId, int status,
10298                    OrderByComparator<BlogsEntry> orderByComparator)
10299                    throws NoSuchEntryException {
10300                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10301                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
10302                                    orderByComparator);
10303                    }
10304    
10305                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10306    
10307                    Session session = null;
10308    
10309                    try {
10310                            session = openSession();
10311    
10312                            BlogsEntry[] array = new BlogsEntryImpl[3];
10313    
10314                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10315                                            groupId, userId, status, orderByComparator, true);
10316    
10317                            array[1] = blogsEntry;
10318    
10319                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10320                                            groupId, userId, status, orderByComparator, false);
10321    
10322                            return array;
10323                    }
10324                    catch (Exception e) {
10325                            throw processException(e);
10326                    }
10327                    finally {
10328                            closeSession(session);
10329                    }
10330            }
10331    
10332            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
10333                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10334                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10335                    StringBundler query = null;
10336    
10337                    if (orderByComparator != null) {
10338                            query = new StringBundler(6 +
10339                                            (orderByComparator.getOrderByFields().length * 6));
10340                    }
10341                    else {
10342                            query = new StringBundler(3);
10343                    }
10344    
10345                    if (getDB().isSupportsInlineDistinct()) {
10346                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10347                    }
10348                    else {
10349                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10350                    }
10351    
10352                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10353    
10354                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10355    
10356                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10357    
10358                    if (!getDB().isSupportsInlineDistinct()) {
10359                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10360                    }
10361    
10362                    if (orderByComparator != null) {
10363                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10364    
10365                            if (orderByConditionFields.length > 0) {
10366                                    query.append(WHERE_AND);
10367                            }
10368    
10369                            for (int i = 0; i < orderByConditionFields.length; i++) {
10370                                    if (getDB().isSupportsInlineDistinct()) {
10371                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10372                                    }
10373                                    else {
10374                                            query.append(_ORDER_BY_ENTITY_TABLE);
10375                                    }
10376    
10377                                    query.append(orderByConditionFields[i]);
10378    
10379                                    if ((i + 1) < orderByConditionFields.length) {
10380                                            if (orderByComparator.isAscending() ^ previous) {
10381                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10382                                            }
10383                                            else {
10384                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10385                                            }
10386                                    }
10387                                    else {
10388                                            if (orderByComparator.isAscending() ^ previous) {
10389                                                    query.append(WHERE_GREATER_THAN);
10390                                            }
10391                                            else {
10392                                                    query.append(WHERE_LESSER_THAN);
10393                                            }
10394                                    }
10395                            }
10396    
10397                            query.append(ORDER_BY_CLAUSE);
10398    
10399                            String[] orderByFields = orderByComparator.getOrderByFields();
10400    
10401                            for (int i = 0; i < orderByFields.length; i++) {
10402                                    if (getDB().isSupportsInlineDistinct()) {
10403                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10404                                    }
10405                                    else {
10406                                            query.append(_ORDER_BY_ENTITY_TABLE);
10407                                    }
10408    
10409                                    query.append(orderByFields[i]);
10410    
10411                                    if ((i + 1) < orderByFields.length) {
10412                                            if (orderByComparator.isAscending() ^ previous) {
10413                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10414                                            }
10415                                            else {
10416                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10417                                            }
10418                                    }
10419                                    else {
10420                                            if (orderByComparator.isAscending() ^ previous) {
10421                                                    query.append(ORDER_BY_ASC);
10422                                            }
10423                                            else {
10424                                                    query.append(ORDER_BY_DESC);
10425                                            }
10426                                    }
10427                            }
10428                    }
10429                    else {
10430                            if (getDB().isSupportsInlineDistinct()) {
10431                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10432                            }
10433                            else {
10434                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10435                            }
10436                    }
10437    
10438                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10439                                    BlogsEntry.class.getName(),
10440                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10441    
10442                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10443    
10444                    q.setFirstResult(0);
10445                    q.setMaxResults(2);
10446    
10447                    if (getDB().isSupportsInlineDistinct()) {
10448                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10449                    }
10450                    else {
10451                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10452                    }
10453    
10454                    QueryPos qPos = QueryPos.getInstance(q);
10455    
10456                    qPos.add(groupId);
10457    
10458                    qPos.add(userId);
10459    
10460                    qPos.add(status);
10461    
10462                    if (orderByComparator != null) {
10463                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10464    
10465                            for (Object value : values) {
10466                                    qPos.add(value);
10467                            }
10468                    }
10469    
10470                    List<BlogsEntry> list = q.list();
10471    
10472                    if (list.size() == 2) {
10473                            return list.get(1);
10474                    }
10475                    else {
10476                            return null;
10477                    }
10478            }
10479    
10480            /**
10481             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10482             *
10483             * @param groupId the group ID
10484             * @param userId the user ID
10485             * @param status the status
10486             */
10487            @Override
10488            public void removeByG_U_S(long groupId, long userId, int status) {
10489                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10490                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10491                            remove(blogsEntry);
10492                    }
10493            }
10494    
10495            /**
10496             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10497             *
10498             * @param groupId the group ID
10499             * @param userId the user ID
10500             * @param status the status
10501             * @return the number of matching blogs entries
10502             */
10503            @Override
10504            public int countByG_U_S(long groupId, long userId, int status) {
10505                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10506    
10507                    Object[] finderArgs = new Object[] { groupId, userId, status };
10508    
10509                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10510    
10511                    if (count == null) {
10512                            StringBundler query = new StringBundler(4);
10513    
10514                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10515    
10516                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10517    
10518                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10519    
10520                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10521    
10522                            String sql = query.toString();
10523    
10524                            Session session = null;
10525    
10526                            try {
10527                                    session = openSession();
10528    
10529                                    Query q = session.createQuery(sql);
10530    
10531                                    QueryPos qPos = QueryPos.getInstance(q);
10532    
10533                                    qPos.add(groupId);
10534    
10535                                    qPos.add(userId);
10536    
10537                                    qPos.add(status);
10538    
10539                                    count = (Long)q.uniqueResult();
10540    
10541                                    finderCache.putResult(finderPath, finderArgs, count);
10542                            }
10543                            catch (Exception e) {
10544                                    finderCache.removeResult(finderPath, finderArgs);
10545    
10546                                    throw processException(e);
10547                            }
10548                            finally {
10549                                    closeSession(session);
10550                            }
10551                    }
10552    
10553                    return count.intValue();
10554            }
10555    
10556            /**
10557             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10558             *
10559             * @param groupId the group ID
10560             * @param userId the user ID
10561             * @param status the status
10562             * @return the number of matching blogs entries that the user has permission to view
10563             */
10564            @Override
10565            public int filterCountByG_U_S(long groupId, long userId, int status) {
10566                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10567                            return countByG_U_S(groupId, userId, status);
10568                    }
10569    
10570                    StringBundler query = new StringBundler(4);
10571    
10572                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
10573    
10574                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10575    
10576                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10577    
10578                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10579    
10580                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10581                                    BlogsEntry.class.getName(),
10582                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10583    
10584                    Session session = null;
10585    
10586                    try {
10587                            session = openSession();
10588    
10589                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10590    
10591                            q.addScalar(COUNT_COLUMN_NAME,
10592                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10593    
10594                            QueryPos qPos = QueryPos.getInstance(q);
10595    
10596                            qPos.add(groupId);
10597    
10598                            qPos.add(userId);
10599    
10600                            qPos.add(status);
10601    
10602                            Long count = (Long)q.uniqueResult();
10603    
10604                            return count.intValue();
10605                    }
10606                    catch (Exception e) {
10607                            throw processException(e);
10608                    }
10609                    finally {
10610                            closeSession(session);
10611                    }
10612            }
10613    
10614            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
10615            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
10616            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
10617            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10618                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10619                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
10620                            new String[] {
10621                                    Long.class.getName(), Long.class.getName(),
10622                                    Integer.class.getName(),
10623                                    
10624                            Integer.class.getName(), Integer.class.getName(),
10625                                    OrderByComparator.class.getName()
10626                            });
10627            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
10628                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10629                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10630                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
10631                            new String[] {
10632                                    Long.class.getName(), Long.class.getName(),
10633                                    Integer.class.getName()
10634                            });
10635    
10636            /**
10637             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10638             *
10639             * @param groupId the group ID
10640             * @param userId the user ID
10641             * @param status the status
10642             * @return the matching blogs entries
10643             */
10644            @Override
10645            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
10646                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
10647                            QueryUtil.ALL_POS, null);
10648            }
10649    
10650            /**
10651             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10652             *
10653             * <p>
10654             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10655             * </p>
10656             *
10657             * @param groupId the group ID
10658             * @param userId the user ID
10659             * @param status the status
10660             * @param start the lower bound of the range of blogs entries
10661             * @param end the upper bound of the range of blogs entries (not inclusive)
10662             * @return the range of matching blogs entries
10663             */
10664            @Override
10665            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10666                    int status, int start, int end) {
10667                    return findByG_U_NotS(groupId, userId, status, start, end, null);
10668            }
10669    
10670            /**
10671             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10672             *
10673             * <p>
10674             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10675             * </p>
10676             *
10677             * @param groupId the group ID
10678             * @param userId the user ID
10679             * @param status the status
10680             * @param start the lower bound of the range of blogs entries
10681             * @param end the upper bound of the range of blogs entries (not inclusive)
10682             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10683             * @return the ordered range of matching blogs entries
10684             */
10685            @Override
10686            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10687                    int status, int start, int end,
10688                    OrderByComparator<BlogsEntry> orderByComparator) {
10689                    return findByG_U_NotS(groupId, userId, status, start, end,
10690                            orderByComparator, true);
10691            }
10692    
10693            /**
10694             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10695             *
10696             * <p>
10697             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10698             * </p>
10699             *
10700             * @param groupId the group ID
10701             * @param userId the user ID
10702             * @param status the status
10703             * @param start the lower bound of the range of blogs entries
10704             * @param end the upper bound of the range of blogs entries (not inclusive)
10705             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10706             * @param retrieveFromCache whether to retrieve from the finder cache
10707             * @return the ordered range of matching blogs entries
10708             */
10709            @Override
10710            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10711                    int status, int start, int end,
10712                    OrderByComparator<BlogsEntry> orderByComparator,
10713                    boolean retrieveFromCache) {
10714                    boolean pagination = true;
10715                    FinderPath finderPath = null;
10716                    Object[] finderArgs = null;
10717    
10718                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
10719                    finderArgs = new Object[] {
10720                                    groupId, userId, status,
10721                                    
10722                                    start, end, orderByComparator
10723                            };
10724    
10725                    List<BlogsEntry> list = null;
10726    
10727                    if (retrieveFromCache) {
10728                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
10729                                            finderArgs, this);
10730    
10731                            if ((list != null) && !list.isEmpty()) {
10732                                    for (BlogsEntry blogsEntry : list) {
10733                                            if ((groupId != blogsEntry.getGroupId()) ||
10734                                                            (userId != blogsEntry.getUserId()) ||
10735                                                            (status == blogsEntry.getStatus())) {
10736                                                    list = null;
10737    
10738                                                    break;
10739                                            }
10740                                    }
10741                            }
10742                    }
10743    
10744                    if (list == null) {
10745                            StringBundler query = null;
10746    
10747                            if (orderByComparator != null) {
10748                                    query = new StringBundler(5 +
10749                                                    (orderByComparator.getOrderByFields().length * 3));
10750                            }
10751                            else {
10752                                    query = new StringBundler(5);
10753                            }
10754    
10755                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10756    
10757                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10758    
10759                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10760    
10761                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10762    
10763                            if (orderByComparator != null) {
10764                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10765                                            orderByComparator);
10766                            }
10767                            else
10768                             if (pagination) {
10769                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10770                            }
10771    
10772                            String sql = query.toString();
10773    
10774                            Session session = null;
10775    
10776                            try {
10777                                    session = openSession();
10778    
10779                                    Query q = session.createQuery(sql);
10780    
10781                                    QueryPos qPos = QueryPos.getInstance(q);
10782    
10783                                    qPos.add(groupId);
10784    
10785                                    qPos.add(userId);
10786    
10787                                    qPos.add(status);
10788    
10789                                    if (!pagination) {
10790                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10791                                                            start, end, false);
10792    
10793                                            Collections.sort(list);
10794    
10795                                            list = Collections.unmodifiableList(list);
10796                                    }
10797                                    else {
10798                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10799                                                            start, end);
10800                                    }
10801    
10802                                    cacheResult(list);
10803    
10804                                    finderCache.putResult(finderPath, finderArgs, list);
10805                            }
10806                            catch (Exception e) {
10807                                    finderCache.removeResult(finderPath, finderArgs);
10808    
10809                                    throw processException(e);
10810                            }
10811                            finally {
10812                                    closeSession(session);
10813                            }
10814                    }
10815    
10816                    return list;
10817            }
10818    
10819            /**
10820             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10821             *
10822             * @param groupId the group ID
10823             * @param userId the user ID
10824             * @param status the status
10825             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10826             * @return the first matching blogs entry
10827             * @throws NoSuchEntryException if a matching blogs entry could not be found
10828             */
10829            @Override
10830            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
10831                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10832                    throws NoSuchEntryException {
10833                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
10834                                    orderByComparator);
10835    
10836                    if (blogsEntry != null) {
10837                            return blogsEntry;
10838                    }
10839    
10840                    StringBundler msg = new StringBundler(8);
10841    
10842                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10843    
10844                    msg.append("groupId=");
10845                    msg.append(groupId);
10846    
10847                    msg.append(", userId=");
10848                    msg.append(userId);
10849    
10850                    msg.append(", status=");
10851                    msg.append(status);
10852    
10853                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10854    
10855                    throw new NoSuchEntryException(msg.toString());
10856            }
10857    
10858            /**
10859             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10860             *
10861             * @param groupId the group ID
10862             * @param userId the user ID
10863             * @param status the status
10864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10865             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10866             */
10867            @Override
10868            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
10869                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10870                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
10871                                    orderByComparator);
10872    
10873                    if (!list.isEmpty()) {
10874                            return list.get(0);
10875                    }
10876    
10877                    return null;
10878            }
10879    
10880            /**
10881             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10882             *
10883             * @param groupId the group ID
10884             * @param userId the user ID
10885             * @param status the status
10886             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10887             * @return the last matching blogs entry
10888             * @throws NoSuchEntryException if a matching blogs entry could not be found
10889             */
10890            @Override
10891            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
10892                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10893                    throws NoSuchEntryException {
10894                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
10895                                    orderByComparator);
10896    
10897                    if (blogsEntry != null) {
10898                            return blogsEntry;
10899                    }
10900    
10901                    StringBundler msg = new StringBundler(8);
10902    
10903                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10904    
10905                    msg.append("groupId=");
10906                    msg.append(groupId);
10907    
10908                    msg.append(", userId=");
10909                    msg.append(userId);
10910    
10911                    msg.append(", status=");
10912                    msg.append(status);
10913    
10914                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10915    
10916                    throw new NoSuchEntryException(msg.toString());
10917            }
10918    
10919            /**
10920             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10921             *
10922             * @param groupId the group ID
10923             * @param userId the user ID
10924             * @param status the status
10925             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10926             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10927             */
10928            @Override
10929            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
10930                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10931                    int count = countByG_U_NotS(groupId, userId, status);
10932    
10933                    if (count == 0) {
10934                            return null;
10935                    }
10936    
10937                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
10938                                    count - 1, count, orderByComparator);
10939    
10940                    if (!list.isEmpty()) {
10941                            return list.get(0);
10942                    }
10943    
10944                    return null;
10945            }
10946    
10947            /**
10948             * 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;.
10949             *
10950             * @param entryId the primary key of the current blogs entry
10951             * @param groupId the group ID
10952             * @param userId the user ID
10953             * @param status the status
10954             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10955             * @return the previous, current, and next blogs entry
10956             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10957             */
10958            @Override
10959            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
10960                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10961                    throws NoSuchEntryException {
10962                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10963    
10964                    Session session = null;
10965    
10966                    try {
10967                            session = openSession();
10968    
10969                            BlogsEntry[] array = new BlogsEntryImpl[3];
10970    
10971                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10972                                            userId, status, orderByComparator, true);
10973    
10974                            array[1] = blogsEntry;
10975    
10976                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10977                                            userId, status, orderByComparator, false);
10978    
10979                            return array;
10980                    }
10981                    catch (Exception e) {
10982                            throw processException(e);
10983                    }
10984                    finally {
10985                            closeSession(session);
10986                    }
10987            }
10988    
10989            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
10990                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10991                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10992                    StringBundler query = null;
10993    
10994                    if (orderByComparator != null) {
10995                            query = new StringBundler(6 +
10996                                            (orderByComparator.getOrderByFields().length * 6));
10997                    }
10998                    else {
10999                            query = new StringBundler(3);
11000                    }
11001    
11002                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11003    
11004                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11005    
11006                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11007    
11008                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11009    
11010                    if (orderByComparator != null) {
11011                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11012    
11013                            if (orderByConditionFields.length > 0) {
11014                                    query.append(WHERE_AND);
11015                            }
11016    
11017                            for (int i = 0; i < orderByConditionFields.length; i++) {
11018                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11019                                    query.append(orderByConditionFields[i]);
11020    
11021                                    if ((i + 1) < orderByConditionFields.length) {
11022                                            if (orderByComparator.isAscending() ^ previous) {
11023                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11024                                            }
11025                                            else {
11026                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11027                                            }
11028                                    }
11029                                    else {
11030                                            if (orderByComparator.isAscending() ^ previous) {
11031                                                    query.append(WHERE_GREATER_THAN);
11032                                            }
11033                                            else {
11034                                                    query.append(WHERE_LESSER_THAN);
11035                                            }
11036                                    }
11037                            }
11038    
11039                            query.append(ORDER_BY_CLAUSE);
11040    
11041                            String[] orderByFields = orderByComparator.getOrderByFields();
11042    
11043                            for (int i = 0; i < orderByFields.length; i++) {
11044                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11045                                    query.append(orderByFields[i]);
11046    
11047                                    if ((i + 1) < orderByFields.length) {
11048                                            if (orderByComparator.isAscending() ^ previous) {
11049                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11050                                            }
11051                                            else {
11052                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11053                                            }
11054                                    }
11055                                    else {
11056                                            if (orderByComparator.isAscending() ^ previous) {
11057                                                    query.append(ORDER_BY_ASC);
11058                                            }
11059                                            else {
11060                                                    query.append(ORDER_BY_DESC);
11061                                            }
11062                                    }
11063                            }
11064                    }
11065                    else {
11066                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11067                    }
11068    
11069                    String sql = query.toString();
11070    
11071                    Query q = session.createQuery(sql);
11072    
11073                    q.setFirstResult(0);
11074                    q.setMaxResults(2);
11075    
11076                    QueryPos qPos = QueryPos.getInstance(q);
11077    
11078                    qPos.add(groupId);
11079    
11080                    qPos.add(userId);
11081    
11082                    qPos.add(status);
11083    
11084                    if (orderByComparator != null) {
11085                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11086    
11087                            for (Object value : values) {
11088                                    qPos.add(value);
11089                            }
11090                    }
11091    
11092                    List<BlogsEntry> list = q.list();
11093    
11094                    if (list.size() == 2) {
11095                            return list.get(1);
11096                    }
11097                    else {
11098                            return null;
11099                    }
11100            }
11101    
11102            /**
11103             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11104             *
11105             * @param groupId the group ID
11106             * @param userId the user ID
11107             * @param status the status
11108             * @return the matching blogs entries that the user has permission to view
11109             */
11110            @Override
11111            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11112                    int status) {
11113                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11114                            QueryUtil.ALL_POS, null);
11115            }
11116    
11117            /**
11118             * 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;.
11119             *
11120             * <p>
11121             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11122             * </p>
11123             *
11124             * @param groupId the group ID
11125             * @param userId the user ID
11126             * @param status the status
11127             * @param start the lower bound of the range of blogs entries
11128             * @param end the upper bound of the range of blogs entries (not inclusive)
11129             * @return the range of matching blogs entries that the user has permission to view
11130             */
11131            @Override
11132            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11133                    int status, int start, int end) {
11134                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
11135            }
11136    
11137            /**
11138             * 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;.
11139             *
11140             * <p>
11141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11142             * </p>
11143             *
11144             * @param groupId the group ID
11145             * @param userId the user ID
11146             * @param status the status
11147             * @param start the lower bound of the range of blogs entries
11148             * @param end the upper bound of the range of blogs entries (not inclusive)
11149             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11150             * @return the ordered range of matching blogs entries that the user has permission to view
11151             */
11152            @Override
11153            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11154                    int status, int start, int end,
11155                    OrderByComparator<BlogsEntry> orderByComparator) {
11156                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11157                            return findByG_U_NotS(groupId, userId, status, start, end,
11158                                    orderByComparator);
11159                    }
11160    
11161                    StringBundler query = null;
11162    
11163                    if (orderByComparator != null) {
11164                            query = new StringBundler(5 +
11165                                            (orderByComparator.getOrderByFields().length * 3));
11166                    }
11167                    else {
11168                            query = new StringBundler(5);
11169                    }
11170    
11171                    if (getDB().isSupportsInlineDistinct()) {
11172                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11173                    }
11174                    else {
11175                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11176                    }
11177    
11178                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11179    
11180                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11181    
11182                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11183    
11184                    if (!getDB().isSupportsInlineDistinct()) {
11185                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11186                    }
11187    
11188                    if (orderByComparator != null) {
11189                            if (getDB().isSupportsInlineDistinct()) {
11190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11191                                            orderByComparator, true);
11192                            }
11193                            else {
11194                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11195                                            orderByComparator, true);
11196                            }
11197                    }
11198                    else {
11199                            if (getDB().isSupportsInlineDistinct()) {
11200                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11201                            }
11202                            else {
11203                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11204                            }
11205                    }
11206    
11207                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11208                                    BlogsEntry.class.getName(),
11209                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11210    
11211                    Session session = null;
11212    
11213                    try {
11214                            session = openSession();
11215    
11216                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11217    
11218                            if (getDB().isSupportsInlineDistinct()) {
11219                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11220                            }
11221                            else {
11222                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11223                            }
11224    
11225                            QueryPos qPos = QueryPos.getInstance(q);
11226    
11227                            qPos.add(groupId);
11228    
11229                            qPos.add(userId);
11230    
11231                            qPos.add(status);
11232    
11233                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11234                    }
11235                    catch (Exception e) {
11236                            throw processException(e);
11237                    }
11238                    finally {
11239                            closeSession(session);
11240                    }
11241            }
11242    
11243            /**
11244             * 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;.
11245             *
11246             * @param entryId the primary key of the current blogs entry
11247             * @param groupId the group ID
11248             * @param userId the user ID
11249             * @param status the status
11250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11251             * @return the previous, current, and next blogs entry
11252             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11253             */
11254            @Override
11255            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
11256                    long groupId, long userId, int status,
11257                    OrderByComparator<BlogsEntry> orderByComparator)
11258                    throws NoSuchEntryException {
11259                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11260                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
11261                                    orderByComparator);
11262                    }
11263    
11264                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11265    
11266                    Session session = null;
11267    
11268                    try {
11269                            session = openSession();
11270    
11271                            BlogsEntry[] array = new BlogsEntryImpl[3];
11272    
11273                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11274                                            groupId, userId, status, orderByComparator, true);
11275    
11276                            array[1] = blogsEntry;
11277    
11278                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11279                                            groupId, userId, status, orderByComparator, false);
11280    
11281                            return array;
11282                    }
11283                    catch (Exception e) {
11284                            throw processException(e);
11285                    }
11286                    finally {
11287                            closeSession(session);
11288                    }
11289            }
11290    
11291            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
11292                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11293                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11294                    StringBundler query = null;
11295    
11296                    if (orderByComparator != null) {
11297                            query = new StringBundler(6 +
11298                                            (orderByComparator.getOrderByFields().length * 6));
11299                    }
11300                    else {
11301                            query = new StringBundler(3);
11302                    }
11303    
11304                    if (getDB().isSupportsInlineDistinct()) {
11305                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11306                    }
11307                    else {
11308                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11309                    }
11310    
11311                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11312    
11313                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11314    
11315                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11316    
11317                    if (!getDB().isSupportsInlineDistinct()) {
11318                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11319                    }
11320    
11321                    if (orderByComparator != null) {
11322                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11323    
11324                            if (orderByConditionFields.length > 0) {
11325                                    query.append(WHERE_AND);
11326                            }
11327    
11328                            for (int i = 0; i < orderByConditionFields.length; i++) {
11329                                    if (getDB().isSupportsInlineDistinct()) {
11330                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11331                                    }
11332                                    else {
11333                                            query.append(_ORDER_BY_ENTITY_TABLE);
11334                                    }
11335    
11336                                    query.append(orderByConditionFields[i]);
11337    
11338                                    if ((i + 1) < orderByConditionFields.length) {
11339                                            if (orderByComparator.isAscending() ^ previous) {
11340                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11341                                            }
11342                                            else {
11343                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11344                                            }
11345                                    }
11346                                    else {
11347                                            if (orderByComparator.isAscending() ^ previous) {
11348                                                    query.append(WHERE_GREATER_THAN);
11349                                            }
11350                                            else {
11351                                                    query.append(WHERE_LESSER_THAN);
11352                                            }
11353                                    }
11354                            }
11355    
11356                            query.append(ORDER_BY_CLAUSE);
11357    
11358                            String[] orderByFields = orderByComparator.getOrderByFields();
11359    
11360                            for (int i = 0; i < orderByFields.length; i++) {
11361                                    if (getDB().isSupportsInlineDistinct()) {
11362                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11363                                    }
11364                                    else {
11365                                            query.append(_ORDER_BY_ENTITY_TABLE);
11366                                    }
11367    
11368                                    query.append(orderByFields[i]);
11369    
11370                                    if ((i + 1) < orderByFields.length) {
11371                                            if (orderByComparator.isAscending() ^ previous) {
11372                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11373                                            }
11374                                            else {
11375                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11376                                            }
11377                                    }
11378                                    else {
11379                                            if (orderByComparator.isAscending() ^ previous) {
11380                                                    query.append(ORDER_BY_ASC);
11381                                            }
11382                                            else {
11383                                                    query.append(ORDER_BY_DESC);
11384                                            }
11385                                    }
11386                            }
11387                    }
11388                    else {
11389                            if (getDB().isSupportsInlineDistinct()) {
11390                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11391                            }
11392                            else {
11393                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11394                            }
11395                    }
11396    
11397                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11398                                    BlogsEntry.class.getName(),
11399                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11400    
11401                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11402    
11403                    q.setFirstResult(0);
11404                    q.setMaxResults(2);
11405    
11406                    if (getDB().isSupportsInlineDistinct()) {
11407                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11408                    }
11409                    else {
11410                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11411                    }
11412    
11413                    QueryPos qPos = QueryPos.getInstance(q);
11414    
11415                    qPos.add(groupId);
11416    
11417                    qPos.add(userId);
11418    
11419                    qPos.add(status);
11420    
11421                    if (orderByComparator != null) {
11422                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11423    
11424                            for (Object value : values) {
11425                                    qPos.add(value);
11426                            }
11427                    }
11428    
11429                    List<BlogsEntry> list = q.list();
11430    
11431                    if (list.size() == 2) {
11432                            return list.get(1);
11433                    }
11434                    else {
11435                            return null;
11436                    }
11437            }
11438    
11439            /**
11440             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
11441             *
11442             * @param groupId the group ID
11443             * @param userId the user ID
11444             * @param status the status
11445             */
11446            @Override
11447            public void removeByG_U_NotS(long groupId, long userId, int status) {
11448                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
11449                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11450                            remove(blogsEntry);
11451                    }
11452            }
11453    
11454            /**
11455             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11456             *
11457             * @param groupId the group ID
11458             * @param userId the user ID
11459             * @param status the status
11460             * @return the number of matching blogs entries
11461             */
11462            @Override
11463            public int countByG_U_NotS(long groupId, long userId, int status) {
11464                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
11465    
11466                    Object[] finderArgs = new Object[] { groupId, userId, status };
11467    
11468                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
11469    
11470                    if (count == null) {
11471                            StringBundler query = new StringBundler(4);
11472    
11473                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11474    
11475                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11476    
11477                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11478    
11479                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11480    
11481                            String sql = query.toString();
11482    
11483                            Session session = null;
11484    
11485                            try {
11486                                    session = openSession();
11487    
11488                                    Query q = session.createQuery(sql);
11489    
11490                                    QueryPos qPos = QueryPos.getInstance(q);
11491    
11492                                    qPos.add(groupId);
11493    
11494                                    qPos.add(userId);
11495    
11496                                    qPos.add(status);
11497    
11498                                    count = (Long)q.uniqueResult();
11499    
11500                                    finderCache.putResult(finderPath, finderArgs, count);
11501                            }
11502                            catch (Exception e) {
11503                                    finderCache.removeResult(finderPath, finderArgs);
11504    
11505                                    throw processException(e);
11506                            }
11507                            finally {
11508                                    closeSession(session);
11509                            }
11510                    }
11511    
11512                    return count.intValue();
11513            }
11514    
11515            /**
11516             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11517             *
11518             * @param groupId the group ID
11519             * @param userId the user ID
11520             * @param status the status
11521             * @return the number of matching blogs entries that the user has permission to view
11522             */
11523            @Override
11524            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
11525                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11526                            return countByG_U_NotS(groupId, userId, status);
11527                    }
11528    
11529                    StringBundler query = new StringBundler(4);
11530    
11531                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11532    
11533                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11534    
11535                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11536    
11537                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11538    
11539                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11540                                    BlogsEntry.class.getName(),
11541                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11542    
11543                    Session session = null;
11544    
11545                    try {
11546                            session = openSession();
11547    
11548                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11549    
11550                            q.addScalar(COUNT_COLUMN_NAME,
11551                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11552    
11553                            QueryPos qPos = QueryPos.getInstance(q);
11554    
11555                            qPos.add(groupId);
11556    
11557                            qPos.add(userId);
11558    
11559                            qPos.add(status);
11560    
11561                            Long count = (Long)q.uniqueResult();
11562    
11563                            return count.intValue();
11564                    }
11565                    catch (Exception e) {
11566                            throw processException(e);
11567                    }
11568                    finally {
11569                            closeSession(session);
11570                    }
11571            }
11572    
11573            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11574            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
11575            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
11576            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11577                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11578                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
11579                            new String[] {
11580                                    Long.class.getName(), Date.class.getName(),
11581                                    Integer.class.getName(),
11582                                    
11583                            Integer.class.getName(), Integer.class.getName(),
11584                                    OrderByComparator.class.getName()
11585                            });
11586            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11587                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11588                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
11589                            new String[] {
11590                                    Long.class.getName(), Date.class.getName(),
11591                                    Integer.class.getName()
11592                            });
11593    
11594            /**
11595             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11596             *
11597             * @param groupId the group ID
11598             * @param displayDate the display date
11599             * @param status the status
11600             * @return the matching blogs entries
11601             */
11602            @Override
11603            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11604                    int status) {
11605                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
11606                            QueryUtil.ALL_POS, null);
11607            }
11608    
11609            /**
11610             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11611             *
11612             * <p>
11613             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11614             * </p>
11615             *
11616             * @param groupId the group ID
11617             * @param displayDate the display date
11618             * @param status the status
11619             * @param start the lower bound of the range of blogs entries
11620             * @param end the upper bound of the range of blogs entries (not inclusive)
11621             * @return the range of matching blogs entries
11622             */
11623            @Override
11624            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11625                    int status, int start, int end) {
11626                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
11627            }
11628    
11629            /**
11630             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11631             *
11632             * <p>
11633             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11634             * </p>
11635             *
11636             * @param groupId the group ID
11637             * @param displayDate the display date
11638             * @param status the status
11639             * @param start the lower bound of the range of blogs entries
11640             * @param end the upper bound of the range of blogs entries (not inclusive)
11641             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11642             * @return the ordered range of matching blogs entries
11643             */
11644            @Override
11645            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11646                    int status, int start, int end,
11647                    OrderByComparator<BlogsEntry> orderByComparator) {
11648                    return findByG_LtD_S(groupId, displayDate, status, start, end,
11649                            orderByComparator, true);
11650            }
11651    
11652            /**
11653             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11654             *
11655             * <p>
11656             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11657             * </p>
11658             *
11659             * @param groupId the group ID
11660             * @param displayDate the display date
11661             * @param status the status
11662             * @param start the lower bound of the range of blogs entries
11663             * @param end the upper bound of the range of blogs entries (not inclusive)
11664             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11665             * @param retrieveFromCache whether to retrieve from the finder cache
11666             * @return the ordered range of matching blogs entries
11667             */
11668            @Override
11669            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11670                    int status, int start, int end,
11671                    OrderByComparator<BlogsEntry> orderByComparator,
11672                    boolean retrieveFromCache) {
11673                    boolean pagination = true;
11674                    FinderPath finderPath = null;
11675                    Object[] finderArgs = null;
11676    
11677                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
11678                    finderArgs = new Object[] {
11679                                    groupId, displayDate, status,
11680                                    
11681                                    start, end, orderByComparator
11682                            };
11683    
11684                    List<BlogsEntry> list = null;
11685    
11686                    if (retrieveFromCache) {
11687                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
11688                                            finderArgs, this);
11689    
11690                            if ((list != null) && !list.isEmpty()) {
11691                                    for (BlogsEntry blogsEntry : list) {
11692                                            if ((groupId != blogsEntry.getGroupId()) ||
11693                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
11694                                                                                                                                            .getTime()) ||
11695                                                            (status != blogsEntry.getStatus())) {
11696                                                    list = null;
11697    
11698                                                    break;
11699                                            }
11700                                    }
11701                            }
11702                    }
11703    
11704                    if (list == null) {
11705                            StringBundler query = null;
11706    
11707                            if (orderByComparator != null) {
11708                                    query = new StringBundler(5 +
11709                                                    (orderByComparator.getOrderByFields().length * 3));
11710                            }
11711                            else {
11712                                    query = new StringBundler(5);
11713                            }
11714    
11715                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11716    
11717                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11718    
11719                            boolean bindDisplayDate = false;
11720    
11721                            if (displayDate == null) {
11722                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11723                            }
11724                            else {
11725                                    bindDisplayDate = true;
11726    
11727                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11728                            }
11729    
11730                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11731    
11732                            if (orderByComparator != null) {
11733                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11734                                            orderByComparator);
11735                            }
11736                            else
11737                             if (pagination) {
11738                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11739                            }
11740    
11741                            String sql = query.toString();
11742    
11743                            Session session = null;
11744    
11745                            try {
11746                                    session = openSession();
11747    
11748                                    Query q = session.createQuery(sql);
11749    
11750                                    QueryPos qPos = QueryPos.getInstance(q);
11751    
11752                                    qPos.add(groupId);
11753    
11754                                    if (bindDisplayDate) {
11755                                            qPos.add(new Timestamp(displayDate.getTime()));
11756                                    }
11757    
11758                                    qPos.add(status);
11759    
11760                                    if (!pagination) {
11761                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11762                                                            start, end, false);
11763    
11764                                            Collections.sort(list);
11765    
11766                                            list = Collections.unmodifiableList(list);
11767                                    }
11768                                    else {
11769                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11770                                                            start, end);
11771                                    }
11772    
11773                                    cacheResult(list);
11774    
11775                                    finderCache.putResult(finderPath, finderArgs, list);
11776                            }
11777                            catch (Exception e) {
11778                                    finderCache.removeResult(finderPath, finderArgs);
11779    
11780                                    throw processException(e);
11781                            }
11782                            finally {
11783                                    closeSession(session);
11784                            }
11785                    }
11786    
11787                    return list;
11788            }
11789    
11790            /**
11791             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11792             *
11793             * @param groupId the group ID
11794             * @param displayDate the display date
11795             * @param status the status
11796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11797             * @return the first matching blogs entry
11798             * @throws NoSuchEntryException if a matching blogs entry could not be found
11799             */
11800            @Override
11801            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
11802                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11803                    throws NoSuchEntryException {
11804                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
11805                                    status, orderByComparator);
11806    
11807                    if (blogsEntry != null) {
11808                            return blogsEntry;
11809                    }
11810    
11811                    StringBundler msg = new StringBundler(8);
11812    
11813                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11814    
11815                    msg.append("groupId=");
11816                    msg.append(groupId);
11817    
11818                    msg.append(", displayDate=");
11819                    msg.append(displayDate);
11820    
11821                    msg.append(", status=");
11822                    msg.append(status);
11823    
11824                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11825    
11826                    throw new NoSuchEntryException(msg.toString());
11827            }
11828    
11829            /**
11830             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11831             *
11832             * @param groupId the group ID
11833             * @param displayDate the display date
11834             * @param status the status
11835             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11836             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11837             */
11838            @Override
11839            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
11840                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11841                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
11842                                    1, orderByComparator);
11843    
11844                    if (!list.isEmpty()) {
11845                            return list.get(0);
11846                    }
11847    
11848                    return null;
11849            }
11850    
11851            /**
11852             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11853             *
11854             * @param groupId the group ID
11855             * @param displayDate the display date
11856             * @param status the status
11857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11858             * @return the last matching blogs entry
11859             * @throws NoSuchEntryException if a matching blogs entry could not be found
11860             */
11861            @Override
11862            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
11863                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11864                    throws NoSuchEntryException {
11865                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
11866                                    status, orderByComparator);
11867    
11868                    if (blogsEntry != null) {
11869                            return blogsEntry;
11870                    }
11871    
11872                    StringBundler msg = new StringBundler(8);
11873    
11874                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11875    
11876                    msg.append("groupId=");
11877                    msg.append(groupId);
11878    
11879                    msg.append(", displayDate=");
11880                    msg.append(displayDate);
11881    
11882                    msg.append(", status=");
11883                    msg.append(status);
11884    
11885                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11886    
11887                    throw new NoSuchEntryException(msg.toString());
11888            }
11889    
11890            /**
11891             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11892             *
11893             * @param groupId the group ID
11894             * @param displayDate the display date
11895             * @param status the status
11896             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11897             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11898             */
11899            @Override
11900            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
11901                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11902                    int count = countByG_LtD_S(groupId, displayDate, status);
11903    
11904                    if (count == 0) {
11905                            return null;
11906                    }
11907    
11908                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
11909                                    count - 1, count, orderByComparator);
11910    
11911                    if (!list.isEmpty()) {
11912                            return list.get(0);
11913                    }
11914    
11915                    return null;
11916            }
11917    
11918            /**
11919             * 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;.
11920             *
11921             * @param entryId the primary key of the current blogs entry
11922             * @param groupId the group ID
11923             * @param displayDate the display date
11924             * @param status the status
11925             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11926             * @return the previous, current, and next blogs entry
11927             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11928             */
11929            @Override
11930            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
11931                    Date displayDate, int status,
11932                    OrderByComparator<BlogsEntry> orderByComparator)
11933                    throws NoSuchEntryException {
11934                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11935    
11936                    Session session = null;
11937    
11938                    try {
11939                            session = openSession();
11940    
11941                            BlogsEntry[] array = new BlogsEntryImpl[3];
11942    
11943                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11944                                            displayDate, status, orderByComparator, true);
11945    
11946                            array[1] = blogsEntry;
11947    
11948                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11949                                            displayDate, status, orderByComparator, false);
11950    
11951                            return array;
11952                    }
11953                    catch (Exception e) {
11954                            throw processException(e);
11955                    }
11956                    finally {
11957                            closeSession(session);
11958                    }
11959            }
11960    
11961            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
11962                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
11963                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11964                    StringBundler query = null;
11965    
11966                    if (orderByComparator != null) {
11967                            query = new StringBundler(6 +
11968                                            (orderByComparator.getOrderByFields().length * 6));
11969                    }
11970                    else {
11971                            query = new StringBundler(3);
11972                    }
11973    
11974                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11975    
11976                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11977    
11978                    boolean bindDisplayDate = false;
11979    
11980                    if (displayDate == null) {
11981                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11982                    }
11983                    else {
11984                            bindDisplayDate = true;
11985    
11986                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11987                    }
11988    
11989                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11990    
11991                    if (orderByComparator != null) {
11992                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11993    
11994                            if (orderByConditionFields.length > 0) {
11995                                    query.append(WHERE_AND);
11996                            }
11997    
11998                            for (int i = 0; i < orderByConditionFields.length; i++) {
11999                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12000                                    query.append(orderByConditionFields[i]);
12001    
12002                                    if ((i + 1) < orderByConditionFields.length) {
12003                                            if (orderByComparator.isAscending() ^ previous) {
12004                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12005                                            }
12006                                            else {
12007                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12008                                            }
12009                                    }
12010                                    else {
12011                                            if (orderByComparator.isAscending() ^ previous) {
12012                                                    query.append(WHERE_GREATER_THAN);
12013                                            }
12014                                            else {
12015                                                    query.append(WHERE_LESSER_THAN);
12016                                            }
12017                                    }
12018                            }
12019    
12020                            query.append(ORDER_BY_CLAUSE);
12021    
12022                            String[] orderByFields = orderByComparator.getOrderByFields();
12023    
12024                            for (int i = 0; i < orderByFields.length; i++) {
12025                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12026                                    query.append(orderByFields[i]);
12027    
12028                                    if ((i + 1) < orderByFields.length) {
12029                                            if (orderByComparator.isAscending() ^ previous) {
12030                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12031                                            }
12032                                            else {
12033                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12034                                            }
12035                                    }
12036                                    else {
12037                                            if (orderByComparator.isAscending() ^ previous) {
12038                                                    query.append(ORDER_BY_ASC);
12039                                            }
12040                                            else {
12041                                                    query.append(ORDER_BY_DESC);
12042                                            }
12043                                    }
12044                            }
12045                    }
12046                    else {
12047                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12048                    }
12049    
12050                    String sql = query.toString();
12051    
12052                    Query q = session.createQuery(sql);
12053    
12054                    q.setFirstResult(0);
12055                    q.setMaxResults(2);
12056    
12057                    QueryPos qPos = QueryPos.getInstance(q);
12058    
12059                    qPos.add(groupId);
12060    
12061                    if (bindDisplayDate) {
12062                            qPos.add(new Timestamp(displayDate.getTime()));
12063                    }
12064    
12065                    qPos.add(status);
12066    
12067                    if (orderByComparator != null) {
12068                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12069    
12070                            for (Object value : values) {
12071                                    qPos.add(value);
12072                            }
12073                    }
12074    
12075                    List<BlogsEntry> list = q.list();
12076    
12077                    if (list.size() == 2) {
12078                            return list.get(1);
12079                    }
12080                    else {
12081                            return null;
12082                    }
12083            }
12084    
12085            /**
12086             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12087             *
12088             * @param groupId the group ID
12089             * @param displayDate the display date
12090             * @param status the status
12091             * @return the matching blogs entries that the user has permission to view
12092             */
12093            @Override
12094            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12095                    int status) {
12096                    return filterFindByG_LtD_S(groupId, displayDate, status,
12097                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12098            }
12099    
12100            /**
12101             * 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;.
12102             *
12103             * <p>
12104             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12105             * </p>
12106             *
12107             * @param groupId the group ID
12108             * @param displayDate the display date
12109             * @param status the status
12110             * @param start the lower bound of the range of blogs entries
12111             * @param end the upper bound of the range of blogs entries (not inclusive)
12112             * @return the range of matching blogs entries that the user has permission to view
12113             */
12114            @Override
12115            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12116                    int status, int start, int end) {
12117                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
12118                            null);
12119            }
12120    
12121            /**
12122             * 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;.
12123             *
12124             * <p>
12125             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12126             * </p>
12127             *
12128             * @param groupId the group ID
12129             * @param displayDate the display date
12130             * @param status the status
12131             * @param start the lower bound of the range of blogs entries
12132             * @param end the upper bound of the range of blogs entries (not inclusive)
12133             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12134             * @return the ordered range of matching blogs entries that the user has permission to view
12135             */
12136            @Override
12137            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12138                    int status, int start, int end,
12139                    OrderByComparator<BlogsEntry> orderByComparator) {
12140                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12141                            return findByG_LtD_S(groupId, displayDate, status, start, end,
12142                                    orderByComparator);
12143                    }
12144    
12145                    StringBundler query = null;
12146    
12147                    if (orderByComparator != null) {
12148                            query = new StringBundler(5 +
12149                                            (orderByComparator.getOrderByFields().length * 3));
12150                    }
12151                    else {
12152                            query = new StringBundler(5);
12153                    }
12154    
12155                    if (getDB().isSupportsInlineDistinct()) {
12156                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12157                    }
12158                    else {
12159                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12160                    }
12161    
12162                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12163    
12164                    boolean bindDisplayDate = false;
12165    
12166                    if (displayDate == null) {
12167                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12168                    }
12169                    else {
12170                            bindDisplayDate = true;
12171    
12172                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12173                    }
12174    
12175                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12176    
12177                    if (!getDB().isSupportsInlineDistinct()) {
12178                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12179                    }
12180    
12181                    if (orderByComparator != null) {
12182                            if (getDB().isSupportsInlineDistinct()) {
12183                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12184                                            orderByComparator, true);
12185                            }
12186                            else {
12187                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12188                                            orderByComparator, true);
12189                            }
12190                    }
12191                    else {
12192                            if (getDB().isSupportsInlineDistinct()) {
12193                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12194                            }
12195                            else {
12196                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12197                            }
12198                    }
12199    
12200                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12201                                    BlogsEntry.class.getName(),
12202                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12203    
12204                    Session session = null;
12205    
12206                    try {
12207                            session = openSession();
12208    
12209                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12210    
12211                            if (getDB().isSupportsInlineDistinct()) {
12212                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12213                            }
12214                            else {
12215                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12216                            }
12217    
12218                            QueryPos qPos = QueryPos.getInstance(q);
12219    
12220                            qPos.add(groupId);
12221    
12222                            if (bindDisplayDate) {
12223                                    qPos.add(new Timestamp(displayDate.getTime()));
12224                            }
12225    
12226                            qPos.add(status);
12227    
12228                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12229                    }
12230                    catch (Exception e) {
12231                            throw processException(e);
12232                    }
12233                    finally {
12234                            closeSession(session);
12235                    }
12236            }
12237    
12238            /**
12239             * 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;.
12240             *
12241             * @param entryId the primary key of the current blogs entry
12242             * @param groupId the group ID
12243             * @param displayDate the display date
12244             * @param status the status
12245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12246             * @return the previous, current, and next blogs entry
12247             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12248             */
12249            @Override
12250            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
12251                    long groupId, Date displayDate, int status,
12252                    OrderByComparator<BlogsEntry> orderByComparator)
12253                    throws NoSuchEntryException {
12254                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12255                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
12256                                    status, orderByComparator);
12257                    }
12258    
12259                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12260    
12261                    Session session = null;
12262    
12263                    try {
12264                            session = openSession();
12265    
12266                            BlogsEntry[] array = new BlogsEntryImpl[3];
12267    
12268                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12269                                            groupId, displayDate, status, orderByComparator, true);
12270    
12271                            array[1] = blogsEntry;
12272    
12273                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12274                                            groupId, displayDate, status, orderByComparator, false);
12275    
12276                            return array;
12277                    }
12278                    catch (Exception e) {
12279                            throw processException(e);
12280                    }
12281                    finally {
12282                            closeSession(session);
12283                    }
12284            }
12285    
12286            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
12287                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12288                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12289                    StringBundler query = null;
12290    
12291                    if (orderByComparator != null) {
12292                            query = new StringBundler(6 +
12293                                            (orderByComparator.getOrderByFields().length * 6));
12294                    }
12295                    else {
12296                            query = new StringBundler(3);
12297                    }
12298    
12299                    if (getDB().isSupportsInlineDistinct()) {
12300                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12301                    }
12302                    else {
12303                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12304                    }
12305    
12306                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12307    
12308                    boolean bindDisplayDate = false;
12309    
12310                    if (displayDate == null) {
12311                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12312                    }
12313                    else {
12314                            bindDisplayDate = true;
12315    
12316                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12317                    }
12318    
12319                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12320    
12321                    if (!getDB().isSupportsInlineDistinct()) {
12322                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12323                    }
12324    
12325                    if (orderByComparator != null) {
12326                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12327    
12328                            if (orderByConditionFields.length > 0) {
12329                                    query.append(WHERE_AND);
12330                            }
12331    
12332                            for (int i = 0; i < orderByConditionFields.length; i++) {
12333                                    if (getDB().isSupportsInlineDistinct()) {
12334                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12335                                    }
12336                                    else {
12337                                            query.append(_ORDER_BY_ENTITY_TABLE);
12338                                    }
12339    
12340                                    query.append(orderByConditionFields[i]);
12341    
12342                                    if ((i + 1) < orderByConditionFields.length) {
12343                                            if (orderByComparator.isAscending() ^ previous) {
12344                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12345                                            }
12346                                            else {
12347                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12348                                            }
12349                                    }
12350                                    else {
12351                                            if (orderByComparator.isAscending() ^ previous) {
12352                                                    query.append(WHERE_GREATER_THAN);
12353                                            }
12354                                            else {
12355                                                    query.append(WHERE_LESSER_THAN);
12356                                            }
12357                                    }
12358                            }
12359    
12360                            query.append(ORDER_BY_CLAUSE);
12361    
12362                            String[] orderByFields = orderByComparator.getOrderByFields();
12363    
12364                            for (int i = 0; i < orderByFields.length; i++) {
12365                                    if (getDB().isSupportsInlineDistinct()) {
12366                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12367                                    }
12368                                    else {
12369                                            query.append(_ORDER_BY_ENTITY_TABLE);
12370                                    }
12371    
12372                                    query.append(orderByFields[i]);
12373    
12374                                    if ((i + 1) < orderByFields.length) {
12375                                            if (orderByComparator.isAscending() ^ previous) {
12376                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12377                                            }
12378                                            else {
12379                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12380                                            }
12381                                    }
12382                                    else {
12383                                            if (orderByComparator.isAscending() ^ previous) {
12384                                                    query.append(ORDER_BY_ASC);
12385                                            }
12386                                            else {
12387                                                    query.append(ORDER_BY_DESC);
12388                                            }
12389                                    }
12390                            }
12391                    }
12392                    else {
12393                            if (getDB().isSupportsInlineDistinct()) {
12394                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12395                            }
12396                            else {
12397                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12398                            }
12399                    }
12400    
12401                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12402                                    BlogsEntry.class.getName(),
12403                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12404    
12405                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12406    
12407                    q.setFirstResult(0);
12408                    q.setMaxResults(2);
12409    
12410                    if (getDB().isSupportsInlineDistinct()) {
12411                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12412                    }
12413                    else {
12414                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12415                    }
12416    
12417                    QueryPos qPos = QueryPos.getInstance(q);
12418    
12419                    qPos.add(groupId);
12420    
12421                    if (bindDisplayDate) {
12422                            qPos.add(new Timestamp(displayDate.getTime()));
12423                    }
12424    
12425                    qPos.add(status);
12426    
12427                    if (orderByComparator != null) {
12428                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12429    
12430                            for (Object value : values) {
12431                                    qPos.add(value);
12432                            }
12433                    }
12434    
12435                    List<BlogsEntry> list = q.list();
12436    
12437                    if (list.size() == 2) {
12438                            return list.get(1);
12439                    }
12440                    else {
12441                            return null;
12442                    }
12443            }
12444    
12445            /**
12446             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
12447             *
12448             * @param groupId the group ID
12449             * @param displayDate the display date
12450             * @param status the status
12451             */
12452            @Override
12453            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
12454                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
12455                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12456                            remove(blogsEntry);
12457                    }
12458            }
12459    
12460            /**
12461             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12462             *
12463             * @param groupId the group ID
12464             * @param displayDate the display date
12465             * @param status the status
12466             * @return the number of matching blogs entries
12467             */
12468            @Override
12469            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
12470                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
12471    
12472                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
12473    
12474                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12475    
12476                    if (count == null) {
12477                            StringBundler query = new StringBundler(4);
12478    
12479                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12480    
12481                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12482    
12483                            boolean bindDisplayDate = false;
12484    
12485                            if (displayDate == null) {
12486                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12487                            }
12488                            else {
12489                                    bindDisplayDate = true;
12490    
12491                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12492                            }
12493    
12494                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12495    
12496                            String sql = query.toString();
12497    
12498                            Session session = null;
12499    
12500                            try {
12501                                    session = openSession();
12502    
12503                                    Query q = session.createQuery(sql);
12504    
12505                                    QueryPos qPos = QueryPos.getInstance(q);
12506    
12507                                    qPos.add(groupId);
12508    
12509                                    if (bindDisplayDate) {
12510                                            qPos.add(new Timestamp(displayDate.getTime()));
12511                                    }
12512    
12513                                    qPos.add(status);
12514    
12515                                    count = (Long)q.uniqueResult();
12516    
12517                                    finderCache.putResult(finderPath, finderArgs, count);
12518                            }
12519                            catch (Exception e) {
12520                                    finderCache.removeResult(finderPath, finderArgs);
12521    
12522                                    throw processException(e);
12523                            }
12524                            finally {
12525                                    closeSession(session);
12526                            }
12527                    }
12528    
12529                    return count.intValue();
12530            }
12531    
12532            /**
12533             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12534             *
12535             * @param groupId the group ID
12536             * @param displayDate the display date
12537             * @param status the status
12538             * @return the number of matching blogs entries that the user has permission to view
12539             */
12540            @Override
12541            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
12542                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12543                            return countByG_LtD_S(groupId, displayDate, status);
12544                    }
12545    
12546                    StringBundler query = new StringBundler(4);
12547    
12548                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12549    
12550                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12551    
12552                    boolean bindDisplayDate = false;
12553    
12554                    if (displayDate == null) {
12555                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12556                    }
12557                    else {
12558                            bindDisplayDate = true;
12559    
12560                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12561                    }
12562    
12563                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12564    
12565                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12566                                    BlogsEntry.class.getName(),
12567                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12568    
12569                    Session session = null;
12570    
12571                    try {
12572                            session = openSession();
12573    
12574                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12575    
12576                            q.addScalar(COUNT_COLUMN_NAME,
12577                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12578    
12579                            QueryPos qPos = QueryPos.getInstance(q);
12580    
12581                            qPos.add(groupId);
12582    
12583                            if (bindDisplayDate) {
12584                                    qPos.add(new Timestamp(displayDate.getTime()));
12585                            }
12586    
12587                            qPos.add(status);
12588    
12589                            Long count = (Long)q.uniqueResult();
12590    
12591                            return count.intValue();
12592                    }
12593                    catch (Exception e) {
12594                            throw processException(e);
12595                    }
12596                    finally {
12597                            closeSession(session);
12598                    }
12599            }
12600    
12601            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12602            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
12603            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12604            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12605            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
12606                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12607                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12608                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
12609                            new String[] {
12610                                    Long.class.getName(), Date.class.getName(),
12611                                    Integer.class.getName(),
12612                                    
12613                            Integer.class.getName(), Integer.class.getName(),
12614                                    OrderByComparator.class.getName()
12615                            });
12616            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
12617                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12618                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12619                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
12620                            new String[] {
12621                                    Long.class.getName(), Date.class.getName(),
12622                                    Integer.class.getName()
12623                            });
12624    
12625            /**
12626             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12627             *
12628             * @param groupId the group ID
12629             * @param displayDate the display date
12630             * @param status the status
12631             * @return the matching blogs entries
12632             */
12633            @Override
12634            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12635                    int status) {
12636                    return findByG_LtD_NotS(groupId, displayDate, status,
12637                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12638            }
12639    
12640            /**
12641             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12642             *
12643             * <p>
12644             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12645             * </p>
12646             *
12647             * @param groupId the group ID
12648             * @param displayDate the display date
12649             * @param status the status
12650             * @param start the lower bound of the range of blogs entries
12651             * @param end the upper bound of the range of blogs entries (not inclusive)
12652             * @return the range of matching blogs entries
12653             */
12654            @Override
12655            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12656                    int status, int start, int end) {
12657                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
12658            }
12659    
12660            /**
12661             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12662             *
12663             * <p>
12664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12665             * </p>
12666             *
12667             * @param groupId the group ID
12668             * @param displayDate the display date
12669             * @param status the status
12670             * @param start the lower bound of the range of blogs entries
12671             * @param end the upper bound of the range of blogs entries (not inclusive)
12672             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12673             * @return the ordered range of matching blogs entries
12674             */
12675            @Override
12676            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12677                    int status, int start, int end,
12678                    OrderByComparator<BlogsEntry> orderByComparator) {
12679                    return findByG_LtD_NotS(groupId, displayDate, status, start, end,
12680                            orderByComparator, true);
12681            }
12682    
12683            /**
12684             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12685             *
12686             * <p>
12687             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12688             * </p>
12689             *
12690             * @param groupId the group ID
12691             * @param displayDate the display date
12692             * @param status the status
12693             * @param start the lower bound of the range of blogs entries
12694             * @param end the upper bound of the range of blogs entries (not inclusive)
12695             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12696             * @param retrieveFromCache whether to retrieve from the finder cache
12697             * @return the ordered range of matching blogs entries
12698             */
12699            @Override
12700            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12701                    int status, int start, int end,
12702                    OrderByComparator<BlogsEntry> orderByComparator,
12703                    boolean retrieveFromCache) {
12704                    boolean pagination = true;
12705                    FinderPath finderPath = null;
12706                    Object[] finderArgs = null;
12707    
12708                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
12709                    finderArgs = new Object[] {
12710                                    groupId, displayDate, status,
12711                                    
12712                                    start, end, orderByComparator
12713                            };
12714    
12715                    List<BlogsEntry> list = null;
12716    
12717                    if (retrieveFromCache) {
12718                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
12719                                            finderArgs, this);
12720    
12721                            if ((list != null) && !list.isEmpty()) {
12722                                    for (BlogsEntry blogsEntry : list) {
12723                                            if ((groupId != blogsEntry.getGroupId()) ||
12724                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
12725                                                                                                                                            .getTime()) ||
12726                                                            (status == blogsEntry.getStatus())) {
12727                                                    list = null;
12728    
12729                                                    break;
12730                                            }
12731                                    }
12732                            }
12733                    }
12734    
12735                    if (list == null) {
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                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12747    
12748                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12749    
12750                            boolean bindDisplayDate = false;
12751    
12752                            if (displayDate == null) {
12753                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12754                            }
12755                            else {
12756                                    bindDisplayDate = true;
12757    
12758                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12759                            }
12760    
12761                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12762    
12763                            if (orderByComparator != null) {
12764                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12765                                            orderByComparator);
12766                            }
12767                            else
12768                             if (pagination) {
12769                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12770                            }
12771    
12772                            String sql = query.toString();
12773    
12774                            Session session = null;
12775    
12776                            try {
12777                                    session = openSession();
12778    
12779                                    Query q = session.createQuery(sql);
12780    
12781                                    QueryPos qPos = QueryPos.getInstance(q);
12782    
12783                                    qPos.add(groupId);
12784    
12785                                    if (bindDisplayDate) {
12786                                            qPos.add(new Timestamp(displayDate.getTime()));
12787                                    }
12788    
12789                                    qPos.add(status);
12790    
12791                                    if (!pagination) {
12792                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12793                                                            start, end, false);
12794    
12795                                            Collections.sort(list);
12796    
12797                                            list = Collections.unmodifiableList(list);
12798                                    }
12799                                    else {
12800                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12801                                                            start, end);
12802                                    }
12803    
12804                                    cacheResult(list);
12805    
12806                                    finderCache.putResult(finderPath, finderArgs, list);
12807                            }
12808                            catch (Exception e) {
12809                                    finderCache.removeResult(finderPath, finderArgs);
12810    
12811                                    throw processException(e);
12812                            }
12813                            finally {
12814                                    closeSession(session);
12815                            }
12816                    }
12817    
12818                    return list;
12819            }
12820    
12821            /**
12822             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12823             *
12824             * @param groupId the group ID
12825             * @param displayDate the display date
12826             * @param status the status
12827             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12828             * @return the first matching blogs entry
12829             * @throws NoSuchEntryException if a matching blogs entry could not be found
12830             */
12831            @Override
12832            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
12833                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12834                    throws NoSuchEntryException {
12835                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
12836                                    status, orderByComparator);
12837    
12838                    if (blogsEntry != null) {
12839                            return blogsEntry;
12840                    }
12841    
12842                    StringBundler msg = new StringBundler(8);
12843    
12844                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12845    
12846                    msg.append("groupId=");
12847                    msg.append(groupId);
12848    
12849                    msg.append(", displayDate=");
12850                    msg.append(displayDate);
12851    
12852                    msg.append(", status=");
12853                    msg.append(status);
12854    
12855                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12856    
12857                    throw new NoSuchEntryException(msg.toString());
12858            }
12859    
12860            /**
12861             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12862             *
12863             * @param groupId the group ID
12864             * @param displayDate the display date
12865             * @param status the status
12866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12867             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12868             */
12869            @Override
12870            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
12871                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12872                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12873                                    0, 1, orderByComparator);
12874    
12875                    if (!list.isEmpty()) {
12876                            return list.get(0);
12877                    }
12878    
12879                    return null;
12880            }
12881    
12882            /**
12883             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12884             *
12885             * @param groupId the group ID
12886             * @param displayDate the display date
12887             * @param status the status
12888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12889             * @return the last matching blogs entry
12890             * @throws NoSuchEntryException if a matching blogs entry could not be found
12891             */
12892            @Override
12893            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
12894                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12895                    throws NoSuchEntryException {
12896                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
12897                                    status, orderByComparator);
12898    
12899                    if (blogsEntry != null) {
12900                            return blogsEntry;
12901                    }
12902    
12903                    StringBundler msg = new StringBundler(8);
12904    
12905                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12906    
12907                    msg.append("groupId=");
12908                    msg.append(groupId);
12909    
12910                    msg.append(", displayDate=");
12911                    msg.append(displayDate);
12912    
12913                    msg.append(", status=");
12914                    msg.append(status);
12915    
12916                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12917    
12918                    throw new NoSuchEntryException(msg.toString());
12919            }
12920    
12921            /**
12922             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12923             *
12924             * @param groupId the group ID
12925             * @param displayDate the display date
12926             * @param status the status
12927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12928             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12929             */
12930            @Override
12931            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
12932                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12933                    int count = countByG_LtD_NotS(groupId, displayDate, status);
12934    
12935                    if (count == 0) {
12936                            return null;
12937                    }
12938    
12939                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12940                                    count - 1, count, orderByComparator);
12941    
12942                    if (!list.isEmpty()) {
12943                            return list.get(0);
12944                    }
12945    
12946                    return null;
12947            }
12948    
12949            /**
12950             * 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;.
12951             *
12952             * @param entryId the primary key of the current blogs entry
12953             * @param groupId the group ID
12954             * @param displayDate the display date
12955             * @param status the status
12956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12957             * @return the previous, current, and next blogs entry
12958             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12959             */
12960            @Override
12961            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
12962                    long groupId, Date displayDate, int status,
12963                    OrderByComparator<BlogsEntry> orderByComparator)
12964                    throws NoSuchEntryException {
12965                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12966    
12967                    Session session = null;
12968    
12969                    try {
12970                            session = openSession();
12971    
12972                            BlogsEntry[] array = new BlogsEntryImpl[3];
12973    
12974                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12975                                            groupId, displayDate, status, orderByComparator, true);
12976    
12977                            array[1] = blogsEntry;
12978    
12979                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12980                                            groupId, displayDate, status, orderByComparator, false);
12981    
12982                            return array;
12983                    }
12984                    catch (Exception e) {
12985                            throw processException(e);
12986                    }
12987                    finally {
12988                            closeSession(session);
12989                    }
12990            }
12991    
12992            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
12993                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12994                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12995                    StringBundler query = null;
12996    
12997                    if (orderByComparator != null) {
12998                            query = new StringBundler(6 +
12999                                            (orderByComparator.getOrderByFields().length * 6));
13000                    }
13001                    else {
13002                            query = new StringBundler(3);
13003                    }
13004    
13005                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13006    
13007                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13008    
13009                    boolean bindDisplayDate = false;
13010    
13011                    if (displayDate == null) {
13012                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13013                    }
13014                    else {
13015                            bindDisplayDate = true;
13016    
13017                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13018                    }
13019    
13020                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13021    
13022                    if (orderByComparator != null) {
13023                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13024    
13025                            if (orderByConditionFields.length > 0) {
13026                                    query.append(WHERE_AND);
13027                            }
13028    
13029                            for (int i = 0; i < orderByConditionFields.length; i++) {
13030                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13031                                    query.append(orderByConditionFields[i]);
13032    
13033                                    if ((i + 1) < orderByConditionFields.length) {
13034                                            if (orderByComparator.isAscending() ^ previous) {
13035                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13036                                            }
13037                                            else {
13038                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13039                                            }
13040                                    }
13041                                    else {
13042                                            if (orderByComparator.isAscending() ^ previous) {
13043                                                    query.append(WHERE_GREATER_THAN);
13044                                            }
13045                                            else {
13046                                                    query.append(WHERE_LESSER_THAN);
13047                                            }
13048                                    }
13049                            }
13050    
13051                            query.append(ORDER_BY_CLAUSE);
13052    
13053                            String[] orderByFields = orderByComparator.getOrderByFields();
13054    
13055                            for (int i = 0; i < orderByFields.length; i++) {
13056                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13057                                    query.append(orderByFields[i]);
13058    
13059                                    if ((i + 1) < orderByFields.length) {
13060                                            if (orderByComparator.isAscending() ^ previous) {
13061                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13062                                            }
13063                                            else {
13064                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13065                                            }
13066                                    }
13067                                    else {
13068                                            if (orderByComparator.isAscending() ^ previous) {
13069                                                    query.append(ORDER_BY_ASC);
13070                                            }
13071                                            else {
13072                                                    query.append(ORDER_BY_DESC);
13073                                            }
13074                                    }
13075                            }
13076                    }
13077                    else {
13078                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13079                    }
13080    
13081                    String sql = query.toString();
13082    
13083                    Query q = session.createQuery(sql);
13084    
13085                    q.setFirstResult(0);
13086                    q.setMaxResults(2);
13087    
13088                    QueryPos qPos = QueryPos.getInstance(q);
13089    
13090                    qPos.add(groupId);
13091    
13092                    if (bindDisplayDate) {
13093                            qPos.add(new Timestamp(displayDate.getTime()));
13094                    }
13095    
13096                    qPos.add(status);
13097    
13098                    if (orderByComparator != null) {
13099                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13100    
13101                            for (Object value : values) {
13102                                    qPos.add(value);
13103                            }
13104                    }
13105    
13106                    List<BlogsEntry> list = q.list();
13107    
13108                    if (list.size() == 2) {
13109                            return list.get(1);
13110                    }
13111                    else {
13112                            return null;
13113                    }
13114            }
13115    
13116            /**
13117             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13118             *
13119             * @param groupId the group ID
13120             * @param displayDate the display date
13121             * @param status the status
13122             * @return the matching blogs entries that the user has permission to view
13123             */
13124            @Override
13125            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13126                    Date displayDate, int status) {
13127                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
13128                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13129            }
13130    
13131            /**
13132             * 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;.
13133             *
13134             * <p>
13135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13136             * </p>
13137             *
13138             * @param groupId the group ID
13139             * @param displayDate the display date
13140             * @param status the status
13141             * @param start the lower bound of the range of blogs entries
13142             * @param end the upper bound of the range of blogs entries (not inclusive)
13143             * @return the range of matching blogs entries that the user has permission to view
13144             */
13145            @Override
13146            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13147                    Date displayDate, int status, int start, int end) {
13148                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13149                            null);
13150            }
13151    
13152            /**
13153             * 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;.
13154             *
13155             * <p>
13156             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13157             * </p>
13158             *
13159             * @param groupId the group ID
13160             * @param displayDate the display date
13161             * @param status the status
13162             * @param start the lower bound of the range of blogs entries
13163             * @param end the upper bound of the range of blogs entries (not inclusive)
13164             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13165             * @return the ordered range of matching blogs entries that the user has permission to view
13166             */
13167            @Override
13168            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13169                    Date displayDate, int status, int start, int end,
13170                    OrderByComparator<BlogsEntry> orderByComparator) {
13171                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13172                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13173                                    orderByComparator);
13174                    }
13175    
13176                    StringBundler query = null;
13177    
13178                    if (orderByComparator != null) {
13179                            query = new StringBundler(5 +
13180                                            (orderByComparator.getOrderByFields().length * 3));
13181                    }
13182                    else {
13183                            query = new StringBundler(5);
13184                    }
13185    
13186                    if (getDB().isSupportsInlineDistinct()) {
13187                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13188                    }
13189                    else {
13190                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13191                    }
13192    
13193                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13194    
13195                    boolean bindDisplayDate = false;
13196    
13197                    if (displayDate == null) {
13198                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13199                    }
13200                    else {
13201                            bindDisplayDate = true;
13202    
13203                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13204                    }
13205    
13206                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13207    
13208                    if (!getDB().isSupportsInlineDistinct()) {
13209                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13210                    }
13211    
13212                    if (orderByComparator != null) {
13213                            if (getDB().isSupportsInlineDistinct()) {
13214                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13215                                            orderByComparator, true);
13216                            }
13217                            else {
13218                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13219                                            orderByComparator, true);
13220                            }
13221                    }
13222                    else {
13223                            if (getDB().isSupportsInlineDistinct()) {
13224                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13225                            }
13226                            else {
13227                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13228                            }
13229                    }
13230    
13231                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13232                                    BlogsEntry.class.getName(),
13233                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13234    
13235                    Session session = null;
13236    
13237                    try {
13238                            session = openSession();
13239    
13240                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13241    
13242                            if (getDB().isSupportsInlineDistinct()) {
13243                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13244                            }
13245                            else {
13246                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13247                            }
13248    
13249                            QueryPos qPos = QueryPos.getInstance(q);
13250    
13251                            qPos.add(groupId);
13252    
13253                            if (bindDisplayDate) {
13254                                    qPos.add(new Timestamp(displayDate.getTime()));
13255                            }
13256    
13257                            qPos.add(status);
13258    
13259                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13260                    }
13261                    catch (Exception e) {
13262                            throw processException(e);
13263                    }
13264                    finally {
13265                            closeSession(session);
13266                    }
13267            }
13268    
13269            /**
13270             * 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;.
13271             *
13272             * @param entryId the primary key of the current blogs entry
13273             * @param groupId the group ID
13274             * @param displayDate the display date
13275             * @param status the status
13276             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13277             * @return the previous, current, and next blogs entry
13278             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13279             */
13280            @Override
13281            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
13282                    long groupId, Date displayDate, int status,
13283                    OrderByComparator<BlogsEntry> orderByComparator)
13284                    throws NoSuchEntryException {
13285                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13286                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
13287                                    status, orderByComparator);
13288                    }
13289    
13290                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13291    
13292                    Session session = null;
13293    
13294                    try {
13295                            session = openSession();
13296    
13297                            BlogsEntry[] array = new BlogsEntryImpl[3];
13298    
13299                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13300                                            groupId, displayDate, status, orderByComparator, true);
13301    
13302                            array[1] = blogsEntry;
13303    
13304                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13305                                            groupId, displayDate, status, orderByComparator, false);
13306    
13307                            return array;
13308                    }
13309                    catch (Exception e) {
13310                            throw processException(e);
13311                    }
13312                    finally {
13313                            closeSession(session);
13314                    }
13315            }
13316    
13317            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
13318                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13319                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13320                    StringBundler query = null;
13321    
13322                    if (orderByComparator != null) {
13323                            query = new StringBundler(6 +
13324                                            (orderByComparator.getOrderByFields().length * 6));
13325                    }
13326                    else {
13327                            query = new StringBundler(3);
13328                    }
13329    
13330                    if (getDB().isSupportsInlineDistinct()) {
13331                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13332                    }
13333                    else {
13334                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13335                    }
13336    
13337                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13338    
13339                    boolean bindDisplayDate = false;
13340    
13341                    if (displayDate == null) {
13342                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13343                    }
13344                    else {
13345                            bindDisplayDate = true;
13346    
13347                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13348                    }
13349    
13350                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13351    
13352                    if (!getDB().isSupportsInlineDistinct()) {
13353                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13354                    }
13355    
13356                    if (orderByComparator != null) {
13357                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13358    
13359                            if (orderByConditionFields.length > 0) {
13360                                    query.append(WHERE_AND);
13361                            }
13362    
13363                            for (int i = 0; i < orderByConditionFields.length; i++) {
13364                                    if (getDB().isSupportsInlineDistinct()) {
13365                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13366                                    }
13367                                    else {
13368                                            query.append(_ORDER_BY_ENTITY_TABLE);
13369                                    }
13370    
13371                                    query.append(orderByConditionFields[i]);
13372    
13373                                    if ((i + 1) < orderByConditionFields.length) {
13374                                            if (orderByComparator.isAscending() ^ previous) {
13375                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13376                                            }
13377                                            else {
13378                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13379                                            }
13380                                    }
13381                                    else {
13382                                            if (orderByComparator.isAscending() ^ previous) {
13383                                                    query.append(WHERE_GREATER_THAN);
13384                                            }
13385                                            else {
13386                                                    query.append(WHERE_LESSER_THAN);
13387                                            }
13388                                    }
13389                            }
13390    
13391                            query.append(ORDER_BY_CLAUSE);
13392    
13393                            String[] orderByFields = orderByComparator.getOrderByFields();
13394    
13395                            for (int i = 0; i < orderByFields.length; i++) {
13396                                    if (getDB().isSupportsInlineDistinct()) {
13397                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13398                                    }
13399                                    else {
13400                                            query.append(_ORDER_BY_ENTITY_TABLE);
13401                                    }
13402    
13403                                    query.append(orderByFields[i]);
13404    
13405                                    if ((i + 1) < orderByFields.length) {
13406                                            if (orderByComparator.isAscending() ^ previous) {
13407                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13408                                            }
13409                                            else {
13410                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13411                                            }
13412                                    }
13413                                    else {
13414                                            if (orderByComparator.isAscending() ^ previous) {
13415                                                    query.append(ORDER_BY_ASC);
13416                                            }
13417                                            else {
13418                                                    query.append(ORDER_BY_DESC);
13419                                            }
13420                                    }
13421                            }
13422                    }
13423                    else {
13424                            if (getDB().isSupportsInlineDistinct()) {
13425                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13426                            }
13427                            else {
13428                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13429                            }
13430                    }
13431    
13432                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13433                                    BlogsEntry.class.getName(),
13434                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13435    
13436                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
13437    
13438                    q.setFirstResult(0);
13439                    q.setMaxResults(2);
13440    
13441                    if (getDB().isSupportsInlineDistinct()) {
13442                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13443                    }
13444                    else {
13445                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13446                    }
13447    
13448                    QueryPos qPos = QueryPos.getInstance(q);
13449    
13450                    qPos.add(groupId);
13451    
13452                    if (bindDisplayDate) {
13453                            qPos.add(new Timestamp(displayDate.getTime()));
13454                    }
13455    
13456                    qPos.add(status);
13457    
13458                    if (orderByComparator != null) {
13459                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13460    
13461                            for (Object value : values) {
13462                                    qPos.add(value);
13463                            }
13464                    }
13465    
13466                    List<BlogsEntry> list = q.list();
13467    
13468                    if (list.size() == 2) {
13469                            return list.get(1);
13470                    }
13471                    else {
13472                            return null;
13473                    }
13474            }
13475    
13476            /**
13477             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
13478             *
13479             * @param groupId the group ID
13480             * @param displayDate the display date
13481             * @param status the status
13482             */
13483            @Override
13484            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
13485                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
13486                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13487                            remove(blogsEntry);
13488                    }
13489            }
13490    
13491            /**
13492             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13493             *
13494             * @param groupId the group ID
13495             * @param displayDate the display date
13496             * @param status the status
13497             * @return the number of matching blogs entries
13498             */
13499            @Override
13500            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
13501                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
13502    
13503                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13504    
13505                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
13506    
13507                    if (count == null) {
13508                            StringBundler query = new StringBundler(4);
13509    
13510                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13511    
13512                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13513    
13514                            boolean bindDisplayDate = false;
13515    
13516                            if (displayDate == null) {
13517                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13518                            }
13519                            else {
13520                                    bindDisplayDate = true;
13521    
13522                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13523                            }
13524    
13525                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13526    
13527                            String sql = query.toString();
13528    
13529                            Session session = null;
13530    
13531                            try {
13532                                    session = openSession();
13533    
13534                                    Query q = session.createQuery(sql);
13535    
13536                                    QueryPos qPos = QueryPos.getInstance(q);
13537    
13538                                    qPos.add(groupId);
13539    
13540                                    if (bindDisplayDate) {
13541                                            qPos.add(new Timestamp(displayDate.getTime()));
13542                                    }
13543    
13544                                    qPos.add(status);
13545    
13546                                    count = (Long)q.uniqueResult();
13547    
13548                                    finderCache.putResult(finderPath, finderArgs, count);
13549                            }
13550                            catch (Exception e) {
13551                                    finderCache.removeResult(finderPath, finderArgs);
13552    
13553                                    throw processException(e);
13554                            }
13555                            finally {
13556                                    closeSession(session);
13557                            }
13558                    }
13559    
13560                    return count.intValue();
13561            }
13562    
13563            /**
13564             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13565             *
13566             * @param groupId the group ID
13567             * @param displayDate the display date
13568             * @param status the status
13569             * @return the number of matching blogs entries that the user has permission to view
13570             */
13571            @Override
13572            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
13573                    int status) {
13574                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13575                            return countByG_LtD_NotS(groupId, displayDate, status);
13576                    }
13577    
13578                    StringBundler query = new StringBundler(4);
13579    
13580                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13581    
13582                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13583    
13584                    boolean bindDisplayDate = false;
13585    
13586                    if (displayDate == null) {
13587                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13588                    }
13589                    else {
13590                            bindDisplayDate = true;
13591    
13592                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13593                    }
13594    
13595                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13596    
13597                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13598                                    BlogsEntry.class.getName(),
13599                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13600    
13601                    Session session = null;
13602    
13603                    try {
13604                            session = openSession();
13605    
13606                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13607    
13608                            q.addScalar(COUNT_COLUMN_NAME,
13609                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13610    
13611                            QueryPos qPos = QueryPos.getInstance(q);
13612    
13613                            qPos.add(groupId);
13614    
13615                            if (bindDisplayDate) {
13616                                    qPos.add(new Timestamp(displayDate.getTime()));
13617                            }
13618    
13619                            qPos.add(status);
13620    
13621                            Long count = (Long)q.uniqueResult();
13622    
13623                            return count.intValue();
13624                    }
13625                    catch (Exception e) {
13626                            throw processException(e);
13627                    }
13628                    finally {
13629                            closeSession(session);
13630                    }
13631            }
13632    
13633            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13634            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
13635            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13636            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
13637            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13638                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13639                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
13640                            new String[] {
13641                                    Long.class.getName(), Long.class.getName(),
13642                                    Integer.class.getName(),
13643                                    
13644                            Integer.class.getName(), Integer.class.getName(),
13645                                    OrderByComparator.class.getName()
13646                            });
13647            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13648                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13649                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
13650                            new String[] {
13651                                    Long.class.getName(), Long.class.getName(),
13652                                    Integer.class.getName()
13653                            },
13654                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
13655                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
13656                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
13657                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
13658                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
13659            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13660                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13661                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
13662                            new String[] {
13663                                    Long.class.getName(), Long.class.getName(),
13664                                    Integer.class.getName()
13665                            });
13666    
13667            /**
13668             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13669             *
13670             * @param companyId the company ID
13671             * @param userId the user ID
13672             * @param status the status
13673             * @return the matching blogs entries
13674             */
13675            @Override
13676            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
13677                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
13678                            QueryUtil.ALL_POS, null);
13679            }
13680    
13681            /**
13682             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13683             *
13684             * <p>
13685             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13686             * </p>
13687             *
13688             * @param companyId the company ID
13689             * @param userId the user ID
13690             * @param status the status
13691             * @param start the lower bound of the range of blogs entries
13692             * @param end the upper bound of the range of blogs entries (not inclusive)
13693             * @return the range of matching blogs entries
13694             */
13695            @Override
13696            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13697                    int status, int start, int end) {
13698                    return findByC_U_S(companyId, userId, status, start, end, null);
13699            }
13700    
13701            /**
13702             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13703             *
13704             * <p>
13705             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13706             * </p>
13707             *
13708             * @param companyId the company ID
13709             * @param userId the user ID
13710             * @param status the status
13711             * @param start the lower bound of the range of blogs entries
13712             * @param end the upper bound of the range of blogs entries (not inclusive)
13713             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13714             * @return the ordered range of matching blogs entries
13715             */
13716            @Override
13717            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13718                    int status, int start, int end,
13719                    OrderByComparator<BlogsEntry> orderByComparator) {
13720                    return findByC_U_S(companyId, userId, status, start, end,
13721                            orderByComparator, true);
13722            }
13723    
13724            /**
13725             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13726             *
13727             * <p>
13728             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13729             * </p>
13730             *
13731             * @param companyId the company ID
13732             * @param userId the user ID
13733             * @param status the status
13734             * @param start the lower bound of the range of blogs entries
13735             * @param end the upper bound of the range of blogs entries (not inclusive)
13736             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13737             * @param retrieveFromCache whether to retrieve from the finder cache
13738             * @return the ordered range of matching blogs entries
13739             */
13740            @Override
13741            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13742                    int status, int start, int end,
13743                    OrderByComparator<BlogsEntry> orderByComparator,
13744                    boolean retrieveFromCache) {
13745                    boolean pagination = true;
13746                    FinderPath finderPath = null;
13747                    Object[] finderArgs = null;
13748    
13749                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13750                                    (orderByComparator == null)) {
13751                            pagination = false;
13752                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
13753                            finderArgs = new Object[] { companyId, userId, status };
13754                    }
13755                    else {
13756                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
13757                            finderArgs = new Object[] {
13758                                            companyId, userId, status,
13759                                            
13760                                            start, end, orderByComparator
13761                                    };
13762                    }
13763    
13764                    List<BlogsEntry> list = null;
13765    
13766                    if (retrieveFromCache) {
13767                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
13768                                            finderArgs, this);
13769    
13770                            if ((list != null) && !list.isEmpty()) {
13771                                    for (BlogsEntry blogsEntry : list) {
13772                                            if ((companyId != blogsEntry.getCompanyId()) ||
13773                                                            (userId != blogsEntry.getUserId()) ||
13774                                                            (status != blogsEntry.getStatus())) {
13775                                                    list = null;
13776    
13777                                                    break;
13778                                            }
13779                                    }
13780                            }
13781                    }
13782    
13783                    if (list == null) {
13784                            StringBundler query = null;
13785    
13786                            if (orderByComparator != null) {
13787                                    query = new StringBundler(5 +
13788                                                    (orderByComparator.getOrderByFields().length * 3));
13789                            }
13790                            else {
13791                                    query = new StringBundler(5);
13792                            }
13793    
13794                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13795    
13796                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13797    
13798                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13799    
13800                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13801    
13802                            if (orderByComparator != null) {
13803                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13804                                            orderByComparator);
13805                            }
13806                            else
13807                             if (pagination) {
13808                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13809                            }
13810    
13811                            String sql = query.toString();
13812    
13813                            Session session = null;
13814    
13815                            try {
13816                                    session = openSession();
13817    
13818                                    Query q = session.createQuery(sql);
13819    
13820                                    QueryPos qPos = QueryPos.getInstance(q);
13821    
13822                                    qPos.add(companyId);
13823    
13824                                    qPos.add(userId);
13825    
13826                                    qPos.add(status);
13827    
13828                                    if (!pagination) {
13829                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13830                                                            start, end, false);
13831    
13832                                            Collections.sort(list);
13833    
13834                                            list = Collections.unmodifiableList(list);
13835                                    }
13836                                    else {
13837                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13838                                                            start, end);
13839                                    }
13840    
13841                                    cacheResult(list);
13842    
13843                                    finderCache.putResult(finderPath, finderArgs, list);
13844                            }
13845                            catch (Exception e) {
13846                                    finderCache.removeResult(finderPath, finderArgs);
13847    
13848                                    throw processException(e);
13849                            }
13850                            finally {
13851                                    closeSession(session);
13852                            }
13853                    }
13854    
13855                    return list;
13856            }
13857    
13858            /**
13859             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13860             *
13861             * @param companyId the company ID
13862             * @param userId the user ID
13863             * @param status the status
13864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13865             * @return the first matching blogs entry
13866             * @throws NoSuchEntryException if a matching blogs entry could not be found
13867             */
13868            @Override
13869            public BlogsEntry findByC_U_S_First(long companyId, long userId,
13870                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13871                    throws NoSuchEntryException {
13872                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
13873                                    orderByComparator);
13874    
13875                    if (blogsEntry != null) {
13876                            return blogsEntry;
13877                    }
13878    
13879                    StringBundler msg = new StringBundler(8);
13880    
13881                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13882    
13883                    msg.append("companyId=");
13884                    msg.append(companyId);
13885    
13886                    msg.append(", userId=");
13887                    msg.append(userId);
13888    
13889                    msg.append(", status=");
13890                    msg.append(status);
13891    
13892                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13893    
13894                    throw new NoSuchEntryException(msg.toString());
13895            }
13896    
13897            /**
13898             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13899             *
13900             * @param companyId the company ID
13901             * @param userId the user ID
13902             * @param status the status
13903             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13904             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13905             */
13906            @Override
13907            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
13908                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13909                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
13910                                    orderByComparator);
13911    
13912                    if (!list.isEmpty()) {
13913                            return list.get(0);
13914                    }
13915    
13916                    return null;
13917            }
13918    
13919            /**
13920             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13921             *
13922             * @param companyId the company ID
13923             * @param userId the user ID
13924             * @param status the status
13925             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13926             * @return the last matching blogs entry
13927             * @throws NoSuchEntryException if a matching blogs entry could not be found
13928             */
13929            @Override
13930            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
13931                    OrderByComparator<BlogsEntry> orderByComparator)
13932                    throws NoSuchEntryException {
13933                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
13934                                    orderByComparator);
13935    
13936                    if (blogsEntry != null) {
13937                            return blogsEntry;
13938                    }
13939    
13940                    StringBundler msg = new StringBundler(8);
13941    
13942                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13943    
13944                    msg.append("companyId=");
13945                    msg.append(companyId);
13946    
13947                    msg.append(", userId=");
13948                    msg.append(userId);
13949    
13950                    msg.append(", status=");
13951                    msg.append(status);
13952    
13953                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13954    
13955                    throw new NoSuchEntryException(msg.toString());
13956            }
13957    
13958            /**
13959             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13960             *
13961             * @param companyId the company ID
13962             * @param userId the user ID
13963             * @param status the status
13964             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13965             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13966             */
13967            @Override
13968            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
13969                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13970                    int count = countByC_U_S(companyId, userId, status);
13971    
13972                    if (count == 0) {
13973                            return null;
13974                    }
13975    
13976                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
13977                                    count - 1, count, orderByComparator);
13978    
13979                    if (!list.isEmpty()) {
13980                            return list.get(0);
13981                    }
13982    
13983                    return null;
13984            }
13985    
13986            /**
13987             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13988             *
13989             * @param entryId the primary key of the current blogs entry
13990             * @param companyId the company ID
13991             * @param userId the user ID
13992             * @param status the status
13993             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13994             * @return the previous, current, and next blogs entry
13995             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13996             */
13997            @Override
13998            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
13999                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
14000                    throws NoSuchEntryException {
14001                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14002    
14003                    Session session = null;
14004    
14005                    try {
14006                            session = openSession();
14007    
14008                            BlogsEntry[] array = new BlogsEntryImpl[3];
14009    
14010                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14011                                            userId, status, orderByComparator, true);
14012    
14013                            array[1] = blogsEntry;
14014    
14015                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14016                                            userId, status, orderByComparator, false);
14017    
14018                            return array;
14019                    }
14020                    catch (Exception e) {
14021                            throw processException(e);
14022                    }
14023                    finally {
14024                            closeSession(session);
14025                    }
14026            }
14027    
14028            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
14029                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14030                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14031                    StringBundler query = null;
14032    
14033                    if (orderByComparator != null) {
14034                            query = new StringBundler(6 +
14035                                            (orderByComparator.getOrderByFields().length * 6));
14036                    }
14037                    else {
14038                            query = new StringBundler(3);
14039                    }
14040    
14041                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14042    
14043                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14044    
14045                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14046    
14047                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14048    
14049                    if (orderByComparator != null) {
14050                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14051    
14052                            if (orderByConditionFields.length > 0) {
14053                                    query.append(WHERE_AND);
14054                            }
14055    
14056                            for (int i = 0; i < orderByConditionFields.length; i++) {
14057                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14058                                    query.append(orderByConditionFields[i]);
14059    
14060                                    if ((i + 1) < orderByConditionFields.length) {
14061                                            if (orderByComparator.isAscending() ^ previous) {
14062                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14063                                            }
14064                                            else {
14065                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14066                                            }
14067                                    }
14068                                    else {
14069                                            if (orderByComparator.isAscending() ^ previous) {
14070                                                    query.append(WHERE_GREATER_THAN);
14071                                            }
14072                                            else {
14073                                                    query.append(WHERE_LESSER_THAN);
14074                                            }
14075                                    }
14076                            }
14077    
14078                            query.append(ORDER_BY_CLAUSE);
14079    
14080                            String[] orderByFields = orderByComparator.getOrderByFields();
14081    
14082                            for (int i = 0; i < orderByFields.length; i++) {
14083                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14084                                    query.append(orderByFields[i]);
14085    
14086                                    if ((i + 1) < orderByFields.length) {
14087                                            if (orderByComparator.isAscending() ^ previous) {
14088                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14089                                            }
14090                                            else {
14091                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14092                                            }
14093                                    }
14094                                    else {
14095                                            if (orderByComparator.isAscending() ^ previous) {
14096                                                    query.append(ORDER_BY_ASC);
14097                                            }
14098                                            else {
14099                                                    query.append(ORDER_BY_DESC);
14100                                            }
14101                                    }
14102                            }
14103                    }
14104                    else {
14105                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14106                    }
14107    
14108                    String sql = query.toString();
14109    
14110                    Query q = session.createQuery(sql);
14111    
14112                    q.setFirstResult(0);
14113                    q.setMaxResults(2);
14114    
14115                    QueryPos qPos = QueryPos.getInstance(q);
14116    
14117                    qPos.add(companyId);
14118    
14119                    qPos.add(userId);
14120    
14121                    qPos.add(status);
14122    
14123                    if (orderByComparator != null) {
14124                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14125    
14126                            for (Object value : values) {
14127                                    qPos.add(value);
14128                            }
14129                    }
14130    
14131                    List<BlogsEntry> list = q.list();
14132    
14133                    if (list.size() == 2) {
14134                            return list.get(1);
14135                    }
14136                    else {
14137                            return null;
14138                    }
14139            }
14140    
14141            /**
14142             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
14143             *
14144             * @param companyId the company ID
14145             * @param userId the user ID
14146             * @param status the status
14147             */
14148            @Override
14149            public void removeByC_U_S(long companyId, long userId, int status) {
14150                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
14151                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14152                            remove(blogsEntry);
14153                    }
14154            }
14155    
14156            /**
14157             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14158             *
14159             * @param companyId the company ID
14160             * @param userId the user ID
14161             * @param status the status
14162             * @return the number of matching blogs entries
14163             */
14164            @Override
14165            public int countByC_U_S(long companyId, long userId, int status) {
14166                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
14167    
14168                    Object[] finderArgs = new Object[] { companyId, userId, status };
14169    
14170                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14171    
14172                    if (count == null) {
14173                            StringBundler query = new StringBundler(4);
14174    
14175                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14176    
14177                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14178    
14179                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14180    
14181                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14182    
14183                            String sql = query.toString();
14184    
14185                            Session session = null;
14186    
14187                            try {
14188                                    session = openSession();
14189    
14190                                    Query q = session.createQuery(sql);
14191    
14192                                    QueryPos qPos = QueryPos.getInstance(q);
14193    
14194                                    qPos.add(companyId);
14195    
14196                                    qPos.add(userId);
14197    
14198                                    qPos.add(status);
14199    
14200                                    count = (Long)q.uniqueResult();
14201    
14202                                    finderCache.putResult(finderPath, finderArgs, count);
14203                            }
14204                            catch (Exception e) {
14205                                    finderCache.removeResult(finderPath, finderArgs);
14206    
14207                                    throw processException(e);
14208                            }
14209                            finally {
14210                                    closeSession(session);
14211                            }
14212                    }
14213    
14214                    return count.intValue();
14215            }
14216    
14217            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14218            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
14219            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
14220            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14221                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14222                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
14223                            new String[] {
14224                                    Long.class.getName(), Long.class.getName(),
14225                                    Integer.class.getName(),
14226                                    
14227                            Integer.class.getName(), Integer.class.getName(),
14228                                    OrderByComparator.class.getName()
14229                            });
14230            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
14231                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14232                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14233                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
14234                            new String[] {
14235                                    Long.class.getName(), Long.class.getName(),
14236                                    Integer.class.getName()
14237                            });
14238    
14239            /**
14240             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14241             *
14242             * @param companyId the company ID
14243             * @param userId the user ID
14244             * @param status the status
14245             * @return the matching blogs entries
14246             */
14247            @Override
14248            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14249                    int status) {
14250                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
14251                            QueryUtil.ALL_POS, null);
14252            }
14253    
14254            /**
14255             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14256             *
14257             * <p>
14258             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14259             * </p>
14260             *
14261             * @param companyId the company ID
14262             * @param userId the user ID
14263             * @param status the status
14264             * @param start the lower bound of the range of blogs entries
14265             * @param end the upper bound of the range of blogs entries (not inclusive)
14266             * @return the range of matching blogs entries
14267             */
14268            @Override
14269            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14270                    int status, int start, int end) {
14271                    return findByC_U_NotS(companyId, userId, status, start, end, null);
14272            }
14273    
14274            /**
14275             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14276             *
14277             * <p>
14278             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14279             * </p>
14280             *
14281             * @param companyId the company ID
14282             * @param userId the user ID
14283             * @param status the status
14284             * @param start the lower bound of the range of blogs entries
14285             * @param end the upper bound of the range of blogs entries (not inclusive)
14286             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14287             * @return the ordered range of matching blogs entries
14288             */
14289            @Override
14290            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14291                    int status, int start, int end,
14292                    OrderByComparator<BlogsEntry> orderByComparator) {
14293                    return findByC_U_NotS(companyId, userId, status, start, end,
14294                            orderByComparator, true);
14295            }
14296    
14297            /**
14298             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14299             *
14300             * <p>
14301             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14302             * </p>
14303             *
14304             * @param companyId the company ID
14305             * @param userId the user ID
14306             * @param status the status
14307             * @param start the lower bound of the range of blogs entries
14308             * @param end the upper bound of the range of blogs entries (not inclusive)
14309             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14310             * @param retrieveFromCache whether to retrieve from the finder cache
14311             * @return the ordered range of matching blogs entries
14312             */
14313            @Override
14314            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14315                    int status, int start, int end,
14316                    OrderByComparator<BlogsEntry> orderByComparator,
14317                    boolean retrieveFromCache) {
14318                    boolean pagination = true;
14319                    FinderPath finderPath = null;
14320                    Object[] finderArgs = null;
14321    
14322                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
14323                    finderArgs = new Object[] {
14324                                    companyId, userId, status,
14325                                    
14326                                    start, end, orderByComparator
14327                            };
14328    
14329                    List<BlogsEntry> list = null;
14330    
14331                    if (retrieveFromCache) {
14332                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14333                                            finderArgs, this);
14334    
14335                            if ((list != null) && !list.isEmpty()) {
14336                                    for (BlogsEntry blogsEntry : list) {
14337                                            if ((companyId != blogsEntry.getCompanyId()) ||
14338                                                            (userId != blogsEntry.getUserId()) ||
14339                                                            (status == blogsEntry.getStatus())) {
14340                                                    list = null;
14341    
14342                                                    break;
14343                                            }
14344                                    }
14345                            }
14346                    }
14347    
14348                    if (list == null) {
14349                            StringBundler query = null;
14350    
14351                            if (orderByComparator != null) {
14352                                    query = new StringBundler(5 +
14353                                                    (orderByComparator.getOrderByFields().length * 3));
14354                            }
14355                            else {
14356                                    query = new StringBundler(5);
14357                            }
14358    
14359                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14360    
14361                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14362    
14363                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14364    
14365                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14366    
14367                            if (orderByComparator != null) {
14368                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14369                                            orderByComparator);
14370                            }
14371                            else
14372                             if (pagination) {
14373                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14374                            }
14375    
14376                            String sql = query.toString();
14377    
14378                            Session session = null;
14379    
14380                            try {
14381                                    session = openSession();
14382    
14383                                    Query q = session.createQuery(sql);
14384    
14385                                    QueryPos qPos = QueryPos.getInstance(q);
14386    
14387                                    qPos.add(companyId);
14388    
14389                                    qPos.add(userId);
14390    
14391                                    qPos.add(status);
14392    
14393                                    if (!pagination) {
14394                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14395                                                            start, end, false);
14396    
14397                                            Collections.sort(list);
14398    
14399                                            list = Collections.unmodifiableList(list);
14400                                    }
14401                                    else {
14402                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14403                                                            start, end);
14404                                    }
14405    
14406                                    cacheResult(list);
14407    
14408                                    finderCache.putResult(finderPath, finderArgs, list);
14409                            }
14410                            catch (Exception e) {
14411                                    finderCache.removeResult(finderPath, finderArgs);
14412    
14413                                    throw processException(e);
14414                            }
14415                            finally {
14416                                    closeSession(session);
14417                            }
14418                    }
14419    
14420                    return list;
14421            }
14422    
14423            /**
14424             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14425             *
14426             * @param companyId the company ID
14427             * @param userId the user ID
14428             * @param status the status
14429             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14430             * @return the first matching blogs entry
14431             * @throws NoSuchEntryException if a matching blogs entry could not be found
14432             */
14433            @Override
14434            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
14435                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14436                    throws NoSuchEntryException {
14437                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
14438                                    status, orderByComparator);
14439    
14440                    if (blogsEntry != null) {
14441                            return blogsEntry;
14442                    }
14443    
14444                    StringBundler msg = new StringBundler(8);
14445    
14446                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14447    
14448                    msg.append("companyId=");
14449                    msg.append(companyId);
14450    
14451                    msg.append(", userId=");
14452                    msg.append(userId);
14453    
14454                    msg.append(", status=");
14455                    msg.append(status);
14456    
14457                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14458    
14459                    throw new NoSuchEntryException(msg.toString());
14460            }
14461    
14462            /**
14463             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14464             *
14465             * @param companyId the company ID
14466             * @param userId the user ID
14467             * @param status the status
14468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14469             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14470             */
14471            @Override
14472            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
14473                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14474                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
14475                                    orderByComparator);
14476    
14477                    if (!list.isEmpty()) {
14478                            return list.get(0);
14479                    }
14480    
14481                    return null;
14482            }
14483    
14484            /**
14485             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14486             *
14487             * @param companyId the company ID
14488             * @param userId the user ID
14489             * @param status the status
14490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14491             * @return the last matching blogs entry
14492             * @throws NoSuchEntryException if a matching blogs entry could not be found
14493             */
14494            @Override
14495            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
14496                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14497                    throws NoSuchEntryException {
14498                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
14499                                    orderByComparator);
14500    
14501                    if (blogsEntry != null) {
14502                            return blogsEntry;
14503                    }
14504    
14505                    StringBundler msg = new StringBundler(8);
14506    
14507                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14508    
14509                    msg.append("companyId=");
14510                    msg.append(companyId);
14511    
14512                    msg.append(", userId=");
14513                    msg.append(userId);
14514    
14515                    msg.append(", status=");
14516                    msg.append(status);
14517    
14518                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14519    
14520                    throw new NoSuchEntryException(msg.toString());
14521            }
14522    
14523            /**
14524             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14525             *
14526             * @param companyId the company ID
14527             * @param userId the user ID
14528             * @param status the status
14529             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14530             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14531             */
14532            @Override
14533            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
14534                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14535                    int count = countByC_U_NotS(companyId, userId, status);
14536    
14537                    if (count == 0) {
14538                            return null;
14539                    }
14540    
14541                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
14542                                    count - 1, count, orderByComparator);
14543    
14544                    if (!list.isEmpty()) {
14545                            return list.get(0);
14546                    }
14547    
14548                    return null;
14549            }
14550    
14551            /**
14552             * 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;.
14553             *
14554             * @param entryId the primary key of the current blogs entry
14555             * @param companyId the company ID
14556             * @param userId the user ID
14557             * @param status the status
14558             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14559             * @return the previous, current, and next blogs entry
14560             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14561             */
14562            @Override
14563            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
14564                    long companyId, long userId, int status,
14565                    OrderByComparator<BlogsEntry> orderByComparator)
14566                    throws NoSuchEntryException {
14567                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14568    
14569                    Session session = null;
14570    
14571                    try {
14572                            session = openSession();
14573    
14574                            BlogsEntry[] array = new BlogsEntryImpl[3];
14575    
14576                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14577                                            companyId, userId, status, orderByComparator, true);
14578    
14579                            array[1] = blogsEntry;
14580    
14581                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14582                                            companyId, userId, status, orderByComparator, false);
14583    
14584                            return array;
14585                    }
14586                    catch (Exception e) {
14587                            throw processException(e);
14588                    }
14589                    finally {
14590                            closeSession(session);
14591                    }
14592            }
14593    
14594            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
14595                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14596                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14597                    StringBundler query = null;
14598    
14599                    if (orderByComparator != null) {
14600                            query = new StringBundler(6 +
14601                                            (orderByComparator.getOrderByFields().length * 6));
14602                    }
14603                    else {
14604                            query = new StringBundler(3);
14605                    }
14606    
14607                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14608    
14609                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14610    
14611                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14612    
14613                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14614    
14615                    if (orderByComparator != null) {
14616                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14617    
14618                            if (orderByConditionFields.length > 0) {
14619                                    query.append(WHERE_AND);
14620                            }
14621    
14622                            for (int i = 0; i < orderByConditionFields.length; i++) {
14623                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14624                                    query.append(orderByConditionFields[i]);
14625    
14626                                    if ((i + 1) < orderByConditionFields.length) {
14627                                            if (orderByComparator.isAscending() ^ previous) {
14628                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14629                                            }
14630                                            else {
14631                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14632                                            }
14633                                    }
14634                                    else {
14635                                            if (orderByComparator.isAscending() ^ previous) {
14636                                                    query.append(WHERE_GREATER_THAN);
14637                                            }
14638                                            else {
14639                                                    query.append(WHERE_LESSER_THAN);
14640                                            }
14641                                    }
14642                            }
14643    
14644                            query.append(ORDER_BY_CLAUSE);
14645    
14646                            String[] orderByFields = orderByComparator.getOrderByFields();
14647    
14648                            for (int i = 0; i < orderByFields.length; i++) {
14649                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14650                                    query.append(orderByFields[i]);
14651    
14652                                    if ((i + 1) < orderByFields.length) {
14653                                            if (orderByComparator.isAscending() ^ previous) {
14654                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14655                                            }
14656                                            else {
14657                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14658                                            }
14659                                    }
14660                                    else {
14661                                            if (orderByComparator.isAscending() ^ previous) {
14662                                                    query.append(ORDER_BY_ASC);
14663                                            }
14664                                            else {
14665                                                    query.append(ORDER_BY_DESC);
14666                                            }
14667                                    }
14668                            }
14669                    }
14670                    else {
14671                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14672                    }
14673    
14674                    String sql = query.toString();
14675    
14676                    Query q = session.createQuery(sql);
14677    
14678                    q.setFirstResult(0);
14679                    q.setMaxResults(2);
14680    
14681                    QueryPos qPos = QueryPos.getInstance(q);
14682    
14683                    qPos.add(companyId);
14684    
14685                    qPos.add(userId);
14686    
14687                    qPos.add(status);
14688    
14689                    if (orderByComparator != null) {
14690                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14691    
14692                            for (Object value : values) {
14693                                    qPos.add(value);
14694                            }
14695                    }
14696    
14697                    List<BlogsEntry> list = q.list();
14698    
14699                    if (list.size() == 2) {
14700                            return list.get(1);
14701                    }
14702                    else {
14703                            return null;
14704                    }
14705            }
14706    
14707            /**
14708             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
14709             *
14710             * @param companyId the company ID
14711             * @param userId the user ID
14712             * @param status the status
14713             */
14714            @Override
14715            public void removeByC_U_NotS(long companyId, long userId, int status) {
14716                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
14717                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14718                            remove(blogsEntry);
14719                    }
14720            }
14721    
14722            /**
14723             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14724             *
14725             * @param companyId the company ID
14726             * @param userId the user ID
14727             * @param status the status
14728             * @return the number of matching blogs entries
14729             */
14730            @Override
14731            public int countByC_U_NotS(long companyId, long userId, int status) {
14732                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
14733    
14734                    Object[] finderArgs = new Object[] { companyId, userId, status };
14735    
14736                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14737    
14738                    if (count == null) {
14739                            StringBundler query = new StringBundler(4);
14740    
14741                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14742    
14743                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14744    
14745                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14746    
14747                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14748    
14749                            String sql = query.toString();
14750    
14751                            Session session = null;
14752    
14753                            try {
14754                                    session = openSession();
14755    
14756                                    Query q = session.createQuery(sql);
14757    
14758                                    QueryPos qPos = QueryPos.getInstance(q);
14759    
14760                                    qPos.add(companyId);
14761    
14762                                    qPos.add(userId);
14763    
14764                                    qPos.add(status);
14765    
14766                                    count = (Long)q.uniqueResult();
14767    
14768                                    finderCache.putResult(finderPath, finderArgs, count);
14769                            }
14770                            catch (Exception e) {
14771                                    finderCache.removeResult(finderPath, finderArgs);
14772    
14773                                    throw processException(e);
14774                            }
14775                            finally {
14776                                    closeSession(session);
14777                            }
14778                    }
14779    
14780                    return count.intValue();
14781            }
14782    
14783            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14784            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
14785            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
14786            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14787                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14788                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
14789                            new String[] {
14790                                    Long.class.getName(), Date.class.getName(),
14791                                    Integer.class.getName(),
14792                                    
14793                            Integer.class.getName(), Integer.class.getName(),
14794                                    OrderByComparator.class.getName()
14795                            });
14796            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14797                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14798                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
14799                            new String[] {
14800                                    Long.class.getName(), Date.class.getName(),
14801                                    Integer.class.getName()
14802                            });
14803    
14804            /**
14805             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14806             *
14807             * @param companyId the company ID
14808             * @param displayDate the display date
14809             * @param status the status
14810             * @return the matching blogs entries
14811             */
14812            @Override
14813            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14814                    int status) {
14815                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
14816                            QueryUtil.ALL_POS, null);
14817            }
14818    
14819            /**
14820             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14821             *
14822             * <p>
14823             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14824             * </p>
14825             *
14826             * @param companyId the company ID
14827             * @param displayDate the display date
14828             * @param status the status
14829             * @param start the lower bound of the range of blogs entries
14830             * @param end the upper bound of the range of blogs entries (not inclusive)
14831             * @return the range of matching blogs entries
14832             */
14833            @Override
14834            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14835                    int status, int start, int end) {
14836                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
14837            }
14838    
14839            /**
14840             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14841             *
14842             * <p>
14843             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14844             * </p>
14845             *
14846             * @param companyId the company ID
14847             * @param displayDate the display date
14848             * @param status the status
14849             * @param start the lower bound of the range of blogs entries
14850             * @param end the upper bound of the range of blogs entries (not inclusive)
14851             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14852             * @return the ordered range of matching blogs entries
14853             */
14854            @Override
14855            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14856                    int status, int start, int end,
14857                    OrderByComparator<BlogsEntry> orderByComparator) {
14858                    return findByC_LtD_S(companyId, displayDate, status, start, end,
14859                            orderByComparator, true);
14860            }
14861    
14862            /**
14863             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14864             *
14865             * <p>
14866             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14867             * </p>
14868             *
14869             * @param companyId the company ID
14870             * @param displayDate the display date
14871             * @param status the status
14872             * @param start the lower bound of the range of blogs entries
14873             * @param end the upper bound of the range of blogs entries (not inclusive)
14874             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14875             * @param retrieveFromCache whether to retrieve from the finder cache
14876             * @return the ordered range of matching blogs entries
14877             */
14878            @Override
14879            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14880                    int status, int start, int end,
14881                    OrderByComparator<BlogsEntry> orderByComparator,
14882                    boolean retrieveFromCache) {
14883                    boolean pagination = true;
14884                    FinderPath finderPath = null;
14885                    Object[] finderArgs = null;
14886    
14887                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
14888                    finderArgs = new Object[] {
14889                                    companyId, displayDate, status,
14890                                    
14891                                    start, end, orderByComparator
14892                            };
14893    
14894                    List<BlogsEntry> list = null;
14895    
14896                    if (retrieveFromCache) {
14897                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14898                                            finderArgs, this);
14899    
14900                            if ((list != null) && !list.isEmpty()) {
14901                                    for (BlogsEntry blogsEntry : list) {
14902                                            if ((companyId != blogsEntry.getCompanyId()) ||
14903                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
14904                                                                                                                                            .getTime()) ||
14905                                                            (status != blogsEntry.getStatus())) {
14906                                                    list = null;
14907    
14908                                                    break;
14909                                            }
14910                                    }
14911                            }
14912                    }
14913    
14914                    if (list == null) {
14915                            StringBundler query = null;
14916    
14917                            if (orderByComparator != null) {
14918                                    query = new StringBundler(5 +
14919                                                    (orderByComparator.getOrderByFields().length * 3));
14920                            }
14921                            else {
14922                                    query = new StringBundler(5);
14923                            }
14924    
14925                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14926    
14927                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14928    
14929                            boolean bindDisplayDate = false;
14930    
14931                            if (displayDate == null) {
14932                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14933                            }
14934                            else {
14935                                    bindDisplayDate = true;
14936    
14937                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14938                            }
14939    
14940                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14941    
14942                            if (orderByComparator != null) {
14943                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14944                                            orderByComparator);
14945                            }
14946                            else
14947                             if (pagination) {
14948                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14949                            }
14950    
14951                            String sql = query.toString();
14952    
14953                            Session session = null;
14954    
14955                            try {
14956                                    session = openSession();
14957    
14958                                    Query q = session.createQuery(sql);
14959    
14960                                    QueryPos qPos = QueryPos.getInstance(q);
14961    
14962                                    qPos.add(companyId);
14963    
14964                                    if (bindDisplayDate) {
14965                                            qPos.add(new Timestamp(displayDate.getTime()));
14966                                    }
14967    
14968                                    qPos.add(status);
14969    
14970                                    if (!pagination) {
14971                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14972                                                            start, end, false);
14973    
14974                                            Collections.sort(list);
14975    
14976                                            list = Collections.unmodifiableList(list);
14977                                    }
14978                                    else {
14979                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14980                                                            start, end);
14981                                    }
14982    
14983                                    cacheResult(list);
14984    
14985                                    finderCache.putResult(finderPath, finderArgs, list);
14986                            }
14987                            catch (Exception e) {
14988                                    finderCache.removeResult(finderPath, finderArgs);
14989    
14990                                    throw processException(e);
14991                            }
14992                            finally {
14993                                    closeSession(session);
14994                            }
14995                    }
14996    
14997                    return list;
14998            }
14999    
15000            /**
15001             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15002             *
15003             * @param companyId the company ID
15004             * @param displayDate the display date
15005             * @param status the status
15006             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15007             * @return the first matching blogs entry
15008             * @throws NoSuchEntryException if a matching blogs entry could not be found
15009             */
15010            @Override
15011            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
15012                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15013                    throws NoSuchEntryException {
15014                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
15015                                    status, orderByComparator);
15016    
15017                    if (blogsEntry != null) {
15018                            return blogsEntry;
15019                    }
15020    
15021                    StringBundler msg = new StringBundler(8);
15022    
15023                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15024    
15025                    msg.append("companyId=");
15026                    msg.append(companyId);
15027    
15028                    msg.append(", displayDate=");
15029                    msg.append(displayDate);
15030    
15031                    msg.append(", status=");
15032                    msg.append(status);
15033    
15034                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15035    
15036                    throw new NoSuchEntryException(msg.toString());
15037            }
15038    
15039            /**
15040             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15041             *
15042             * @param companyId the company ID
15043             * @param displayDate the display date
15044             * @param status the status
15045             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15046             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15047             */
15048            @Override
15049            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
15050                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15051                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15052                                    0, 1, orderByComparator);
15053    
15054                    if (!list.isEmpty()) {
15055                            return list.get(0);
15056                    }
15057    
15058                    return null;
15059            }
15060    
15061            /**
15062             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15063             *
15064             * @param companyId the company ID
15065             * @param displayDate the display date
15066             * @param status the status
15067             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15068             * @return the last matching blogs entry
15069             * @throws NoSuchEntryException if a matching blogs entry could not be found
15070             */
15071            @Override
15072            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
15073                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15074                    throws NoSuchEntryException {
15075                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
15076                                    status, orderByComparator);
15077    
15078                    if (blogsEntry != null) {
15079                            return blogsEntry;
15080                    }
15081    
15082                    StringBundler msg = new StringBundler(8);
15083    
15084                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15085    
15086                    msg.append("companyId=");
15087                    msg.append(companyId);
15088    
15089                    msg.append(", displayDate=");
15090                    msg.append(displayDate);
15091    
15092                    msg.append(", status=");
15093                    msg.append(status);
15094    
15095                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15096    
15097                    throw new NoSuchEntryException(msg.toString());
15098            }
15099    
15100            /**
15101             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15102             *
15103             * @param companyId the company ID
15104             * @param displayDate the display date
15105             * @param status the status
15106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15107             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15108             */
15109            @Override
15110            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
15111                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15112                    int count = countByC_LtD_S(companyId, displayDate, status);
15113    
15114                    if (count == 0) {
15115                            return null;
15116                    }
15117    
15118                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15119                                    count - 1, count, orderByComparator);
15120    
15121                    if (!list.isEmpty()) {
15122                            return list.get(0);
15123                    }
15124    
15125                    return null;
15126            }
15127    
15128            /**
15129             * 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;.
15130             *
15131             * @param entryId the primary key of the current blogs entry
15132             * @param companyId the company ID
15133             * @param displayDate the display date
15134             * @param status the status
15135             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15136             * @return the previous, current, and next blogs entry
15137             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15138             */
15139            @Override
15140            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
15141                    Date displayDate, int status,
15142                    OrderByComparator<BlogsEntry> orderByComparator)
15143                    throws NoSuchEntryException {
15144                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15145    
15146                    Session session = null;
15147    
15148                    try {
15149                            session = openSession();
15150    
15151                            BlogsEntry[] array = new BlogsEntryImpl[3];
15152    
15153                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15154                                            displayDate, status, orderByComparator, true);
15155    
15156                            array[1] = blogsEntry;
15157    
15158                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15159                                            displayDate, status, orderByComparator, false);
15160    
15161                            return array;
15162                    }
15163                    catch (Exception e) {
15164                            throw processException(e);
15165                    }
15166                    finally {
15167                            closeSession(session);
15168                    }
15169            }
15170    
15171            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
15172                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15173                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15174                    StringBundler query = null;
15175    
15176                    if (orderByComparator != null) {
15177                            query = new StringBundler(6 +
15178                                            (orderByComparator.getOrderByFields().length * 6));
15179                    }
15180                    else {
15181                            query = new StringBundler(3);
15182                    }
15183    
15184                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15185    
15186                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15187    
15188                    boolean bindDisplayDate = false;
15189    
15190                    if (displayDate == null) {
15191                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15192                    }
15193                    else {
15194                            bindDisplayDate = true;
15195    
15196                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15197                    }
15198    
15199                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15200    
15201                    if (orderByComparator != null) {
15202                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15203    
15204                            if (orderByConditionFields.length > 0) {
15205                                    query.append(WHERE_AND);
15206                            }
15207    
15208                            for (int i = 0; i < orderByConditionFields.length; i++) {
15209                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15210                                    query.append(orderByConditionFields[i]);
15211    
15212                                    if ((i + 1) < orderByConditionFields.length) {
15213                                            if (orderByComparator.isAscending() ^ previous) {
15214                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15215                                            }
15216                                            else {
15217                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15218                                            }
15219                                    }
15220                                    else {
15221                                            if (orderByComparator.isAscending() ^ previous) {
15222                                                    query.append(WHERE_GREATER_THAN);
15223                                            }
15224                                            else {
15225                                                    query.append(WHERE_LESSER_THAN);
15226                                            }
15227                                    }
15228                            }
15229    
15230                            query.append(ORDER_BY_CLAUSE);
15231    
15232                            String[] orderByFields = orderByComparator.getOrderByFields();
15233    
15234                            for (int i = 0; i < orderByFields.length; i++) {
15235                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15236                                    query.append(orderByFields[i]);
15237    
15238                                    if ((i + 1) < orderByFields.length) {
15239                                            if (orderByComparator.isAscending() ^ previous) {
15240                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15241                                            }
15242                                            else {
15243                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15244                                            }
15245                                    }
15246                                    else {
15247                                            if (orderByComparator.isAscending() ^ previous) {
15248                                                    query.append(ORDER_BY_ASC);
15249                                            }
15250                                            else {
15251                                                    query.append(ORDER_BY_DESC);
15252                                            }
15253                                    }
15254                            }
15255                    }
15256                    else {
15257                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15258                    }
15259    
15260                    String sql = query.toString();
15261    
15262                    Query q = session.createQuery(sql);
15263    
15264                    q.setFirstResult(0);
15265                    q.setMaxResults(2);
15266    
15267                    QueryPos qPos = QueryPos.getInstance(q);
15268    
15269                    qPos.add(companyId);
15270    
15271                    if (bindDisplayDate) {
15272                            qPos.add(new Timestamp(displayDate.getTime()));
15273                    }
15274    
15275                    qPos.add(status);
15276    
15277                    if (orderByComparator != null) {
15278                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15279    
15280                            for (Object value : values) {
15281                                    qPos.add(value);
15282                            }
15283                    }
15284    
15285                    List<BlogsEntry> list = q.list();
15286    
15287                    if (list.size() == 2) {
15288                            return list.get(1);
15289                    }
15290                    else {
15291                            return null;
15292                    }
15293            }
15294    
15295            /**
15296             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15297             *
15298             * @param companyId the company ID
15299             * @param displayDate the display date
15300             * @param status the status
15301             */
15302            @Override
15303            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
15304                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
15305                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15306                            remove(blogsEntry);
15307                    }
15308            }
15309    
15310            /**
15311             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15312             *
15313             * @param companyId the company ID
15314             * @param displayDate the display date
15315             * @param status the status
15316             * @return the number of matching blogs entries
15317             */
15318            @Override
15319            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
15320                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
15321    
15322                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15323    
15324                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15325    
15326                    if (count == null) {
15327                            StringBundler query = new StringBundler(4);
15328    
15329                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15330    
15331                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15332    
15333                            boolean bindDisplayDate = false;
15334    
15335                            if (displayDate == null) {
15336                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15337                            }
15338                            else {
15339                                    bindDisplayDate = true;
15340    
15341                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15342                            }
15343    
15344                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15345    
15346                            String sql = query.toString();
15347    
15348                            Session session = null;
15349    
15350                            try {
15351                                    session = openSession();
15352    
15353                                    Query q = session.createQuery(sql);
15354    
15355                                    QueryPos qPos = QueryPos.getInstance(q);
15356    
15357                                    qPos.add(companyId);
15358    
15359                                    if (bindDisplayDate) {
15360                                            qPos.add(new Timestamp(displayDate.getTime()));
15361                                    }
15362    
15363                                    qPos.add(status);
15364    
15365                                    count = (Long)q.uniqueResult();
15366    
15367                                    finderCache.putResult(finderPath, finderArgs, count);
15368                            }
15369                            catch (Exception e) {
15370                                    finderCache.removeResult(finderPath, finderArgs);
15371    
15372                                    throw processException(e);
15373                            }
15374                            finally {
15375                                    closeSession(session);
15376                            }
15377                    }
15378    
15379                    return count.intValue();
15380            }
15381    
15382            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15383            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15384            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15385            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15386            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
15387                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15388                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15389                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
15390                            new String[] {
15391                                    Long.class.getName(), Date.class.getName(),
15392                                    Integer.class.getName(),
15393                                    
15394                            Integer.class.getName(), Integer.class.getName(),
15395                                    OrderByComparator.class.getName()
15396                            });
15397            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
15398                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15399                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15400                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
15401                            new String[] {
15402                                    Long.class.getName(), Date.class.getName(),
15403                                    Integer.class.getName()
15404                            });
15405    
15406            /**
15407             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15408             *
15409             * @param companyId the company ID
15410             * @param displayDate the display date
15411             * @param status the status
15412             * @return the matching blogs entries
15413             */
15414            @Override
15415            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15416                    int status) {
15417                    return findByC_LtD_NotS(companyId, displayDate, status,
15418                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15419            }
15420    
15421            /**
15422             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15423             *
15424             * <p>
15425             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15426             * </p>
15427             *
15428             * @param companyId the company ID
15429             * @param displayDate the display date
15430             * @param status the status
15431             * @param start the lower bound of the range of blogs entries
15432             * @param end the upper bound of the range of blogs entries (not inclusive)
15433             * @return the range of matching blogs entries
15434             */
15435            @Override
15436            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15437                    int status, int start, int end) {
15438                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
15439            }
15440    
15441            /**
15442             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15443             *
15444             * <p>
15445             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15446             * </p>
15447             *
15448             * @param companyId the company ID
15449             * @param displayDate the display date
15450             * @param status the status
15451             * @param start the lower bound of the range of blogs entries
15452             * @param end the upper bound of the range of blogs entries (not inclusive)
15453             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15454             * @return the ordered range of matching blogs entries
15455             */
15456            @Override
15457            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15458                    int status, int start, int end,
15459                    OrderByComparator<BlogsEntry> orderByComparator) {
15460                    return findByC_LtD_NotS(companyId, displayDate, status, start, end,
15461                            orderByComparator, true);
15462            }
15463    
15464            /**
15465             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15466             *
15467             * <p>
15468             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15469             * </p>
15470             *
15471             * @param companyId the company ID
15472             * @param displayDate the display date
15473             * @param status the status
15474             * @param start the lower bound of the range of blogs entries
15475             * @param end the upper bound of the range of blogs entries (not inclusive)
15476             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15477             * @param retrieveFromCache whether to retrieve from the finder cache
15478             * @return the ordered range of matching blogs entries
15479             */
15480            @Override
15481            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15482                    int status, int start, int end,
15483                    OrderByComparator<BlogsEntry> orderByComparator,
15484                    boolean retrieveFromCache) {
15485                    boolean pagination = true;
15486                    FinderPath finderPath = null;
15487                    Object[] finderArgs = null;
15488    
15489                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
15490                    finderArgs = new Object[] {
15491                                    companyId, displayDate, status,
15492                                    
15493                                    start, end, orderByComparator
15494                            };
15495    
15496                    List<BlogsEntry> list = null;
15497    
15498                    if (retrieveFromCache) {
15499                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
15500                                            finderArgs, this);
15501    
15502                            if ((list != null) && !list.isEmpty()) {
15503                                    for (BlogsEntry blogsEntry : list) {
15504                                            if ((companyId != blogsEntry.getCompanyId()) ||
15505                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
15506                                                                                                                                            .getTime()) ||
15507                                                            (status == blogsEntry.getStatus())) {
15508                                                    list = null;
15509    
15510                                                    break;
15511                                            }
15512                                    }
15513                            }
15514                    }
15515    
15516                    if (list == null) {
15517                            StringBundler query = null;
15518    
15519                            if (orderByComparator != null) {
15520                                    query = new StringBundler(5 +
15521                                                    (orderByComparator.getOrderByFields().length * 3));
15522                            }
15523                            else {
15524                                    query = new StringBundler(5);
15525                            }
15526    
15527                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15528    
15529                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15530    
15531                            boolean bindDisplayDate = false;
15532    
15533                            if (displayDate == null) {
15534                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15535                            }
15536                            else {
15537                                    bindDisplayDate = true;
15538    
15539                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15540                            }
15541    
15542                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15543    
15544                            if (orderByComparator != null) {
15545                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15546                                            orderByComparator);
15547                            }
15548                            else
15549                             if (pagination) {
15550                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15551                            }
15552    
15553                            String sql = query.toString();
15554    
15555                            Session session = null;
15556    
15557                            try {
15558                                    session = openSession();
15559    
15560                                    Query q = session.createQuery(sql);
15561    
15562                                    QueryPos qPos = QueryPos.getInstance(q);
15563    
15564                                    qPos.add(companyId);
15565    
15566                                    if (bindDisplayDate) {
15567                                            qPos.add(new Timestamp(displayDate.getTime()));
15568                                    }
15569    
15570                                    qPos.add(status);
15571    
15572                                    if (!pagination) {
15573                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15574                                                            start, end, false);
15575    
15576                                            Collections.sort(list);
15577    
15578                                            list = Collections.unmodifiableList(list);
15579                                    }
15580                                    else {
15581                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15582                                                            start, end);
15583                                    }
15584    
15585                                    cacheResult(list);
15586    
15587                                    finderCache.putResult(finderPath, finderArgs, list);
15588                            }
15589                            catch (Exception e) {
15590                                    finderCache.removeResult(finderPath, finderArgs);
15591    
15592                                    throw processException(e);
15593                            }
15594                            finally {
15595                                    closeSession(session);
15596                            }
15597                    }
15598    
15599                    return list;
15600            }
15601    
15602            /**
15603             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15604             *
15605             * @param companyId the company ID
15606             * @param displayDate the display date
15607             * @param status the status
15608             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15609             * @return the first matching blogs entry
15610             * @throws NoSuchEntryException if a matching blogs entry could not be found
15611             */
15612            @Override
15613            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
15614                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15615                    throws NoSuchEntryException {
15616                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
15617                                    status, orderByComparator);
15618    
15619                    if (blogsEntry != null) {
15620                            return blogsEntry;
15621                    }
15622    
15623                    StringBundler msg = new StringBundler(8);
15624    
15625                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15626    
15627                    msg.append("companyId=");
15628                    msg.append(companyId);
15629    
15630                    msg.append(", displayDate=");
15631                    msg.append(displayDate);
15632    
15633                    msg.append(", status=");
15634                    msg.append(status);
15635    
15636                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15637    
15638                    throw new NoSuchEntryException(msg.toString());
15639            }
15640    
15641            /**
15642             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15643             *
15644             * @param companyId the company ID
15645             * @param displayDate the display date
15646             * @param status the status
15647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15648             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15649             */
15650            @Override
15651            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
15652                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15653                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15654                                    status, 0, 1, orderByComparator);
15655    
15656                    if (!list.isEmpty()) {
15657                            return list.get(0);
15658                    }
15659    
15660                    return null;
15661            }
15662    
15663            /**
15664             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15665             *
15666             * @param companyId the company ID
15667             * @param displayDate the display date
15668             * @param status the status
15669             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15670             * @return the last matching blogs entry
15671             * @throws NoSuchEntryException if a matching blogs entry could not be found
15672             */
15673            @Override
15674            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
15675                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15676                    throws NoSuchEntryException {
15677                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
15678                                    status, orderByComparator);
15679    
15680                    if (blogsEntry != null) {
15681                            return blogsEntry;
15682                    }
15683    
15684                    StringBundler msg = new StringBundler(8);
15685    
15686                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15687    
15688                    msg.append("companyId=");
15689                    msg.append(companyId);
15690    
15691                    msg.append(", displayDate=");
15692                    msg.append(displayDate);
15693    
15694                    msg.append(", status=");
15695                    msg.append(status);
15696    
15697                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15698    
15699                    throw new NoSuchEntryException(msg.toString());
15700            }
15701    
15702            /**
15703             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15704             *
15705             * @param companyId the company 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, or <code>null</code> if a matching blogs entry could not be found
15710             */
15711            @Override
15712            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
15713                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15714                    int count = countByC_LtD_NotS(companyId, displayDate, status);
15715    
15716                    if (count == 0) {
15717                            return null;
15718                    }
15719    
15720                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15721                                    status, count - 1, count, orderByComparator);
15722    
15723                    if (!list.isEmpty()) {
15724                            return list.get(0);
15725                    }
15726    
15727                    return null;
15728            }
15729    
15730            /**
15731             * 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;.
15732             *
15733             * @param entryId the primary key of the current blogs entry
15734             * @param companyId the company ID
15735             * @param displayDate the display date
15736             * @param status the status
15737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15738             * @return the previous, current, and next blogs entry
15739             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15740             */
15741            @Override
15742            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
15743                    long companyId, Date displayDate, int status,
15744                    OrderByComparator<BlogsEntry> orderByComparator)
15745                    throws NoSuchEntryException {
15746                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15747    
15748                    Session session = null;
15749    
15750                    try {
15751                            session = openSession();
15752    
15753                            BlogsEntry[] array = new BlogsEntryImpl[3];
15754    
15755                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15756                                            companyId, displayDate, status, orderByComparator, true);
15757    
15758                            array[1] = blogsEntry;
15759    
15760                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15761                                            companyId, displayDate, status, orderByComparator, false);
15762    
15763                            return array;
15764                    }
15765                    catch (Exception e) {
15766                            throw processException(e);
15767                    }
15768                    finally {
15769                            closeSession(session);
15770                    }
15771            }
15772    
15773            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
15774                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15775                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15776                    StringBundler query = null;
15777    
15778                    if (orderByComparator != null) {
15779                            query = new StringBundler(6 +
15780                                            (orderByComparator.getOrderByFields().length * 6));
15781                    }
15782                    else {
15783                            query = new StringBundler(3);
15784                    }
15785    
15786                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15787    
15788                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15789    
15790                    boolean bindDisplayDate = false;
15791    
15792                    if (displayDate == null) {
15793                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15794                    }
15795                    else {
15796                            bindDisplayDate = true;
15797    
15798                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15799                    }
15800    
15801                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15802    
15803                    if (orderByComparator != null) {
15804                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15805    
15806                            if (orderByConditionFields.length > 0) {
15807                                    query.append(WHERE_AND);
15808                            }
15809    
15810                            for (int i = 0; i < orderByConditionFields.length; i++) {
15811                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15812                                    query.append(orderByConditionFields[i]);
15813    
15814                                    if ((i + 1) < orderByConditionFields.length) {
15815                                            if (orderByComparator.isAscending() ^ previous) {
15816                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15817                                            }
15818                                            else {
15819                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15820                                            }
15821                                    }
15822                                    else {
15823                                            if (orderByComparator.isAscending() ^ previous) {
15824                                                    query.append(WHERE_GREATER_THAN);
15825                                            }
15826                                            else {
15827                                                    query.append(WHERE_LESSER_THAN);
15828                                            }
15829                                    }
15830                            }
15831    
15832                            query.append(ORDER_BY_CLAUSE);
15833    
15834                            String[] orderByFields = orderByComparator.getOrderByFields();
15835    
15836                            for (int i = 0; i < orderByFields.length; i++) {
15837                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15838                                    query.append(orderByFields[i]);
15839    
15840                                    if ((i + 1) < orderByFields.length) {
15841                                            if (orderByComparator.isAscending() ^ previous) {
15842                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15843                                            }
15844                                            else {
15845                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15846                                            }
15847                                    }
15848                                    else {
15849                                            if (orderByComparator.isAscending() ^ previous) {
15850                                                    query.append(ORDER_BY_ASC);
15851                                            }
15852                                            else {
15853                                                    query.append(ORDER_BY_DESC);
15854                                            }
15855                                    }
15856                            }
15857                    }
15858                    else {
15859                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15860                    }
15861    
15862                    String sql = query.toString();
15863    
15864                    Query q = session.createQuery(sql);
15865    
15866                    q.setFirstResult(0);
15867                    q.setMaxResults(2);
15868    
15869                    QueryPos qPos = QueryPos.getInstance(q);
15870    
15871                    qPos.add(companyId);
15872    
15873                    if (bindDisplayDate) {
15874                            qPos.add(new Timestamp(displayDate.getTime()));
15875                    }
15876    
15877                    qPos.add(status);
15878    
15879                    if (orderByComparator != null) {
15880                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15881    
15882                            for (Object value : values) {
15883                                    qPos.add(value);
15884                            }
15885                    }
15886    
15887                    List<BlogsEntry> list = q.list();
15888    
15889                    if (list.size() == 2) {
15890                            return list.get(1);
15891                    }
15892                    else {
15893                            return null;
15894                    }
15895            }
15896    
15897            /**
15898             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15899             *
15900             * @param companyId the company ID
15901             * @param displayDate the display date
15902             * @param status the status
15903             */
15904            @Override
15905            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
15906                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
15907                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15908                            remove(blogsEntry);
15909                    }
15910            }
15911    
15912            /**
15913             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15914             *
15915             * @param companyId the company ID
15916             * @param displayDate the display date
15917             * @param status the status
15918             * @return the number of matching blogs entries
15919             */
15920            @Override
15921            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
15922                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
15923    
15924                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15925    
15926                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15927    
15928                    if (count == null) {
15929                            StringBundler query = new StringBundler(4);
15930    
15931                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15932    
15933                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15934    
15935                            boolean bindDisplayDate = false;
15936    
15937                            if (displayDate == null) {
15938                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15939                            }
15940                            else {
15941                                    bindDisplayDate = true;
15942    
15943                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15944                            }
15945    
15946                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15947    
15948                            String sql = query.toString();
15949    
15950                            Session session = null;
15951    
15952                            try {
15953                                    session = openSession();
15954    
15955                                    Query q = session.createQuery(sql);
15956    
15957                                    QueryPos qPos = QueryPos.getInstance(q);
15958    
15959                                    qPos.add(companyId);
15960    
15961                                    if (bindDisplayDate) {
15962                                            qPos.add(new Timestamp(displayDate.getTime()));
15963                                    }
15964    
15965                                    qPos.add(status);
15966    
15967                                    count = (Long)q.uniqueResult();
15968    
15969                                    finderCache.putResult(finderPath, finderArgs, count);
15970                            }
15971                            catch (Exception e) {
15972                                    finderCache.removeResult(finderPath, finderArgs);
15973    
15974                                    throw processException(e);
15975                            }
15976                            finally {
15977                                    closeSession(session);
15978                            }
15979                    }
15980    
15981                    return count.intValue();
15982            }
15983    
15984            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15985            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15986            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15987            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
15988            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
15989                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15990                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15991                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
15992                            new String[] {
15993                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15994                                    Integer.class.getName(),
15995                                    
15996                            Integer.class.getName(), Integer.class.getName(),
15997                                    OrderByComparator.class.getName()
15998                            });
15999            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16000                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16001                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16002                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16003                            new String[] {
16004                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16005                                    Integer.class.getName()
16006                            });
16007    
16008            /**
16009             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16010             *
16011             * @param groupId the group ID
16012             * @param userId the user ID
16013             * @param displayDate the display date
16014             * @param status the status
16015             * @return the matching blogs entries
16016             */
16017            @Override
16018            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16019                    Date displayDate, int status) {
16020                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16021                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16022            }
16023    
16024            /**
16025             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16026             *
16027             * <p>
16028             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16029             * </p>
16030             *
16031             * @param groupId the group ID
16032             * @param userId the user ID
16033             * @param displayDate the display date
16034             * @param status the status
16035             * @param start the lower bound of the range of blogs entries
16036             * @param end the upper bound of the range of blogs entries (not inclusive)
16037             * @return the range of matching blogs entries
16038             */
16039            @Override
16040            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16041                    Date displayDate, int status, int start, int end) {
16042                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16043                            end, null);
16044            }
16045    
16046            /**
16047             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16048             *
16049             * <p>
16050             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16051             * </p>
16052             *
16053             * @param groupId the group ID
16054             * @param userId the user ID
16055             * @param displayDate the display date
16056             * @param status the status
16057             * @param start the lower bound of the range of blogs entries
16058             * @param end the upper bound of the range of blogs entries (not inclusive)
16059             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16060             * @return the ordered range of matching blogs entries
16061             */
16062            @Override
16063            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16064                    Date displayDate, int status, int start, int end,
16065                    OrderByComparator<BlogsEntry> orderByComparator) {
16066                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16067                            end, orderByComparator, true);
16068            }
16069    
16070            /**
16071             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16072             *
16073             * <p>
16074             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16075             * </p>
16076             *
16077             * @param groupId the group ID
16078             * @param userId the user ID
16079             * @param displayDate the display date
16080             * @param status the status
16081             * @param start the lower bound of the range of blogs entries
16082             * @param end the upper bound of the range of blogs entries (not inclusive)
16083             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16084             * @param retrieveFromCache whether to retrieve from the finder cache
16085             * @return the ordered range of matching blogs entries
16086             */
16087            @Override
16088            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16089                    Date displayDate, int status, int start, int end,
16090                    OrderByComparator<BlogsEntry> orderByComparator,
16091                    boolean retrieveFromCache) {
16092                    boolean pagination = true;
16093                    FinderPath finderPath = null;
16094                    Object[] finderArgs = null;
16095    
16096                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16097                    finderArgs = new Object[] {
16098                                    groupId, userId, displayDate, status,
16099                                    
16100                                    start, end, orderByComparator
16101                            };
16102    
16103                    List<BlogsEntry> list = null;
16104    
16105                    if (retrieveFromCache) {
16106                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16107                                            finderArgs, this);
16108    
16109                            if ((list != null) && !list.isEmpty()) {
16110                                    for (BlogsEntry blogsEntry : list) {
16111                                            if ((groupId != blogsEntry.getGroupId()) ||
16112                                                            (userId != blogsEntry.getUserId()) ||
16113                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16114                                                                                                                                            .getTime()) ||
16115                                                            (status != blogsEntry.getStatus())) {
16116                                                    list = null;
16117    
16118                                                    break;
16119                                            }
16120                                    }
16121                            }
16122                    }
16123    
16124                    if (list == null) {
16125                            StringBundler query = null;
16126    
16127                            if (orderByComparator != null) {
16128                                    query = new StringBundler(6 +
16129                                                    (orderByComparator.getOrderByFields().length * 3));
16130                            }
16131                            else {
16132                                    query = new StringBundler(6);
16133                            }
16134    
16135                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16136    
16137                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16138    
16139                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16140    
16141                            boolean bindDisplayDate = false;
16142    
16143                            if (displayDate == null) {
16144                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16145                            }
16146                            else {
16147                                    bindDisplayDate = true;
16148    
16149                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16150                            }
16151    
16152                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16153    
16154                            if (orderByComparator != null) {
16155                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16156                                            orderByComparator);
16157                            }
16158                            else
16159                             if (pagination) {
16160                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16161                            }
16162    
16163                            String sql = query.toString();
16164    
16165                            Session session = null;
16166    
16167                            try {
16168                                    session = openSession();
16169    
16170                                    Query q = session.createQuery(sql);
16171    
16172                                    QueryPos qPos = QueryPos.getInstance(q);
16173    
16174                                    qPos.add(groupId);
16175    
16176                                    qPos.add(userId);
16177    
16178                                    if (bindDisplayDate) {
16179                                            qPos.add(new Timestamp(displayDate.getTime()));
16180                                    }
16181    
16182                                    qPos.add(status);
16183    
16184                                    if (!pagination) {
16185                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16186                                                            start, end, false);
16187    
16188                                            Collections.sort(list);
16189    
16190                                            list = Collections.unmodifiableList(list);
16191                                    }
16192                                    else {
16193                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16194                                                            start, end);
16195                                    }
16196    
16197                                    cacheResult(list);
16198    
16199                                    finderCache.putResult(finderPath, finderArgs, list);
16200                            }
16201                            catch (Exception e) {
16202                                    finderCache.removeResult(finderPath, finderArgs);
16203    
16204                                    throw processException(e);
16205                            }
16206                            finally {
16207                                    closeSession(session);
16208                            }
16209                    }
16210    
16211                    return list;
16212            }
16213    
16214            /**
16215             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16216             *
16217             * @param groupId the group ID
16218             * @param userId the user ID
16219             * @param displayDate the display date
16220             * @param status the status
16221             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16222             * @return the first matching blogs entry
16223             * @throws NoSuchEntryException if a matching blogs entry could not be found
16224             */
16225            @Override
16226            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16227                    Date displayDate, int status,
16228                    OrderByComparator<BlogsEntry> orderByComparator)
16229                    throws NoSuchEntryException {
16230                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16231                                    displayDate, status, orderByComparator);
16232    
16233                    if (blogsEntry != null) {
16234                            return blogsEntry;
16235                    }
16236    
16237                    StringBundler msg = new StringBundler(10);
16238    
16239                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16240    
16241                    msg.append("groupId=");
16242                    msg.append(groupId);
16243    
16244                    msg.append(", userId=");
16245                    msg.append(userId);
16246    
16247                    msg.append(", displayDate=");
16248                    msg.append(displayDate);
16249    
16250                    msg.append(", status=");
16251                    msg.append(status);
16252    
16253                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16254    
16255                    throw new NoSuchEntryException(msg.toString());
16256            }
16257    
16258            /**
16259             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16260             *
16261             * @param groupId the group ID
16262             * @param userId the user ID
16263             * @param displayDate the display date
16264             * @param status the status
16265             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16266             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16267             */
16268            @Override
16269            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16270                    Date displayDate, int status,
16271                    OrderByComparator<BlogsEntry> orderByComparator) {
16272                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16273                                    status, 0, 1, orderByComparator);
16274    
16275                    if (!list.isEmpty()) {
16276                            return list.get(0);
16277                    }
16278    
16279                    return null;
16280            }
16281    
16282            /**
16283             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16284             *
16285             * @param groupId the group ID
16286             * @param userId the user ID
16287             * @param displayDate the display date
16288             * @param status the status
16289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16290             * @return the last matching blogs entry
16291             * @throws NoSuchEntryException if a matching blogs entry could not be found
16292             */
16293            @Override
16294            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16295                    Date displayDate, int status,
16296                    OrderByComparator<BlogsEntry> orderByComparator)
16297                    throws NoSuchEntryException {
16298                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16299                                    displayDate, status, orderByComparator);
16300    
16301                    if (blogsEntry != null) {
16302                            return blogsEntry;
16303                    }
16304    
16305                    StringBundler msg = new StringBundler(10);
16306    
16307                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16308    
16309                    msg.append("groupId=");
16310                    msg.append(groupId);
16311    
16312                    msg.append(", userId=");
16313                    msg.append(userId);
16314    
16315                    msg.append(", displayDate=");
16316                    msg.append(displayDate);
16317    
16318                    msg.append(", status=");
16319                    msg.append(status);
16320    
16321                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16322    
16323                    throw new NoSuchEntryException(msg.toString());
16324            }
16325    
16326            /**
16327             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16328             *
16329             * @param groupId the group ID
16330             * @param userId the user ID
16331             * @param displayDate the display date
16332             * @param status the status
16333             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16334             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16335             */
16336            @Override
16337            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16338                    Date displayDate, int status,
16339                    OrderByComparator<BlogsEntry> orderByComparator) {
16340                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16341    
16342                    if (count == 0) {
16343                            return null;
16344                    }
16345    
16346                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16347                                    status, count - 1, count, orderByComparator);
16348    
16349                    if (!list.isEmpty()) {
16350                            return list.get(0);
16351                    }
16352    
16353                    return null;
16354            }
16355    
16356            /**
16357             * 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;.
16358             *
16359             * @param entryId the primary key of the current blogs entry
16360             * @param groupId the group ID
16361             * @param userId the user ID
16362             * @param displayDate the display date
16363             * @param status the status
16364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16365             * @return the previous, current, and next blogs entry
16366             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16367             */
16368            @Override
16369            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16370                    long userId, Date displayDate, int status,
16371                    OrderByComparator<BlogsEntry> orderByComparator)
16372                    throws NoSuchEntryException {
16373                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16374    
16375                    Session session = null;
16376    
16377                    try {
16378                            session = openSession();
16379    
16380                            BlogsEntry[] array = new BlogsEntryImpl[3];
16381    
16382                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16383                                            userId, displayDate, status, orderByComparator, true);
16384    
16385                            array[1] = blogsEntry;
16386    
16387                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16388                                            userId, displayDate, status, orderByComparator, false);
16389    
16390                            return array;
16391                    }
16392                    catch (Exception e) {
16393                            throw processException(e);
16394                    }
16395                    finally {
16396                            closeSession(session);
16397                    }
16398            }
16399    
16400            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16401                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16402                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16403                    boolean previous) {
16404                    StringBundler query = null;
16405    
16406                    if (orderByComparator != null) {
16407                            query = new StringBundler(6 +
16408                                            (orderByComparator.getOrderByFields().length * 6));
16409                    }
16410                    else {
16411                            query = new StringBundler(3);
16412                    }
16413    
16414                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16415    
16416                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16417    
16418                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16419    
16420                    boolean bindDisplayDate = false;
16421    
16422                    if (displayDate == null) {
16423                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16424                    }
16425                    else {
16426                            bindDisplayDate = true;
16427    
16428                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16429                    }
16430    
16431                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16432    
16433                    if (orderByComparator != null) {
16434                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16435    
16436                            if (orderByConditionFields.length > 0) {
16437                                    query.append(WHERE_AND);
16438                            }
16439    
16440                            for (int i = 0; i < orderByConditionFields.length; i++) {
16441                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16442                                    query.append(orderByConditionFields[i]);
16443    
16444                                    if ((i + 1) < orderByConditionFields.length) {
16445                                            if (orderByComparator.isAscending() ^ previous) {
16446                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16447                                            }
16448                                            else {
16449                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16450                                            }
16451                                    }
16452                                    else {
16453                                            if (orderByComparator.isAscending() ^ previous) {
16454                                                    query.append(WHERE_GREATER_THAN);
16455                                            }
16456                                            else {
16457                                                    query.append(WHERE_LESSER_THAN);
16458                                            }
16459                                    }
16460                            }
16461    
16462                            query.append(ORDER_BY_CLAUSE);
16463    
16464                            String[] orderByFields = orderByComparator.getOrderByFields();
16465    
16466                            for (int i = 0; i < orderByFields.length; i++) {
16467                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16468                                    query.append(orderByFields[i]);
16469    
16470                                    if ((i + 1) < orderByFields.length) {
16471                                            if (orderByComparator.isAscending() ^ previous) {
16472                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16473                                            }
16474                                            else {
16475                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16476                                            }
16477                                    }
16478                                    else {
16479                                            if (orderByComparator.isAscending() ^ previous) {
16480                                                    query.append(ORDER_BY_ASC);
16481                                            }
16482                                            else {
16483                                                    query.append(ORDER_BY_DESC);
16484                                            }
16485                                    }
16486                            }
16487                    }
16488                    else {
16489                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16490                    }
16491    
16492                    String sql = query.toString();
16493    
16494                    Query q = session.createQuery(sql);
16495    
16496                    q.setFirstResult(0);
16497                    q.setMaxResults(2);
16498    
16499                    QueryPos qPos = QueryPos.getInstance(q);
16500    
16501                    qPos.add(groupId);
16502    
16503                    qPos.add(userId);
16504    
16505                    if (bindDisplayDate) {
16506                            qPos.add(new Timestamp(displayDate.getTime()));
16507                    }
16508    
16509                    qPos.add(status);
16510    
16511                    if (orderByComparator != null) {
16512                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16513    
16514                            for (Object value : values) {
16515                                    qPos.add(value);
16516                            }
16517                    }
16518    
16519                    List<BlogsEntry> list = q.list();
16520    
16521                    if (list.size() == 2) {
16522                            return list.get(1);
16523                    }
16524                    else {
16525                            return null;
16526                    }
16527            }
16528    
16529            /**
16530             * 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;.
16531             *
16532             * @param groupId the group ID
16533             * @param userId the user ID
16534             * @param displayDate the display date
16535             * @param status the status
16536             * @return the matching blogs entries that the user has permission to view
16537             */
16538            @Override
16539            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16540                    Date displayDate, int status) {
16541                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16542                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16543            }
16544    
16545            /**
16546             * 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;.
16547             *
16548             * <p>
16549             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16550             * </p>
16551             *
16552             * @param groupId the group ID
16553             * @param userId the user ID
16554             * @param displayDate the display date
16555             * @param status the status
16556             * @param start the lower bound of the range of blogs entries
16557             * @param end the upper bound of the range of blogs entries (not inclusive)
16558             * @return the range of matching blogs entries that the user has permission to view
16559             */
16560            @Override
16561            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16562                    Date displayDate, int status, int start, int end) {
16563                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16564                            start, end, null);
16565            }
16566    
16567            /**
16568             * 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;.
16569             *
16570             * <p>
16571             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16572             * </p>
16573             *
16574             * @param groupId the group ID
16575             * @param userId the user ID
16576             * @param displayDate the display date
16577             * @param status the status
16578             * @param start the lower bound of the range of blogs entries
16579             * @param end the upper bound of the range of blogs entries (not inclusive)
16580             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16581             * @return the ordered range of matching blogs entries that the user has permission to view
16582             */
16583            @Override
16584            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16585                    Date displayDate, int status, int start, int end,
16586                    OrderByComparator<BlogsEntry> orderByComparator) {
16587                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16588                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16589                                    end, orderByComparator);
16590                    }
16591    
16592                    StringBundler query = null;
16593    
16594                    if (orderByComparator != null) {
16595                            query = new StringBundler(6 +
16596                                            (orderByComparator.getOrderByFields().length * 3));
16597                    }
16598                    else {
16599                            query = new StringBundler(6);
16600                    }
16601    
16602                    if (getDB().isSupportsInlineDistinct()) {
16603                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16604                    }
16605                    else {
16606                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16607                    }
16608    
16609                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16610    
16611                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16612    
16613                    boolean bindDisplayDate = false;
16614    
16615                    if (displayDate == null) {
16616                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16617                    }
16618                    else {
16619                            bindDisplayDate = true;
16620    
16621                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16622                    }
16623    
16624                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16625    
16626                    if (!getDB().isSupportsInlineDistinct()) {
16627                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16628                    }
16629    
16630                    if (orderByComparator != null) {
16631                            if (getDB().isSupportsInlineDistinct()) {
16632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16633                                            orderByComparator, true);
16634                            }
16635                            else {
16636                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16637                                            orderByComparator, true);
16638                            }
16639                    }
16640                    else {
16641                            if (getDB().isSupportsInlineDistinct()) {
16642                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16643                            }
16644                            else {
16645                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16646                            }
16647                    }
16648    
16649                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16650                                    BlogsEntry.class.getName(),
16651                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16652    
16653                    Session session = null;
16654    
16655                    try {
16656                            session = openSession();
16657    
16658                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16659    
16660                            if (getDB().isSupportsInlineDistinct()) {
16661                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16662                            }
16663                            else {
16664                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16665                            }
16666    
16667                            QueryPos qPos = QueryPos.getInstance(q);
16668    
16669                            qPos.add(groupId);
16670    
16671                            qPos.add(userId);
16672    
16673                            if (bindDisplayDate) {
16674                                    qPos.add(new Timestamp(displayDate.getTime()));
16675                            }
16676    
16677                            qPos.add(status);
16678    
16679                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16680                    }
16681                    catch (Exception e) {
16682                            throw processException(e);
16683                    }
16684                    finally {
16685                            closeSession(session);
16686                    }
16687            }
16688    
16689            /**
16690             * 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;.
16691             *
16692             * @param entryId the primary key of the current blogs entry
16693             * @param groupId the group ID
16694             * @param userId the user ID
16695             * @param displayDate the display date
16696             * @param status the status
16697             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16698             * @return the previous, current, and next blogs entry
16699             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16700             */
16701            @Override
16702            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
16703                    long groupId, long userId, Date displayDate, int status,
16704                    OrderByComparator<BlogsEntry> orderByComparator)
16705                    throws NoSuchEntryException {
16706                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16707                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
16708                                    displayDate, status, orderByComparator);
16709                    }
16710    
16711                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16712    
16713                    Session session = null;
16714    
16715                    try {
16716                            session = openSession();
16717    
16718                            BlogsEntry[] array = new BlogsEntryImpl[3];
16719    
16720                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16721                                            groupId, userId, displayDate, status, orderByComparator,
16722                                            true);
16723    
16724                            array[1] = blogsEntry;
16725    
16726                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16727                                            groupId, userId, displayDate, status, orderByComparator,
16728                                            false);
16729    
16730                            return array;
16731                    }
16732                    catch (Exception e) {
16733                            throw processException(e);
16734                    }
16735                    finally {
16736                            closeSession(session);
16737                    }
16738            }
16739    
16740            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
16741                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16742                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16743                    boolean previous) {
16744                    StringBundler query = null;
16745    
16746                    if (orderByComparator != null) {
16747                            query = new StringBundler(6 +
16748                                            (orderByComparator.getOrderByFields().length * 6));
16749                    }
16750                    else {
16751                            query = new StringBundler(3);
16752                    }
16753    
16754                    if (getDB().isSupportsInlineDistinct()) {
16755                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16756                    }
16757                    else {
16758                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16759                    }
16760    
16761                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16762    
16763                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16764    
16765                    boolean bindDisplayDate = false;
16766    
16767                    if (displayDate == null) {
16768                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16769                    }
16770                    else {
16771                            bindDisplayDate = true;
16772    
16773                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16774                    }
16775    
16776                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16777    
16778                    if (!getDB().isSupportsInlineDistinct()) {
16779                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16780                    }
16781    
16782                    if (orderByComparator != null) {
16783                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16784    
16785                            if (orderByConditionFields.length > 0) {
16786                                    query.append(WHERE_AND);
16787                            }
16788    
16789                            for (int i = 0; i < orderByConditionFields.length; i++) {
16790                                    if (getDB().isSupportsInlineDistinct()) {
16791                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16792                                    }
16793                                    else {
16794                                            query.append(_ORDER_BY_ENTITY_TABLE);
16795                                    }
16796    
16797                                    query.append(orderByConditionFields[i]);
16798    
16799                                    if ((i + 1) < orderByConditionFields.length) {
16800                                            if (orderByComparator.isAscending() ^ previous) {
16801                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16802                                            }
16803                                            else {
16804                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16805                                            }
16806                                    }
16807                                    else {
16808                                            if (orderByComparator.isAscending() ^ previous) {
16809                                                    query.append(WHERE_GREATER_THAN);
16810                                            }
16811                                            else {
16812                                                    query.append(WHERE_LESSER_THAN);
16813                                            }
16814                                    }
16815                            }
16816    
16817                            query.append(ORDER_BY_CLAUSE);
16818    
16819                            String[] orderByFields = orderByComparator.getOrderByFields();
16820    
16821                            for (int i = 0; i < orderByFields.length; i++) {
16822                                    if (getDB().isSupportsInlineDistinct()) {
16823                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16824                                    }
16825                                    else {
16826                                            query.append(_ORDER_BY_ENTITY_TABLE);
16827                                    }
16828    
16829                                    query.append(orderByFields[i]);
16830    
16831                                    if ((i + 1) < orderByFields.length) {
16832                                            if (orderByComparator.isAscending() ^ previous) {
16833                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16834                                            }
16835                                            else {
16836                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16837                                            }
16838                                    }
16839                                    else {
16840                                            if (orderByComparator.isAscending() ^ previous) {
16841                                                    query.append(ORDER_BY_ASC);
16842                                            }
16843                                            else {
16844                                                    query.append(ORDER_BY_DESC);
16845                                            }
16846                                    }
16847                            }
16848                    }
16849                    else {
16850                            if (getDB().isSupportsInlineDistinct()) {
16851                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16852                            }
16853                            else {
16854                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16855                            }
16856                    }
16857    
16858                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16859                                    BlogsEntry.class.getName(),
16860                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16861    
16862                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
16863    
16864                    q.setFirstResult(0);
16865                    q.setMaxResults(2);
16866    
16867                    if (getDB().isSupportsInlineDistinct()) {
16868                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16869                    }
16870                    else {
16871                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16872                    }
16873    
16874                    QueryPos qPos = QueryPos.getInstance(q);
16875    
16876                    qPos.add(groupId);
16877    
16878                    qPos.add(userId);
16879    
16880                    if (bindDisplayDate) {
16881                            qPos.add(new Timestamp(displayDate.getTime()));
16882                    }
16883    
16884                    qPos.add(status);
16885    
16886                    if (orderByComparator != null) {
16887                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16888    
16889                            for (Object value : values) {
16890                                    qPos.add(value);
16891                            }
16892                    }
16893    
16894                    List<BlogsEntry> list = q.list();
16895    
16896                    if (list.size() == 2) {
16897                            return list.get(1);
16898                    }
16899                    else {
16900                            return null;
16901                    }
16902            }
16903    
16904            /**
16905             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
16906             *
16907             * @param groupId the group ID
16908             * @param userId the user ID
16909             * @param displayDate the display date
16910             * @param status the status
16911             */
16912            @Override
16913            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
16914                    int status) {
16915                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
16916                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16917                            remove(blogsEntry);
16918                    }
16919            }
16920    
16921            /**
16922             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16923             *
16924             * @param groupId the group ID
16925             * @param userId the user ID
16926             * @param displayDate the display date
16927             * @param status the status
16928             * @return the number of matching blogs entries
16929             */
16930            @Override
16931            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
16932                    int status) {
16933                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
16934    
16935                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16936    
16937                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
16938    
16939                    if (count == null) {
16940                            StringBundler query = new StringBundler(5);
16941    
16942                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16943    
16944                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16945    
16946                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16947    
16948                            boolean bindDisplayDate = false;
16949    
16950                            if (displayDate == null) {
16951                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16952                            }
16953                            else {
16954                                    bindDisplayDate = true;
16955    
16956                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16957                            }
16958    
16959                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16960    
16961                            String sql = query.toString();
16962    
16963                            Session session = null;
16964    
16965                            try {
16966                                    session = openSession();
16967    
16968                                    Query q = session.createQuery(sql);
16969    
16970                                    QueryPos qPos = QueryPos.getInstance(q);
16971    
16972                                    qPos.add(groupId);
16973    
16974                                    qPos.add(userId);
16975    
16976                                    if (bindDisplayDate) {
16977                                            qPos.add(new Timestamp(displayDate.getTime()));
16978                                    }
16979    
16980                                    qPos.add(status);
16981    
16982                                    count = (Long)q.uniqueResult();
16983    
16984                                    finderCache.putResult(finderPath, finderArgs, count);
16985                            }
16986                            catch (Exception e) {
16987                                    finderCache.removeResult(finderPath, finderArgs);
16988    
16989                                    throw processException(e);
16990                            }
16991                            finally {
16992                                    closeSession(session);
16993                            }
16994                    }
16995    
16996                    return count.intValue();
16997            }
16998    
16999            /**
17000             * 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;.
17001             *
17002             * @param groupId the group ID
17003             * @param userId the user ID
17004             * @param displayDate the display date
17005             * @param status the status
17006             * @return the number of matching blogs entries that the user has permission to view
17007             */
17008            @Override
17009            public int filterCountByG_U_LtD_S(long groupId, long userId,
17010                    Date displayDate, int status) {
17011                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17012                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17013                    }
17014    
17015                    StringBundler query = new StringBundler(5);
17016    
17017                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17018    
17019                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17020    
17021                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17022    
17023                    boolean bindDisplayDate = false;
17024    
17025                    if (displayDate == null) {
17026                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17027                    }
17028                    else {
17029                            bindDisplayDate = true;
17030    
17031                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17032                    }
17033    
17034                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17035    
17036                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17037                                    BlogsEntry.class.getName(),
17038                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17039    
17040                    Session session = null;
17041    
17042                    try {
17043                            session = openSession();
17044    
17045                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17046    
17047                            q.addScalar(COUNT_COLUMN_NAME,
17048                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17049    
17050                            QueryPos qPos = QueryPos.getInstance(q);
17051    
17052                            qPos.add(groupId);
17053    
17054                            qPos.add(userId);
17055    
17056                            if (bindDisplayDate) {
17057                                    qPos.add(new Timestamp(displayDate.getTime()));
17058                            }
17059    
17060                            qPos.add(status);
17061    
17062                            Long count = (Long)q.uniqueResult();
17063    
17064                            return count.intValue();
17065                    }
17066                    catch (Exception e) {
17067                            throw processException(e);
17068                    }
17069                    finally {
17070                            closeSession(session);
17071                    }
17072            }
17073    
17074            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17075            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17076            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
17077            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17078            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
17080                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17081                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
17082                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
17083                            new String[] {
17084                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17085                                    Integer.class.getName(),
17086                                    
17087                            Integer.class.getName(), Integer.class.getName(),
17088                                    OrderByComparator.class.getName()
17089                            });
17090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
17091                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17092                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
17093                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
17094                            new String[] {
17095                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17096                                    Integer.class.getName()
17097                            });
17098    
17099            /**
17100             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17101             *
17102             * @param groupId the group ID
17103             * @param userId the user ID
17104             * @param displayDate the display date
17105             * @param status the status
17106             * @return the matching blogs entries
17107             */
17108            @Override
17109            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17110                    Date displayDate, int status) {
17111                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17112                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17113            }
17114    
17115            /**
17116             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17117             *
17118             * <p>
17119             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17120             * </p>
17121             *
17122             * @param groupId the group ID
17123             * @param userId the user ID
17124             * @param displayDate the display date
17125             * @param status the status
17126             * @param start the lower bound of the range of blogs entries
17127             * @param end the upper bound of the range of blogs entries (not inclusive)
17128             * @return the range of matching blogs entries
17129             */
17130            @Override
17131            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17132                    Date displayDate, int status, int start, int end) {
17133                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17134                            end, null);
17135            }
17136    
17137            /**
17138             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17139             *
17140             * <p>
17141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17142             * </p>
17143             *
17144             * @param groupId the group ID
17145             * @param userId the user ID
17146             * @param displayDate the display date
17147             * @param status the status
17148             * @param start the lower bound of the range of blogs entries
17149             * @param end the upper bound of the range of blogs entries (not inclusive)
17150             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17151             * @return the ordered range of matching blogs entries
17152             */
17153            @Override
17154            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17155                    Date displayDate, int status, int start, int end,
17156                    OrderByComparator<BlogsEntry> orderByComparator) {
17157                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17158                            end, orderByComparator, true);
17159            }
17160    
17161            /**
17162             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17163             *
17164             * <p>
17165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17166             * </p>
17167             *
17168             * @param groupId the group ID
17169             * @param userId the user ID
17170             * @param displayDate the display date
17171             * @param status the status
17172             * @param start the lower bound of the range of blogs entries
17173             * @param end the upper bound of the range of blogs entries (not inclusive)
17174             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17175             * @param retrieveFromCache whether to retrieve from the finder cache
17176             * @return the ordered range of matching blogs entries
17177             */
17178            @Override
17179            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17180                    Date displayDate, int status, int start, int end,
17181                    OrderByComparator<BlogsEntry> orderByComparator,
17182                    boolean retrieveFromCache) {
17183                    boolean pagination = true;
17184                    FinderPath finderPath = null;
17185                    Object[] finderArgs = null;
17186    
17187                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
17188                    finderArgs = new Object[] {
17189                                    groupId, userId, displayDate, status,
17190                                    
17191                                    start, end, orderByComparator
17192                            };
17193    
17194                    List<BlogsEntry> list = null;
17195    
17196                    if (retrieveFromCache) {
17197                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
17198                                            finderArgs, this);
17199    
17200                            if ((list != null) && !list.isEmpty()) {
17201                                    for (BlogsEntry blogsEntry : list) {
17202                                            if ((groupId != blogsEntry.getGroupId()) ||
17203                                                            (userId != blogsEntry.getUserId()) ||
17204                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
17205                                                                                                                                            .getTime()) ||
17206                                                            (status == blogsEntry.getStatus())) {
17207                                                    list = null;
17208    
17209                                                    break;
17210                                            }
17211                                    }
17212                            }
17213                    }
17214    
17215                    if (list == null) {
17216                            StringBundler query = null;
17217    
17218                            if (orderByComparator != null) {
17219                                    query = new StringBundler(6 +
17220                                                    (orderByComparator.getOrderByFields().length * 3));
17221                            }
17222                            else {
17223                                    query = new StringBundler(6);
17224                            }
17225    
17226                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17227    
17228                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17229    
17230                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17231    
17232                            boolean bindDisplayDate = false;
17233    
17234                            if (displayDate == null) {
17235                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17236                            }
17237                            else {
17238                                    bindDisplayDate = true;
17239    
17240                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17241                            }
17242    
17243                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17244    
17245                            if (orderByComparator != null) {
17246                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17247                                            orderByComparator);
17248                            }
17249                            else
17250                             if (pagination) {
17251                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17252                            }
17253    
17254                            String sql = query.toString();
17255    
17256                            Session session = null;
17257    
17258                            try {
17259                                    session = openSession();
17260    
17261                                    Query q = session.createQuery(sql);
17262    
17263                                    QueryPos qPos = QueryPos.getInstance(q);
17264    
17265                                    qPos.add(groupId);
17266    
17267                                    qPos.add(userId);
17268    
17269                                    if (bindDisplayDate) {
17270                                            qPos.add(new Timestamp(displayDate.getTime()));
17271                                    }
17272    
17273                                    qPos.add(status);
17274    
17275                                    if (!pagination) {
17276                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17277                                                            start, end, false);
17278    
17279                                            Collections.sort(list);
17280    
17281                                            list = Collections.unmodifiableList(list);
17282                                    }
17283                                    else {
17284                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17285                                                            start, end);
17286                                    }
17287    
17288                                    cacheResult(list);
17289    
17290                                    finderCache.putResult(finderPath, finderArgs, list);
17291                            }
17292                            catch (Exception e) {
17293                                    finderCache.removeResult(finderPath, finderArgs);
17294    
17295                                    throw processException(e);
17296                            }
17297                            finally {
17298                                    closeSession(session);
17299                            }
17300                    }
17301    
17302                    return list;
17303            }
17304    
17305            /**
17306             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17307             *
17308             * @param groupId the group ID
17309             * @param userId the user ID
17310             * @param displayDate the display date
17311             * @param status the status
17312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17313             * @return the first matching blogs entry
17314             * @throws NoSuchEntryException if a matching blogs entry could not be found
17315             */
17316            @Override
17317            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
17318                    Date displayDate, int status,
17319                    OrderByComparator<BlogsEntry> orderByComparator)
17320                    throws NoSuchEntryException {
17321                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
17322                                    displayDate, status, orderByComparator);
17323    
17324                    if (blogsEntry != null) {
17325                            return blogsEntry;
17326                    }
17327    
17328                    StringBundler msg = new StringBundler(10);
17329    
17330                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17331    
17332                    msg.append("groupId=");
17333                    msg.append(groupId);
17334    
17335                    msg.append(", userId=");
17336                    msg.append(userId);
17337    
17338                    msg.append(", displayDate=");
17339                    msg.append(displayDate);
17340    
17341                    msg.append(", status=");
17342                    msg.append(status);
17343    
17344                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17345    
17346                    throw new NoSuchEntryException(msg.toString());
17347            }
17348    
17349            /**
17350             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17351             *
17352             * @param groupId the group ID
17353             * @param userId the user ID
17354             * @param displayDate the display date
17355             * @param status the status
17356             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17357             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17358             */
17359            @Override
17360            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
17361                    Date displayDate, int status,
17362                    OrderByComparator<BlogsEntry> orderByComparator) {
17363                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17364                                    displayDate, status, 0, 1, orderByComparator);
17365    
17366                    if (!list.isEmpty()) {
17367                            return list.get(0);
17368                    }
17369    
17370                    return null;
17371            }
17372    
17373            /**
17374             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17375             *
17376             * @param groupId the group ID
17377             * @param userId the user ID
17378             * @param displayDate the display date
17379             * @param status the status
17380             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17381             * @return the last matching blogs entry
17382             * @throws NoSuchEntryException if a matching blogs entry could not be found
17383             */
17384            @Override
17385            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
17386                    Date displayDate, int status,
17387                    OrderByComparator<BlogsEntry> orderByComparator)
17388                    throws NoSuchEntryException {
17389                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
17390                                    displayDate, status, orderByComparator);
17391    
17392                    if (blogsEntry != null) {
17393                            return blogsEntry;
17394                    }
17395    
17396                    StringBundler msg = new StringBundler(10);
17397    
17398                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17399    
17400                    msg.append("groupId=");
17401                    msg.append(groupId);
17402    
17403                    msg.append(", userId=");
17404                    msg.append(userId);
17405    
17406                    msg.append(", displayDate=");
17407                    msg.append(displayDate);
17408    
17409                    msg.append(", status=");
17410                    msg.append(status);
17411    
17412                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17413    
17414                    throw new NoSuchEntryException(msg.toString());
17415            }
17416    
17417            /**
17418             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17419             *
17420             * @param groupId the group ID
17421             * @param userId the user ID
17422             * @param displayDate the display date
17423             * @param status the status
17424             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17425             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17426             */
17427            @Override
17428            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
17429                    Date displayDate, int status,
17430                    OrderByComparator<BlogsEntry> orderByComparator) {
17431                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
17432    
17433                    if (count == 0) {
17434                            return null;
17435                    }
17436    
17437                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17438                                    displayDate, status, count - 1, count, orderByComparator);
17439    
17440                    if (!list.isEmpty()) {
17441                            return list.get(0);
17442                    }
17443    
17444                    return null;
17445            }
17446    
17447            /**
17448             * 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;.
17449             *
17450             * @param entryId the primary key of the current blogs entry
17451             * @param groupId the group ID
17452             * @param userId the user ID
17453             * @param displayDate the display date
17454             * @param status the status
17455             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17456             * @return the previous, current, and next blogs entry
17457             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17458             */
17459            @Override
17460            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
17461                    long groupId, long userId, Date displayDate, int status,
17462                    OrderByComparator<BlogsEntry> orderByComparator)
17463                    throws NoSuchEntryException {
17464                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17465    
17466                    Session session = null;
17467    
17468                    try {
17469                            session = openSession();
17470    
17471                            BlogsEntry[] array = new BlogsEntryImpl[3];
17472    
17473                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17474                                            groupId, userId, displayDate, status, orderByComparator,
17475                                            true);
17476    
17477                            array[1] = blogsEntry;
17478    
17479                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17480                                            groupId, userId, displayDate, status, orderByComparator,
17481                                            false);
17482    
17483                            return array;
17484                    }
17485                    catch (Exception e) {
17486                            throw processException(e);
17487                    }
17488                    finally {
17489                            closeSession(session);
17490                    }
17491            }
17492    
17493            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
17494                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17495                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17496                    boolean previous) {
17497                    StringBundler query = null;
17498    
17499                    if (orderByComparator != null) {
17500                            query = new StringBundler(6 +
17501                                            (orderByComparator.getOrderByFields().length * 6));
17502                    }
17503                    else {
17504                            query = new StringBundler(3);
17505                    }
17506    
17507                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17508    
17509                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17510    
17511                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17512    
17513                    boolean bindDisplayDate = false;
17514    
17515                    if (displayDate == null) {
17516                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17517                    }
17518                    else {
17519                            bindDisplayDate = true;
17520    
17521                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17522                    }
17523    
17524                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17525    
17526                    if (orderByComparator != null) {
17527                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17528    
17529                            if (orderByConditionFields.length > 0) {
17530                                    query.append(WHERE_AND);
17531                            }
17532    
17533                            for (int i = 0; i < orderByConditionFields.length; i++) {
17534                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17535                                    query.append(orderByConditionFields[i]);
17536    
17537                                    if ((i + 1) < orderByConditionFields.length) {
17538                                            if (orderByComparator.isAscending() ^ previous) {
17539                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17540                                            }
17541                                            else {
17542                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17543                                            }
17544                                    }
17545                                    else {
17546                                            if (orderByComparator.isAscending() ^ previous) {
17547                                                    query.append(WHERE_GREATER_THAN);
17548                                            }
17549                                            else {
17550                                                    query.append(WHERE_LESSER_THAN);
17551                                            }
17552                                    }
17553                            }
17554    
17555                            query.append(ORDER_BY_CLAUSE);
17556    
17557                            String[] orderByFields = orderByComparator.getOrderByFields();
17558    
17559                            for (int i = 0; i < orderByFields.length; i++) {
17560                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17561                                    query.append(orderByFields[i]);
17562    
17563                                    if ((i + 1) < orderByFields.length) {
17564                                            if (orderByComparator.isAscending() ^ previous) {
17565                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17566                                            }
17567                                            else {
17568                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17569                                            }
17570                                    }
17571                                    else {
17572                                            if (orderByComparator.isAscending() ^ previous) {
17573                                                    query.append(ORDER_BY_ASC);
17574                                            }
17575                                            else {
17576                                                    query.append(ORDER_BY_DESC);
17577                                            }
17578                                    }
17579                            }
17580                    }
17581                    else {
17582                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17583                    }
17584    
17585                    String sql = query.toString();
17586    
17587                    Query q = session.createQuery(sql);
17588    
17589                    q.setFirstResult(0);
17590                    q.setMaxResults(2);
17591    
17592                    QueryPos qPos = QueryPos.getInstance(q);
17593    
17594                    qPos.add(groupId);
17595    
17596                    qPos.add(userId);
17597    
17598                    if (bindDisplayDate) {
17599                            qPos.add(new Timestamp(displayDate.getTime()));
17600                    }
17601    
17602                    qPos.add(status);
17603    
17604                    if (orderByComparator != null) {
17605                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17606    
17607                            for (Object value : values) {
17608                                    qPos.add(value);
17609                            }
17610                    }
17611    
17612                    List<BlogsEntry> list = q.list();
17613    
17614                    if (list.size() == 2) {
17615                            return list.get(1);
17616                    }
17617                    else {
17618                            return null;
17619                    }
17620            }
17621    
17622            /**
17623             * 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;.
17624             *
17625             * @param groupId the group ID
17626             * @param userId the user ID
17627             * @param displayDate the display date
17628             * @param status the status
17629             * @return the matching blogs entries that the user has permission to view
17630             */
17631            @Override
17632            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17633                    Date displayDate, int status) {
17634                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17635                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17636            }
17637    
17638            /**
17639             * 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;.
17640             *
17641             * <p>
17642             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17643             * </p>
17644             *
17645             * @param groupId the group ID
17646             * @param userId the user ID
17647             * @param displayDate the display date
17648             * @param status the status
17649             * @param start the lower bound of the range of blogs entries
17650             * @param end the upper bound of the range of blogs entries (not inclusive)
17651             * @return the range of matching blogs entries that the user has permission to view
17652             */
17653            @Override
17654            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17655                    Date displayDate, int status, int start, int end) {
17656                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17657                            start, end, null);
17658            }
17659    
17660            /**
17661             * 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;.
17662             *
17663             * <p>
17664             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17665             * </p>
17666             *
17667             * @param groupId the group ID
17668             * @param userId the user ID
17669             * @param displayDate the display date
17670             * @param status the status
17671             * @param start the lower bound of the range of blogs entries
17672             * @param end the upper bound of the range of blogs entries (not inclusive)
17673             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17674             * @return the ordered range of matching blogs entries that the user has permission to view
17675             */
17676            @Override
17677            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17678                    Date displayDate, int status, int start, int end,
17679                    OrderByComparator<BlogsEntry> orderByComparator) {
17680                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17681                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17682                                    start, end, orderByComparator);
17683                    }
17684    
17685                    StringBundler query = null;
17686    
17687                    if (orderByComparator != null) {
17688                            query = new StringBundler(6 +
17689                                            (orderByComparator.getOrderByFields().length * 3));
17690                    }
17691                    else {
17692                            query = new StringBundler(6);
17693                    }
17694    
17695                    if (getDB().isSupportsInlineDistinct()) {
17696                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17697                    }
17698                    else {
17699                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17700                    }
17701    
17702                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17703    
17704                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17705    
17706                    boolean bindDisplayDate = false;
17707    
17708                    if (displayDate == null) {
17709                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17710                    }
17711                    else {
17712                            bindDisplayDate = true;
17713    
17714                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17715                    }
17716    
17717                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17718    
17719                    if (!getDB().isSupportsInlineDistinct()) {
17720                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17721                    }
17722    
17723                    if (orderByComparator != null) {
17724                            if (getDB().isSupportsInlineDistinct()) {
17725                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17726                                            orderByComparator, true);
17727                            }
17728                            else {
17729                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17730                                            orderByComparator, true);
17731                            }
17732                    }
17733                    else {
17734                            if (getDB().isSupportsInlineDistinct()) {
17735                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17736                            }
17737                            else {
17738                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17739                            }
17740                    }
17741    
17742                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17743                                    BlogsEntry.class.getName(),
17744                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17745    
17746                    Session session = null;
17747    
17748                    try {
17749                            session = openSession();
17750    
17751                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17752    
17753                            if (getDB().isSupportsInlineDistinct()) {
17754                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17755                            }
17756                            else {
17757                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17758                            }
17759    
17760                            QueryPos qPos = QueryPos.getInstance(q);
17761    
17762                            qPos.add(groupId);
17763    
17764                            qPos.add(userId);
17765    
17766                            if (bindDisplayDate) {
17767                                    qPos.add(new Timestamp(displayDate.getTime()));
17768                            }
17769    
17770                            qPos.add(status);
17771    
17772                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17773                    }
17774                    catch (Exception e) {
17775                            throw processException(e);
17776                    }
17777                    finally {
17778                            closeSession(session);
17779                    }
17780            }
17781    
17782            /**
17783             * 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;.
17784             *
17785             * @param entryId the primary key of the current blogs entry
17786             * @param groupId the group ID
17787             * @param userId the user ID
17788             * @param displayDate the display date
17789             * @param status the status
17790             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17791             * @return the previous, current, and next blogs entry
17792             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17793             */
17794            @Override
17795            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
17796                    long groupId, long userId, Date displayDate, int status,
17797                    OrderByComparator<BlogsEntry> orderByComparator)
17798                    throws NoSuchEntryException {
17799                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17800                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
17801                                    displayDate, status, orderByComparator);
17802                    }
17803    
17804                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17805    
17806                    Session session = null;
17807    
17808                    try {
17809                            session = openSession();
17810    
17811                            BlogsEntry[] array = new BlogsEntryImpl[3];
17812    
17813                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17814                                            groupId, userId, displayDate, status, orderByComparator,
17815                                            true);
17816    
17817                            array[1] = blogsEntry;
17818    
17819                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17820                                            groupId, userId, displayDate, status, orderByComparator,
17821                                            false);
17822    
17823                            return array;
17824                    }
17825                    catch (Exception e) {
17826                            throw processException(e);
17827                    }
17828                    finally {
17829                            closeSession(session);
17830                    }
17831            }
17832    
17833            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
17834                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17835                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17836                    boolean previous) {
17837                    StringBundler query = null;
17838    
17839                    if (orderByComparator != null) {
17840                            query = new StringBundler(6 +
17841                                            (orderByComparator.getOrderByFields().length * 6));
17842                    }
17843                    else {
17844                            query = new StringBundler(3);
17845                    }
17846    
17847                    if (getDB().isSupportsInlineDistinct()) {
17848                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17849                    }
17850                    else {
17851                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17852                    }
17853    
17854                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17855    
17856                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17857    
17858                    boolean bindDisplayDate = false;
17859    
17860                    if (displayDate == null) {
17861                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17862                    }
17863                    else {
17864                            bindDisplayDate = true;
17865    
17866                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17867                    }
17868    
17869                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17870    
17871                    if (!getDB().isSupportsInlineDistinct()) {
17872                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17873                    }
17874    
17875                    if (orderByComparator != null) {
17876                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17877    
17878                            if (orderByConditionFields.length > 0) {
17879                                    query.append(WHERE_AND);
17880                            }
17881    
17882                            for (int i = 0; i < orderByConditionFields.length; i++) {
17883                                    if (getDB().isSupportsInlineDistinct()) {
17884                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17885                                    }
17886                                    else {
17887                                            query.append(_ORDER_BY_ENTITY_TABLE);
17888                                    }
17889    
17890                                    query.append(orderByConditionFields[i]);
17891    
17892                                    if ((i + 1) < orderByConditionFields.length) {
17893                                            if (orderByComparator.isAscending() ^ previous) {
17894                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17895                                            }
17896                                            else {
17897                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17898                                            }
17899                                    }
17900                                    else {
17901                                            if (orderByComparator.isAscending() ^ previous) {
17902                                                    query.append(WHERE_GREATER_THAN);
17903                                            }
17904                                            else {
17905                                                    query.append(WHERE_LESSER_THAN);
17906                                            }
17907                                    }
17908                            }
17909    
17910                            query.append(ORDER_BY_CLAUSE);
17911    
17912                            String[] orderByFields = orderByComparator.getOrderByFields();
17913    
17914                            for (int i = 0; i < orderByFields.length; i++) {
17915                                    if (getDB().isSupportsInlineDistinct()) {
17916                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17917                                    }
17918                                    else {
17919                                            query.append(_ORDER_BY_ENTITY_TABLE);
17920                                    }
17921    
17922                                    query.append(orderByFields[i]);
17923    
17924                                    if ((i + 1) < orderByFields.length) {
17925                                            if (orderByComparator.isAscending() ^ previous) {
17926                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17927                                            }
17928                                            else {
17929                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17930                                            }
17931                                    }
17932                                    else {
17933                                            if (orderByComparator.isAscending() ^ previous) {
17934                                                    query.append(ORDER_BY_ASC);
17935                                            }
17936                                            else {
17937                                                    query.append(ORDER_BY_DESC);
17938                                            }
17939                                    }
17940                            }
17941                    }
17942                    else {
17943                            if (getDB().isSupportsInlineDistinct()) {
17944                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17945                            }
17946                            else {
17947                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17948                            }
17949                    }
17950    
17951                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17952                                    BlogsEntry.class.getName(),
17953                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17954    
17955                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17956    
17957                    q.setFirstResult(0);
17958                    q.setMaxResults(2);
17959    
17960                    if (getDB().isSupportsInlineDistinct()) {
17961                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17962                    }
17963                    else {
17964                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17965                    }
17966    
17967                    QueryPos qPos = QueryPos.getInstance(q);
17968    
17969                    qPos.add(groupId);
17970    
17971                    qPos.add(userId);
17972    
17973                    if (bindDisplayDate) {
17974                            qPos.add(new Timestamp(displayDate.getTime()));
17975                    }
17976    
17977                    qPos.add(status);
17978    
17979                    if (orderByComparator != null) {
17980                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17981    
17982                            for (Object value : values) {
17983                                    qPos.add(value);
17984                            }
17985                    }
17986    
17987                    List<BlogsEntry> list = q.list();
17988    
17989                    if (list.size() == 2) {
17990                            return list.get(1);
17991                    }
17992                    else {
17993                            return null;
17994                    }
17995            }
17996    
17997            /**
17998             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
17999             *
18000             * @param groupId the group ID
18001             * @param userId the user ID
18002             * @param displayDate the display date
18003             * @param status the status
18004             */
18005            @Override
18006            public void removeByG_U_LtD_NotS(long groupId, long userId,
18007                    Date displayDate, int status) {
18008                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
18009                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18010                            remove(blogsEntry);
18011                    }
18012            }
18013    
18014            /**
18015             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
18016             *
18017             * @param groupId the group ID
18018             * @param userId the user ID
18019             * @param displayDate the display date
18020             * @param status the status
18021             * @return the number of matching blogs entries
18022             */
18023            @Override
18024            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
18025                    int status) {
18026                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
18027    
18028                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
18029    
18030                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
18031    
18032                    if (count == null) {
18033                            StringBundler query = new StringBundler(5);
18034    
18035                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
18036    
18037                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18038    
18039                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18040    
18041                            boolean bindDisplayDate = false;
18042    
18043                            if (displayDate == null) {
18044                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18045                            }
18046                            else {
18047                                    bindDisplayDate = true;
18048    
18049                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18050                            }
18051    
18052                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18053    
18054                            String sql = query.toString();
18055    
18056                            Session session = null;
18057    
18058                            try {
18059                                    session = openSession();
18060    
18061                                    Query q = session.createQuery(sql);
18062    
18063                                    QueryPos qPos = QueryPos.getInstance(q);
18064    
18065                                    qPos.add(groupId);
18066    
18067                                    qPos.add(userId);
18068    
18069                                    if (bindDisplayDate) {
18070                                            qPos.add(new Timestamp(displayDate.getTime()));
18071                                    }
18072    
18073                                    qPos.add(status);
18074    
18075                                    count = (Long)q.uniqueResult();
18076    
18077                                    finderCache.putResult(finderPath, finderArgs, count);
18078                            }
18079                            catch (Exception e) {
18080                                    finderCache.removeResult(finderPath, finderArgs);
18081    
18082                                    throw processException(e);
18083                            }
18084                            finally {
18085                                    closeSession(session);
18086                            }
18087                    }
18088    
18089                    return count.intValue();
18090            }
18091    
18092            /**
18093             * 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;.
18094             *
18095             * @param groupId the group ID
18096             * @param userId the user ID
18097             * @param displayDate the display date
18098             * @param status the status
18099             * @return the number of matching blogs entries that the user has permission to view
18100             */
18101            @Override
18102            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
18103                    Date displayDate, int status) {
18104                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18105                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18106                    }
18107    
18108                    StringBundler query = new StringBundler(5);
18109    
18110                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
18111    
18112                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18113    
18114                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18115    
18116                    boolean bindDisplayDate = false;
18117    
18118                    if (displayDate == null) {
18119                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18120                    }
18121                    else {
18122                            bindDisplayDate = true;
18123    
18124                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18125                    }
18126    
18127                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18128    
18129                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18130                                    BlogsEntry.class.getName(),
18131                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18132    
18133                    Session session = null;
18134    
18135                    try {
18136                            session = openSession();
18137    
18138                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18139    
18140                            q.addScalar(COUNT_COLUMN_NAME,
18141                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18142    
18143                            QueryPos qPos = QueryPos.getInstance(q);
18144    
18145                            qPos.add(groupId);
18146    
18147                            qPos.add(userId);
18148    
18149                            if (bindDisplayDate) {
18150                                    qPos.add(new Timestamp(displayDate.getTime()));
18151                            }
18152    
18153                            qPos.add(status);
18154    
18155                            Long count = (Long)q.uniqueResult();
18156    
18157                            return count.intValue();
18158                    }
18159                    catch (Exception e) {
18160                            throw processException(e);
18161                    }
18162                    finally {
18163                            closeSession(session);
18164                    }
18165            }
18166    
18167            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18168            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
18169            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
18170            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18171            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
18172    
18173            public BlogsEntryPersistenceImpl() {
18174                    setModelClass(BlogsEntry.class);
18175            }
18176    
18177            /**
18178             * Caches the blogs entry in the entity cache if it is enabled.
18179             *
18180             * @param blogsEntry the blogs entry
18181             */
18182            @Override
18183            public void cacheResult(BlogsEntry blogsEntry) {
18184                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18185                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18186    
18187                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
18188                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
18189                            blogsEntry);
18190    
18191                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
18192                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
18193                            blogsEntry);
18194    
18195                    blogsEntry.resetOriginalValues();
18196            }
18197    
18198            /**
18199             * Caches the blogs entries in the entity cache if it is enabled.
18200             *
18201             * @param blogsEntries the blogs entries
18202             */
18203            @Override
18204            public void cacheResult(List<BlogsEntry> blogsEntries) {
18205                    for (BlogsEntry blogsEntry : blogsEntries) {
18206                            if (entityCache.getResult(
18207                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18208                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
18209                                    cacheResult(blogsEntry);
18210                            }
18211                            else {
18212                                    blogsEntry.resetOriginalValues();
18213                            }
18214                    }
18215            }
18216    
18217            /**
18218             * Clears the cache for all blogs entries.
18219             *
18220             * <p>
18221             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18222             * </p>
18223             */
18224            @Override
18225            public void clearCache() {
18226                    entityCache.clearCache(BlogsEntryImpl.class);
18227    
18228                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
18229                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18230                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18231            }
18232    
18233            /**
18234             * Clears the cache for the blogs entry.
18235             *
18236             * <p>
18237             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18238             * </p>
18239             */
18240            @Override
18241            public void clearCache(BlogsEntry blogsEntry) {
18242                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18243                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18244    
18245                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18246                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18247    
18248                    clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18249            }
18250    
18251            @Override
18252            public void clearCache(List<BlogsEntry> blogsEntries) {
18253                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18254                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18255    
18256                    for (BlogsEntry blogsEntry : blogsEntries) {
18257                            entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18258                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18259    
18260                            clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18261                    }
18262            }
18263    
18264            protected void cacheUniqueFindersCache(
18265                    BlogsEntryModelImpl blogsEntryModelImpl, boolean isNew) {
18266                    if (isNew) {
18267                            Object[] args = new Object[] {
18268                                            blogsEntryModelImpl.getUuid(),
18269                                            blogsEntryModelImpl.getGroupId()
18270                                    };
18271    
18272                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18273                                    Long.valueOf(1));
18274                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18275                                    blogsEntryModelImpl);
18276    
18277                            args = new Object[] {
18278                                            blogsEntryModelImpl.getGroupId(),
18279                                            blogsEntryModelImpl.getUrlTitle()
18280                                    };
18281    
18282                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18283                                    Long.valueOf(1));
18284                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18285                                    blogsEntryModelImpl);
18286                    }
18287                    else {
18288                            if ((blogsEntryModelImpl.getColumnBitmask() &
18289                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18290                                    Object[] args = new Object[] {
18291                                                    blogsEntryModelImpl.getUuid(),
18292                                                    blogsEntryModelImpl.getGroupId()
18293                                            };
18294    
18295                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18296                                            Long.valueOf(1));
18297                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18298                                            blogsEntryModelImpl);
18299                            }
18300    
18301                            if ((blogsEntryModelImpl.getColumnBitmask() &
18302                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18303                                    Object[] args = new Object[] {
18304                                                    blogsEntryModelImpl.getGroupId(),
18305                                                    blogsEntryModelImpl.getUrlTitle()
18306                                            };
18307    
18308                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18309                                            Long.valueOf(1));
18310                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18311                                            blogsEntryModelImpl);
18312                            }
18313                    }
18314            }
18315    
18316            protected void clearUniqueFindersCache(
18317                    BlogsEntryModelImpl blogsEntryModelImpl) {
18318                    Object[] args = new Object[] {
18319                                    blogsEntryModelImpl.getUuid(), blogsEntryModelImpl.getGroupId()
18320                            };
18321    
18322                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18323                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18324    
18325                    if ((blogsEntryModelImpl.getColumnBitmask() &
18326                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18327                            args = new Object[] {
18328                                            blogsEntryModelImpl.getOriginalUuid(),
18329                                            blogsEntryModelImpl.getOriginalGroupId()
18330                                    };
18331    
18332                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18333                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18334                    }
18335    
18336                    args = new Object[] {
18337                                    blogsEntryModelImpl.getGroupId(),
18338                                    blogsEntryModelImpl.getUrlTitle()
18339                            };
18340    
18341                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18342                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18343    
18344                    if ((blogsEntryModelImpl.getColumnBitmask() &
18345                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18346                            args = new Object[] {
18347                                            blogsEntryModelImpl.getOriginalGroupId(),
18348                                            blogsEntryModelImpl.getOriginalUrlTitle()
18349                                    };
18350    
18351                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18352                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18353                    }
18354            }
18355    
18356            /**
18357             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18358             *
18359             * @param entryId the primary key for the new blogs entry
18360             * @return the new blogs entry
18361             */
18362            @Override
18363            public BlogsEntry create(long entryId) {
18364                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18365    
18366                    blogsEntry.setNew(true);
18367                    blogsEntry.setPrimaryKey(entryId);
18368    
18369                    String uuid = PortalUUIDUtil.generate();
18370    
18371                    blogsEntry.setUuid(uuid);
18372    
18373                    return blogsEntry;
18374            }
18375    
18376            /**
18377             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18378             *
18379             * @param entryId the primary key of the blogs entry
18380             * @return the blogs entry that was removed
18381             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18382             */
18383            @Override
18384            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
18385                    return remove((Serializable)entryId);
18386            }
18387    
18388            /**
18389             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18390             *
18391             * @param primaryKey the primary key of the blogs entry
18392             * @return the blogs entry that was removed
18393             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18394             */
18395            @Override
18396            public BlogsEntry remove(Serializable primaryKey)
18397                    throws NoSuchEntryException {
18398                    Session session = null;
18399    
18400                    try {
18401                            session = openSession();
18402    
18403                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18404                                            primaryKey);
18405    
18406                            if (blogsEntry == null) {
18407                                    if (_log.isWarnEnabled()) {
18408                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18409                                    }
18410    
18411                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18412                                            primaryKey);
18413                            }
18414    
18415                            return remove(blogsEntry);
18416                    }
18417                    catch (NoSuchEntryException nsee) {
18418                            throw nsee;
18419                    }
18420                    catch (Exception e) {
18421                            throw processException(e);
18422                    }
18423                    finally {
18424                            closeSession(session);
18425                    }
18426            }
18427    
18428            @Override
18429            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
18430                    blogsEntry = toUnwrappedModel(blogsEntry);
18431    
18432                    Session session = null;
18433    
18434                    try {
18435                            session = openSession();
18436    
18437                            if (!session.contains(blogsEntry)) {
18438                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18439                                                    blogsEntry.getPrimaryKeyObj());
18440                            }
18441    
18442                            if (blogsEntry != null) {
18443                                    session.delete(blogsEntry);
18444                            }
18445                    }
18446                    catch (Exception e) {
18447                            throw processException(e);
18448                    }
18449                    finally {
18450                            closeSession(session);
18451                    }
18452    
18453                    if (blogsEntry != null) {
18454                            clearCache(blogsEntry);
18455                    }
18456    
18457                    return blogsEntry;
18458            }
18459    
18460            @Override
18461            public BlogsEntry updateImpl(BlogsEntry blogsEntry) {
18462                    blogsEntry = toUnwrappedModel(blogsEntry);
18463    
18464                    boolean isNew = blogsEntry.isNew();
18465    
18466                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18467    
18468                    if (Validator.isNull(blogsEntry.getUuid())) {
18469                            String uuid = PortalUUIDUtil.generate();
18470    
18471                            blogsEntry.setUuid(uuid);
18472                    }
18473    
18474                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
18475    
18476                    Date now = new Date();
18477    
18478                    if (isNew && (blogsEntry.getCreateDate() == null)) {
18479                            if (serviceContext == null) {
18480                                    blogsEntry.setCreateDate(now);
18481                            }
18482                            else {
18483                                    blogsEntry.setCreateDate(serviceContext.getCreateDate(now));
18484                            }
18485                    }
18486    
18487                    if (!blogsEntryModelImpl.hasSetModifiedDate()) {
18488                            if (serviceContext == null) {
18489                                    blogsEntry.setModifiedDate(now);
18490                            }
18491                            else {
18492                                    blogsEntry.setModifiedDate(serviceContext.getModifiedDate(now));
18493                            }
18494                    }
18495    
18496                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
18497    
18498                    if (userId > 0) {
18499                            long companyId = blogsEntry.getCompanyId();
18500    
18501                            long groupId = blogsEntry.getGroupId();
18502    
18503                            long entryId = 0;
18504    
18505                            if (!isNew) {
18506                                    entryId = blogsEntry.getPrimaryKey();
18507                            }
18508    
18509                            try {
18510                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
18511                                                    userId,
18512                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18513                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
18514                                                    blogsEntry.getTitle(), null));
18515    
18516                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
18517                                                    groupId, userId,
18518                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18519                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
18520                                                    blogsEntry.getContent(), null));
18521                            }
18522                            catch (SanitizerException se) {
18523                                    throw new SystemException(se);
18524                            }
18525                    }
18526    
18527                    Session session = null;
18528    
18529                    try {
18530                            session = openSession();
18531    
18532                            if (blogsEntry.isNew()) {
18533                                    session.save(blogsEntry);
18534    
18535                                    blogsEntry.setNew(false);
18536                            }
18537                            else {
18538                                    blogsEntry = (BlogsEntry)session.merge(blogsEntry);
18539                            }
18540                    }
18541                    catch (Exception e) {
18542                            throw processException(e);
18543                    }
18544                    finally {
18545                            closeSession(session);
18546                    }
18547    
18548                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18549    
18550                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
18551                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18552                    }
18553    
18554                    else {
18555                            if ((blogsEntryModelImpl.getColumnBitmask() &
18556                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
18557                                    Object[] args = new Object[] {
18558                                                    blogsEntryModelImpl.getOriginalUuid()
18559                                            };
18560    
18561                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18562                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18563                                            args);
18564    
18565                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
18566    
18567                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18568                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18569                                            args);
18570                            }
18571    
18572                            if ((blogsEntryModelImpl.getColumnBitmask() &
18573                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
18574                                    Object[] args = new Object[] {
18575                                                    blogsEntryModelImpl.getOriginalUuid(),
18576                                                    blogsEntryModelImpl.getOriginalCompanyId()
18577                                            };
18578    
18579                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18580                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18581                                            args);
18582    
18583                                    args = new Object[] {
18584                                                    blogsEntryModelImpl.getUuid(),
18585                                                    blogsEntryModelImpl.getCompanyId()
18586                                            };
18587    
18588                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18589                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18590                                            args);
18591                            }
18592    
18593                            if ((blogsEntryModelImpl.getColumnBitmask() &
18594                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
18595                                    Object[] args = new Object[] {
18596                                                    blogsEntryModelImpl.getOriginalGroupId()
18597                                            };
18598    
18599                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18600                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18601                                            args);
18602    
18603                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
18604    
18605                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18606                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18607                                            args);
18608                            }
18609    
18610                            if ((blogsEntryModelImpl.getColumnBitmask() &
18611                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
18612                                    Object[] args = new Object[] {
18613                                                    blogsEntryModelImpl.getOriginalCompanyId()
18614                                            };
18615    
18616                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
18617                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18618                                            args);
18619    
18620                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
18621    
18622                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
18623                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18624                                            args);
18625                            }
18626    
18627                            if ((blogsEntryModelImpl.getColumnBitmask() &
18628                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18629                                    Object[] args = new Object[] {
18630                                                    blogsEntryModelImpl.getOriginalGroupId(),
18631                                                    blogsEntryModelImpl.getOriginalStatus()
18632                                            };
18633    
18634                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18635                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18636                                            args);
18637    
18638                                    args = new Object[] {
18639                                                    blogsEntryModelImpl.getGroupId(),
18640                                                    blogsEntryModelImpl.getStatus()
18641                                            };
18642    
18643                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18644                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18645                                            args);
18646                            }
18647    
18648                            if ((blogsEntryModelImpl.getColumnBitmask() &
18649                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
18650                                    Object[] args = new Object[] {
18651                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18652                                                    blogsEntryModelImpl.getOriginalUserId()
18653                                            };
18654    
18655                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18656                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18657                                            args);
18658    
18659                                    args = new Object[] {
18660                                                    blogsEntryModelImpl.getCompanyId(),
18661                                                    blogsEntryModelImpl.getUserId()
18662                                            };
18663    
18664                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18665                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18666                                            args);
18667                            }
18668    
18669                            if ((blogsEntryModelImpl.getColumnBitmask() &
18670                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18671                                    Object[] args = new Object[] {
18672                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18673                                                    blogsEntryModelImpl.getOriginalStatus()
18674                                            };
18675    
18676                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18677                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18678                                            args);
18679    
18680                                    args = new Object[] {
18681                                                    blogsEntryModelImpl.getCompanyId(),
18682                                                    blogsEntryModelImpl.getStatus()
18683                                            };
18684    
18685                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18686                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18687                                            args);
18688                            }
18689    
18690                            if ((blogsEntryModelImpl.getColumnBitmask() &
18691                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18692                                    Object[] args = new Object[] {
18693                                                    blogsEntryModelImpl.getOriginalGroupId(),
18694                                                    blogsEntryModelImpl.getOriginalUserId(),
18695                                                    blogsEntryModelImpl.getOriginalStatus()
18696                                            };
18697    
18698                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18699                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18700                                            args);
18701    
18702                                    args = new Object[] {
18703                                                    blogsEntryModelImpl.getGroupId(),
18704                                                    blogsEntryModelImpl.getUserId(),
18705                                                    blogsEntryModelImpl.getStatus()
18706                                            };
18707    
18708                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18709                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18710                                            args);
18711                            }
18712    
18713                            if ((blogsEntryModelImpl.getColumnBitmask() &
18714                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18715                                    Object[] args = new Object[] {
18716                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18717                                                    blogsEntryModelImpl.getOriginalUserId(),
18718                                                    blogsEntryModelImpl.getOriginalStatus()
18719                                            };
18720    
18721                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18722                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18723                                            args);
18724    
18725                                    args = new Object[] {
18726                                                    blogsEntryModelImpl.getCompanyId(),
18727                                                    blogsEntryModelImpl.getUserId(),
18728                                                    blogsEntryModelImpl.getStatus()
18729                                            };
18730    
18731                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18732                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18733                                            args);
18734                            }
18735                    }
18736    
18737                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18738                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry, false);
18739    
18740                    clearUniqueFindersCache(blogsEntryModelImpl);
18741                    cacheUniqueFindersCache(blogsEntryModelImpl, isNew);
18742    
18743                    blogsEntry.resetOriginalValues();
18744    
18745                    return blogsEntry;
18746            }
18747    
18748            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18749                    if (blogsEntry instanceof BlogsEntryImpl) {
18750                            return blogsEntry;
18751                    }
18752    
18753                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18754    
18755                    blogsEntryImpl.setNew(blogsEntry.isNew());
18756                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18757    
18758                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
18759                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18760                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18761                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18762                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
18763                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
18764                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18765                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18766                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
18767                    blogsEntryImpl.setSubtitle(blogsEntry.getSubtitle());
18768                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18769                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
18770                    blogsEntryImpl.setContent(blogsEntry.getContent());
18771                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18772                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18773                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18774                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18775                    blogsEntryImpl.setCoverImageCaption(blogsEntry.getCoverImageCaption());
18776                    blogsEntryImpl.setCoverImageFileEntryId(blogsEntry.getCoverImageFileEntryId());
18777                    blogsEntryImpl.setCoverImageURL(blogsEntry.getCoverImageURL());
18778                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18779                    blogsEntryImpl.setSmallImageFileEntryId(blogsEntry.getSmallImageFileEntryId());
18780                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18781                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18782                    blogsEntryImpl.setLastPublishDate(blogsEntry.getLastPublishDate());
18783                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
18784                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18785                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18786                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18787    
18788                    return blogsEntryImpl;
18789            }
18790    
18791            /**
18792             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
18793             *
18794             * @param primaryKey the primary key of the blogs entry
18795             * @return the blogs entry
18796             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18797             */
18798            @Override
18799            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18800                    throws NoSuchEntryException {
18801                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18802    
18803                    if (blogsEntry == null) {
18804                            if (_log.isWarnEnabled()) {
18805                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18806                            }
18807    
18808                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18809                                    primaryKey);
18810                    }
18811    
18812                    return blogsEntry;
18813            }
18814    
18815            /**
18816             * Returns the blogs entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found.
18817             *
18818             * @param entryId the primary key of the blogs entry
18819             * @return the blogs entry
18820             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18821             */
18822            @Override
18823            public BlogsEntry findByPrimaryKey(long entryId)
18824                    throws NoSuchEntryException {
18825                    return findByPrimaryKey((Serializable)entryId);
18826            }
18827    
18828            /**
18829             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18830             *
18831             * @param primaryKey the primary key of the blogs entry
18832             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18833             */
18834            @Override
18835            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey) {
18836                    BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18837                                    BlogsEntryImpl.class, primaryKey);
18838    
18839                    if (blogsEntry == _nullBlogsEntry) {
18840                            return null;
18841                    }
18842    
18843                    if (blogsEntry == null) {
18844                            Session session = null;
18845    
18846                            try {
18847                                    session = openSession();
18848    
18849                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18850                                                    primaryKey);
18851    
18852                                    if (blogsEntry != null) {
18853                                            cacheResult(blogsEntry);
18854                                    }
18855                                    else {
18856                                            entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18857                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18858                                    }
18859                            }
18860                            catch (Exception e) {
18861                                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18862                                            BlogsEntryImpl.class, primaryKey);
18863    
18864                                    throw processException(e);
18865                            }
18866                            finally {
18867                                    closeSession(session);
18868                            }
18869                    }
18870    
18871                    return blogsEntry;
18872            }
18873    
18874            /**
18875             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18876             *
18877             * @param entryId the primary key of the blogs entry
18878             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18879             */
18880            @Override
18881            public BlogsEntry fetchByPrimaryKey(long entryId) {
18882                    return fetchByPrimaryKey((Serializable)entryId);
18883            }
18884    
18885            @Override
18886            public Map<Serializable, BlogsEntry> fetchByPrimaryKeys(
18887                    Set<Serializable> primaryKeys) {
18888                    if (primaryKeys.isEmpty()) {
18889                            return Collections.emptyMap();
18890                    }
18891    
18892                    Map<Serializable, BlogsEntry> map = new HashMap<Serializable, BlogsEntry>();
18893    
18894                    if (primaryKeys.size() == 1) {
18895                            Iterator<Serializable> iterator = primaryKeys.iterator();
18896    
18897                            Serializable primaryKey = iterator.next();
18898    
18899                            BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18900    
18901                            if (blogsEntry != null) {
18902                                    map.put(primaryKey, blogsEntry);
18903                            }
18904    
18905                            return map;
18906                    }
18907    
18908                    Set<Serializable> uncachedPrimaryKeys = null;
18909    
18910                    for (Serializable primaryKey : primaryKeys) {
18911                            BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18912                                            BlogsEntryImpl.class, primaryKey);
18913    
18914                            if (blogsEntry == null) {
18915                                    if (uncachedPrimaryKeys == null) {
18916                                            uncachedPrimaryKeys = new HashSet<Serializable>();
18917                                    }
18918    
18919                                    uncachedPrimaryKeys.add(primaryKey);
18920                            }
18921                            else {
18922                                    map.put(primaryKey, blogsEntry);
18923                            }
18924                    }
18925    
18926                    if (uncachedPrimaryKeys == null) {
18927                            return map;
18928                    }
18929    
18930                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
18931                                    1);
18932    
18933                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN);
18934    
18935                    for (Serializable primaryKey : uncachedPrimaryKeys) {
18936                            query.append(String.valueOf(primaryKey));
18937    
18938                            query.append(StringPool.COMMA);
18939                    }
18940    
18941                    query.setIndex(query.index() - 1);
18942    
18943                    query.append(StringPool.CLOSE_PARENTHESIS);
18944    
18945                    String sql = query.toString();
18946    
18947                    Session session = null;
18948    
18949                    try {
18950                            session = openSession();
18951    
18952                            Query q = session.createQuery(sql);
18953    
18954                            for (BlogsEntry blogsEntry : (List<BlogsEntry>)q.list()) {
18955                                    map.put(blogsEntry.getPrimaryKeyObj(), blogsEntry);
18956    
18957                                    cacheResult(blogsEntry);
18958    
18959                                    uncachedPrimaryKeys.remove(blogsEntry.getPrimaryKeyObj());
18960                            }
18961    
18962                            for (Serializable primaryKey : uncachedPrimaryKeys) {
18963                                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18964                                            BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18965                            }
18966                    }
18967                    catch (Exception e) {
18968                            throw processException(e);
18969                    }
18970                    finally {
18971                            closeSession(session);
18972                    }
18973    
18974                    return map;
18975            }
18976    
18977            /**
18978             * Returns all the blogs entries.
18979             *
18980             * @return the blogs entries
18981             */
18982            @Override
18983            public List<BlogsEntry> findAll() {
18984                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18985            }
18986    
18987            /**
18988             * Returns a range of all the blogs entries.
18989             *
18990             * <p>
18991             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18992             * </p>
18993             *
18994             * @param start the lower bound of the range of blogs entries
18995             * @param end the upper bound of the range of blogs entries (not inclusive)
18996             * @return the range of blogs entries
18997             */
18998            @Override
18999            public List<BlogsEntry> findAll(int start, int end) {
19000                    return findAll(start, end, null);
19001            }
19002    
19003            /**
19004             * Returns an ordered range of all the blogs entries.
19005             *
19006             * <p>
19007             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19008             * </p>
19009             *
19010             * @param start the lower bound of the range of blogs entries
19011             * @param end the upper bound of the range of blogs entries (not inclusive)
19012             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19013             * @return the ordered range of blogs entries
19014             */
19015            @Override
19016            public List<BlogsEntry> findAll(int start, int end,
19017                    OrderByComparator<BlogsEntry> orderByComparator) {
19018                    return findAll(start, end, orderByComparator, true);
19019            }
19020    
19021            /**
19022             * Returns an ordered range of all the blogs entries.
19023             *
19024             * <p>
19025             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19026             * </p>
19027             *
19028             * @param start the lower bound of the range of blogs entries
19029             * @param end the upper bound of the range of blogs entries (not inclusive)
19030             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19031             * @param retrieveFromCache whether to retrieve from the finder cache
19032             * @return the ordered range of blogs entries
19033             */
19034            @Override
19035            public List<BlogsEntry> findAll(int start, int end,
19036                    OrderByComparator<BlogsEntry> orderByComparator,
19037                    boolean retrieveFromCache) {
19038                    boolean pagination = true;
19039                    FinderPath finderPath = null;
19040                    Object[] finderArgs = null;
19041    
19042                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19043                                    (orderByComparator == null)) {
19044                            pagination = false;
19045                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
19046                            finderArgs = FINDER_ARGS_EMPTY;
19047                    }
19048                    else {
19049                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
19050                            finderArgs = new Object[] { start, end, orderByComparator };
19051                    }
19052    
19053                    List<BlogsEntry> list = null;
19054    
19055                    if (retrieveFromCache) {
19056                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
19057                                            finderArgs, this);
19058                    }
19059    
19060                    if (list == null) {
19061                            StringBundler query = null;
19062                            String sql = null;
19063    
19064                            if (orderByComparator != null) {
19065                                    query = new StringBundler(2 +
19066                                                    (orderByComparator.getOrderByFields().length * 3));
19067    
19068                                    query.append(_SQL_SELECT_BLOGSENTRY);
19069    
19070                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19071                                            orderByComparator);
19072    
19073                                    sql = query.toString();
19074                            }
19075                            else {
19076                                    sql = _SQL_SELECT_BLOGSENTRY;
19077    
19078                                    if (pagination) {
19079                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
19080                                    }
19081                            }
19082    
19083                            Session session = null;
19084    
19085                            try {
19086                                    session = openSession();
19087    
19088                                    Query q = session.createQuery(sql);
19089    
19090                                    if (!pagination) {
19091                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19092                                                            start, end, false);
19093    
19094                                            Collections.sort(list);
19095    
19096                                            list = Collections.unmodifiableList(list);
19097                                    }
19098                                    else {
19099                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19100                                                            start, end);
19101                                    }
19102    
19103                                    cacheResult(list);
19104    
19105                                    finderCache.putResult(finderPath, finderArgs, list);
19106                            }
19107                            catch (Exception e) {
19108                                    finderCache.removeResult(finderPath, finderArgs);
19109    
19110                                    throw processException(e);
19111                            }
19112                            finally {
19113                                    closeSession(session);
19114                            }
19115                    }
19116    
19117                    return list;
19118            }
19119    
19120            /**
19121             * Removes all the blogs entries from the database.
19122             *
19123             */
19124            @Override
19125            public void removeAll() {
19126                    for (BlogsEntry blogsEntry : findAll()) {
19127                            remove(blogsEntry);
19128                    }
19129            }
19130    
19131            /**
19132             * Returns the number of blogs entries.
19133             *
19134             * @return the number of blogs entries
19135             */
19136            @Override
19137            public int countAll() {
19138                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
19139                                    FINDER_ARGS_EMPTY, this);
19140    
19141                    if (count == null) {
19142                            Session session = null;
19143    
19144                            try {
19145                                    session = openSession();
19146    
19147                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
19148    
19149                                    count = (Long)q.uniqueResult();
19150    
19151                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
19152                                            count);
19153                            }
19154                            catch (Exception e) {
19155                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
19156                                            FINDER_ARGS_EMPTY);
19157    
19158                                    throw processException(e);
19159                            }
19160                            finally {
19161                                    closeSession(session);
19162                            }
19163                    }
19164    
19165                    return count.intValue();
19166            }
19167    
19168            @Override
19169            public Set<String> getBadColumnNames() {
19170                    return _badColumnNames;
19171            }
19172    
19173            @Override
19174            protected Map<String, Integer> getTableColumnsMap() {
19175                    return BlogsEntryModelImpl.TABLE_COLUMNS_MAP;
19176            }
19177    
19178            /**
19179             * Initializes the blogs entry persistence.
19180             */
19181            public void afterPropertiesSet() {
19182            }
19183    
19184            public void destroy() {
19185                    entityCache.removeCache(BlogsEntryImpl.class.getName());
19186                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
19187                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
19188                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19189            }
19190    
19191            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
19192            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
19193            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
19194            private static final String _SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE entryId IN (";
19195            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
19196            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
19197            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
19198            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
19199            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
19200            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
19201                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
19202            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
19203                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
19204            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
19205            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
19206            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
19207            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
19208            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
19209            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
19210            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
19211            private static final Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
19212            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
19213                                    "uuid"
19214                            });
19215            private static final BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
19216                            @Override
19217                            public Object clone() {
19218                                    return this;
19219                            }
19220    
19221                            @Override
19222                            public CacheModel<BlogsEntry> toCacheModel() {
19223                                    return _nullBlogsEntryCacheModel;
19224                            }
19225                    };
19226    
19227            private static final CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
19228                            @Override
19229                            public BlogsEntry toEntityModel() {
19230                                    return _nullBlogsEntry;
19231                            }
19232                    };
19233    }