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.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.SQLQuery;
029    import com.liferay.portal.kernel.dao.orm.Session;
030    import com.liferay.portal.kernel.exception.SystemException;
031    import com.liferay.portal.kernel.log.Log;
032    import com.liferay.portal.kernel.log.LogFactoryUtil;
033    import com.liferay.portal.kernel.sanitizer.Sanitizer;
034    import com.liferay.portal.kernel.sanitizer.SanitizerException;
035    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
036    import com.liferay.portal.kernel.util.ContentTypes;
037    import com.liferay.portal.kernel.util.GetterUtil;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.Validator;
043    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
044    import com.liferay.portal.model.CacheModel;
045    import com.liferay.portal.security.auth.PrincipalThreadLocal;
046    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047    import com.liferay.portal.service.ServiceContext;
048    import com.liferay.portal.service.ServiceContextThreadLocal;
049    import com.liferay.portal.service.persistence.CompanyProvider;
050    import com.liferay.portal.service.persistence.CompanyProviderWrapper;
051    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052    
053    import com.liferay.portlet.blogs.exception.NoSuchEntryException;
054    import com.liferay.portlet.blogs.model.BlogsEntry;
055    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
056    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
057    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
058    
059    import java.io.Serializable;
060    
061    import java.sql.Timestamp;
062    
063    import java.util.Collections;
064    import java.util.Date;
065    import java.util.HashMap;
066    import java.util.HashSet;
067    import java.util.Iterator;
068    import java.util.List;
069    import java.util.Map;
070    import java.util.Set;
071    
072    /**
073     * The persistence implementation for the blogs entry service.
074     *
075     * <p>
076     * Caching information and settings can be found in <code>portal.properties</code>
077     * </p>
078     *
079     * @author Brian Wing Shun Chan
080     * @see BlogsEntryPersistence
081     * @see com.liferay.portlet.blogs.service.persistence.BlogsEntryUtil
082     * @generated
083     */
084    @ProviderType
085    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
086            implements BlogsEntryPersistence {
087            /*
088             * NOTE FOR DEVELOPERS:
089             *
090             * 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.
091             */
092            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
093            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
094                    ".List1";
095            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
096                    ".List2";
097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
098                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
100            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
101                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
103            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
106            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
107                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
108                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
109                            new String[] {
110                                    String.class.getName(),
111                                    
112                            Integer.class.getName(), Integer.class.getName(),
113                                    OrderByComparator.class.getName()
114                            });
115            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
116                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
118                            new String[] { String.class.getName() },
119                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
120                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
121                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
122            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
123                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
125                            new String[] { String.class.getName() });
126    
127            /**
128             * Returns all the blogs entries where uuid = &#63;.
129             *
130             * @param uuid the uuid
131             * @return the matching blogs entries
132             */
133            @Override
134            public List<BlogsEntry> findByUuid(String uuid) {
135                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
136            }
137    
138            /**
139             * Returns a range of all the blogs entries where uuid = &#63;.
140             *
141             * <p>
142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
143             * </p>
144             *
145             * @param uuid the uuid
146             * @param start the lower bound of the range of blogs entries
147             * @param end the upper bound of the range of blogs entries (not inclusive)
148             * @return the range of matching blogs entries
149             */
150            @Override
151            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
152                    return findByUuid(uuid, start, end, null);
153            }
154    
155            /**
156             * Returns an ordered range of all the blogs entries where uuid = &#63;.
157             *
158             * <p>
159             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
160             * </p>
161             *
162             * @param uuid the uuid
163             * @param start the lower bound of the range of blogs entries
164             * @param end the upper bound of the range of blogs entries (not inclusive)
165             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
166             * @return the ordered range of matching blogs entries
167             */
168            @Override
169            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
170                    OrderByComparator<BlogsEntry> orderByComparator) {
171                    return findByUuid(uuid, start, end, orderByComparator, true);
172            }
173    
174            /**
175             * Returns an ordered range of all the blogs entries where uuid = &#63;.
176             *
177             * <p>
178             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
179             * </p>
180             *
181             * @param uuid the uuid
182             * @param start the lower bound of the range of blogs entries
183             * @param end the upper bound of the range of blogs entries (not inclusive)
184             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
185             * @param retrieveFromCache whether to retrieve from the finder cache
186             * @return the ordered range of matching blogs entries
187             */
188            @Override
189            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
190                    OrderByComparator<BlogsEntry> orderByComparator,
191                    boolean retrieveFromCache) {
192                    boolean pagination = true;
193                    FinderPath finderPath = null;
194                    Object[] finderArgs = null;
195    
196                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
197                                    (orderByComparator == null)) {
198                            pagination = false;
199                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
200                            finderArgs = new Object[] { uuid };
201                    }
202                    else {
203                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
204                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
205                    }
206    
207                    List<BlogsEntry> list = null;
208    
209                    if (retrieveFromCache) {
210                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
211                                            finderArgs, this);
212    
213                            if ((list != null) && !list.isEmpty()) {
214                                    for (BlogsEntry blogsEntry : list) {
215                                            if (!Validator.equals(uuid, blogsEntry.getUuid())) {
216                                                    list = null;
217    
218                                                    break;
219                                            }
220                                    }
221                            }
222                    }
223    
224                    if (list == null) {
225                            StringBundler query = null;
226    
227                            if (orderByComparator != null) {
228                                    query = new StringBundler(3 +
229                                                    (orderByComparator.getOrderByFields().length * 3));
230                            }
231                            else {
232                                    query = new StringBundler(3);
233                            }
234    
235                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
236    
237                            boolean bindUuid = false;
238    
239                            if (uuid == null) {
240                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
241                            }
242                            else if (uuid.equals(StringPool.BLANK)) {
243                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
244                            }
245                            else {
246                                    bindUuid = true;
247    
248                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
249                            }
250    
251                            if (orderByComparator != null) {
252                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
253                                            orderByComparator);
254                            }
255                            else
256                             if (pagination) {
257                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
258                            }
259    
260                            String sql = query.toString();
261    
262                            Session session = null;
263    
264                            try {
265                                    session = openSession();
266    
267                                    Query q = session.createQuery(sql);
268    
269                                    QueryPos qPos = QueryPos.getInstance(q);
270    
271                                    if (bindUuid) {
272                                            qPos.add(uuid);
273                                    }
274    
275                                    if (!pagination) {
276                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
277                                                            start, end, false);
278    
279                                            Collections.sort(list);
280    
281                                            list = Collections.unmodifiableList(list);
282                                    }
283                                    else {
284                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
285                                                            start, end);
286                                    }
287    
288                                    cacheResult(list);
289    
290                                    finderCache.putResult(finderPath, finderArgs, list);
291                            }
292                            catch (Exception e) {
293                                    finderCache.removeResult(finderPath, finderArgs);
294    
295                                    throw processException(e);
296                            }
297                            finally {
298                                    closeSession(session);
299                            }
300                    }
301    
302                    return list;
303            }
304    
305            /**
306             * Returns the first blogs entry in the ordered set where uuid = &#63;.
307             *
308             * @param uuid the uuid
309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
310             * @return the first matching blogs entry
311             * @throws NoSuchEntryException if a matching blogs entry could not be found
312             */
313            @Override
314            public BlogsEntry findByUuid_First(String uuid,
315                    OrderByComparator<BlogsEntry> orderByComparator)
316                    throws NoSuchEntryException {
317                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
318    
319                    if (blogsEntry != null) {
320                            return blogsEntry;
321                    }
322    
323                    StringBundler msg = new StringBundler(4);
324    
325                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
326    
327                    msg.append("uuid=");
328                    msg.append(uuid);
329    
330                    msg.append(StringPool.CLOSE_CURLY_BRACE);
331    
332                    throw new NoSuchEntryException(msg.toString());
333            }
334    
335            /**
336             * Returns the first blogs entry in the ordered set where uuid = &#63;.
337             *
338             * @param uuid the uuid
339             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
340             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
341             */
342            @Override
343            public BlogsEntry fetchByUuid_First(String uuid,
344                    OrderByComparator<BlogsEntry> orderByComparator) {
345                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
346    
347                    if (!list.isEmpty()) {
348                            return list.get(0);
349                    }
350    
351                    return null;
352            }
353    
354            /**
355             * Returns the last blogs entry in the ordered set where uuid = &#63;.
356             *
357             * @param uuid the uuid
358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
359             * @return the last matching blogs entry
360             * @throws NoSuchEntryException if a matching blogs entry could not be found
361             */
362            @Override
363            public BlogsEntry findByUuid_Last(String uuid,
364                    OrderByComparator<BlogsEntry> orderByComparator)
365                    throws NoSuchEntryException {
366                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
367    
368                    if (blogsEntry != null) {
369                            return blogsEntry;
370                    }
371    
372                    StringBundler msg = new StringBundler(4);
373    
374                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
375    
376                    msg.append("uuid=");
377                    msg.append(uuid);
378    
379                    msg.append(StringPool.CLOSE_CURLY_BRACE);
380    
381                    throw new NoSuchEntryException(msg.toString());
382            }
383    
384            /**
385             * Returns the last blogs entry in the ordered set where uuid = &#63;.
386             *
387             * @param uuid the uuid
388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
389             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
390             */
391            @Override
392            public BlogsEntry fetchByUuid_Last(String uuid,
393                    OrderByComparator<BlogsEntry> orderByComparator) {
394                    int count = countByUuid(uuid);
395    
396                    if (count == 0) {
397                            return null;
398                    }
399    
400                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
401                                    orderByComparator);
402    
403                    if (!list.isEmpty()) {
404                            return list.get(0);
405                    }
406    
407                    return null;
408            }
409    
410            /**
411             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
412             *
413             * @param entryId the primary key of the current blogs entry
414             * @param uuid the uuid
415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
416             * @return the previous, current, and next blogs entry
417             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
418             */
419            @Override
420            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
421                    OrderByComparator<BlogsEntry> orderByComparator)
422                    throws NoSuchEntryException {
423                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
424    
425                    Session session = null;
426    
427                    try {
428                            session = openSession();
429    
430                            BlogsEntry[] array = new BlogsEntryImpl[3];
431    
432                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
433                                            orderByComparator, true);
434    
435                            array[1] = blogsEntry;
436    
437                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
438                                            orderByComparator, false);
439    
440                            return array;
441                    }
442                    catch (Exception e) {
443                            throw processException(e);
444                    }
445                    finally {
446                            closeSession(session);
447                    }
448            }
449    
450            protected BlogsEntry getByUuid_PrevAndNext(Session session,
451                    BlogsEntry blogsEntry, String uuid,
452                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
453                    StringBundler query = null;
454    
455                    if (orderByComparator != null) {
456                            query = new StringBundler(6 +
457                                            (orderByComparator.getOrderByFields().length * 6));
458                    }
459                    else {
460                            query = new StringBundler(3);
461                    }
462    
463                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
464    
465                    boolean bindUuid = false;
466    
467                    if (uuid == null) {
468                            query.append(_FINDER_COLUMN_UUID_UUID_1);
469                    }
470                    else if (uuid.equals(StringPool.BLANK)) {
471                            query.append(_FINDER_COLUMN_UUID_UUID_3);
472                    }
473                    else {
474                            bindUuid = true;
475    
476                            query.append(_FINDER_COLUMN_UUID_UUID_2);
477                    }
478    
479                    if (orderByComparator != null) {
480                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
481    
482                            if (orderByConditionFields.length > 0) {
483                                    query.append(WHERE_AND);
484                            }
485    
486                            for (int i = 0; i < orderByConditionFields.length; i++) {
487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
488                                    query.append(orderByConditionFields[i]);
489    
490                                    if ((i + 1) < orderByConditionFields.length) {
491                                            if (orderByComparator.isAscending() ^ previous) {
492                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
493                                            }
494                                            else {
495                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
496                                            }
497                                    }
498                                    else {
499                                            if (orderByComparator.isAscending() ^ previous) {
500                                                    query.append(WHERE_GREATER_THAN);
501                                            }
502                                            else {
503                                                    query.append(WHERE_LESSER_THAN);
504                                            }
505                                    }
506                            }
507    
508                            query.append(ORDER_BY_CLAUSE);
509    
510                            String[] orderByFields = orderByComparator.getOrderByFields();
511    
512                            for (int i = 0; i < orderByFields.length; i++) {
513                                    query.append(_ORDER_BY_ENTITY_ALIAS);
514                                    query.append(orderByFields[i]);
515    
516                                    if ((i + 1) < orderByFields.length) {
517                                            if (orderByComparator.isAscending() ^ previous) {
518                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
519                                            }
520                                            else {
521                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
522                                            }
523                                    }
524                                    else {
525                                            if (orderByComparator.isAscending() ^ previous) {
526                                                    query.append(ORDER_BY_ASC);
527                                            }
528                                            else {
529                                                    query.append(ORDER_BY_DESC);
530                                            }
531                                    }
532                            }
533                    }
534                    else {
535                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
536                    }
537    
538                    String sql = query.toString();
539    
540                    Query q = session.createQuery(sql);
541    
542                    q.setFirstResult(0);
543                    q.setMaxResults(2);
544    
545                    QueryPos qPos = QueryPos.getInstance(q);
546    
547                    if (bindUuid) {
548                            qPos.add(uuid);
549                    }
550    
551                    if (orderByComparator != null) {
552                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
553    
554                            for (Object value : values) {
555                                    qPos.add(value);
556                            }
557                    }
558    
559                    List<BlogsEntry> list = q.list();
560    
561                    if (list.size() == 2) {
562                            return list.get(1);
563                    }
564                    else {
565                            return null;
566                    }
567            }
568    
569            /**
570             * Removes all the blogs entries where uuid = &#63; from the database.
571             *
572             * @param uuid the uuid
573             */
574            @Override
575            public void removeByUuid(String uuid) {
576                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
577                                    QueryUtil.ALL_POS, null)) {
578                            remove(blogsEntry);
579                    }
580            }
581    
582            /**
583             * Returns the number of blogs entries where uuid = &#63;.
584             *
585             * @param uuid the uuid
586             * @return the number of matching blogs entries
587             */
588            @Override
589            public int countByUuid(String uuid) {
590                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
591    
592                    Object[] finderArgs = new Object[] { uuid };
593    
594                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
595    
596                    if (count == null) {
597                            StringBundler query = new StringBundler(2);
598    
599                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
600    
601                            boolean bindUuid = false;
602    
603                            if (uuid == null) {
604                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
605                            }
606                            else if (uuid.equals(StringPool.BLANK)) {
607                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
608                            }
609                            else {
610                                    bindUuid = true;
611    
612                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
613                            }
614    
615                            String sql = query.toString();
616    
617                            Session session = null;
618    
619                            try {
620                                    session = openSession();
621    
622                                    Query q = session.createQuery(sql);
623    
624                                    QueryPos qPos = QueryPos.getInstance(q);
625    
626                                    if (bindUuid) {
627                                            qPos.add(uuid);
628                                    }
629    
630                                    count = (Long)q.uniqueResult();
631    
632                                    finderCache.putResult(finderPath, finderArgs, count);
633                            }
634                            catch (Exception e) {
635                                    finderCache.removeResult(finderPath, finderArgs);
636    
637                                    throw processException(e);
638                            }
639                            finally {
640                                    closeSession(session);
641                            }
642                    }
643    
644                    return count.intValue();
645            }
646    
647            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
648            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
649            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
650            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
651                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
652                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
653                            new String[] { String.class.getName(), Long.class.getName() },
654                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
655                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
656            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
657                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
658                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
659                            new String[] { String.class.getName(), Long.class.getName() });
660    
661            /**
662             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
663             *
664             * @param uuid the uuid
665             * @param groupId the group ID
666             * @return the matching blogs entry
667             * @throws NoSuchEntryException if a matching blogs entry could not be found
668             */
669            @Override
670            public BlogsEntry findByUUID_G(String uuid, long groupId)
671                    throws NoSuchEntryException {
672                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
673    
674                    if (blogsEntry == null) {
675                            StringBundler msg = new StringBundler(6);
676    
677                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
678    
679                            msg.append("uuid=");
680                            msg.append(uuid);
681    
682                            msg.append(", groupId=");
683                            msg.append(groupId);
684    
685                            msg.append(StringPool.CLOSE_CURLY_BRACE);
686    
687                            if (_log.isWarnEnabled()) {
688                                    _log.warn(msg.toString());
689                            }
690    
691                            throw new NoSuchEntryException(msg.toString());
692                    }
693    
694                    return blogsEntry;
695            }
696    
697            /**
698             * 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.
699             *
700             * @param uuid the uuid
701             * @param groupId the group ID
702             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
703             */
704            @Override
705            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
706                    return fetchByUUID_G(uuid, groupId, true);
707            }
708    
709            /**
710             * 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.
711             *
712             * @param uuid the uuid
713             * @param groupId the group ID
714             * @param retrieveFromCache whether to retrieve from the finder cache
715             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
716             */
717            @Override
718            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
719                    boolean retrieveFromCache) {
720                    Object[] finderArgs = new Object[] { uuid, groupId };
721    
722                    Object result = null;
723    
724                    if (retrieveFromCache) {
725                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
726                                            finderArgs, this);
727                    }
728    
729                    if (result instanceof BlogsEntry) {
730                            BlogsEntry blogsEntry = (BlogsEntry)result;
731    
732                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
733                                            (groupId != blogsEntry.getGroupId())) {
734                                    result = null;
735                            }
736                    }
737    
738                    if (result == null) {
739                            StringBundler query = new StringBundler(4);
740    
741                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
742    
743                            boolean bindUuid = false;
744    
745                            if (uuid == null) {
746                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
747                            }
748                            else if (uuid.equals(StringPool.BLANK)) {
749                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
750                            }
751                            else {
752                                    bindUuid = true;
753    
754                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
755                            }
756    
757                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
758    
759                            String sql = query.toString();
760    
761                            Session session = null;
762    
763                            try {
764                                    session = openSession();
765    
766                                    Query q = session.createQuery(sql);
767    
768                                    QueryPos qPos = QueryPos.getInstance(q);
769    
770                                    if (bindUuid) {
771                                            qPos.add(uuid);
772                                    }
773    
774                                    qPos.add(groupId);
775    
776                                    List<BlogsEntry> list = q.list();
777    
778                                    if (list.isEmpty()) {
779                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
780                                                    finderArgs, list);
781                                    }
782                                    else {
783                                            BlogsEntry blogsEntry = list.get(0);
784    
785                                            result = blogsEntry;
786    
787                                            cacheResult(blogsEntry);
788    
789                                            if ((blogsEntry.getUuid() == null) ||
790                                                            !blogsEntry.getUuid().equals(uuid) ||
791                                                            (blogsEntry.getGroupId() != groupId)) {
792                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
793                                                            finderArgs, blogsEntry);
794                                            }
795                                    }
796                            }
797                            catch (Exception e) {
798                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
799    
800                                    throw processException(e);
801                            }
802                            finally {
803                                    closeSession(session);
804                            }
805                    }
806    
807                    if (result instanceof List<?>) {
808                            return null;
809                    }
810                    else {
811                            return (BlogsEntry)result;
812                    }
813            }
814    
815            /**
816             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
817             *
818             * @param uuid the uuid
819             * @param groupId the group ID
820             * @return the blogs entry that was removed
821             */
822            @Override
823            public BlogsEntry removeByUUID_G(String uuid, long groupId)
824                    throws NoSuchEntryException {
825                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
826    
827                    return remove(blogsEntry);
828            }
829    
830            /**
831             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
832             *
833             * @param uuid the uuid
834             * @param groupId the group ID
835             * @return the number of matching blogs entries
836             */
837            @Override
838            public int countByUUID_G(String uuid, long groupId) {
839                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
840    
841                    Object[] finderArgs = new Object[] { uuid, groupId };
842    
843                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
844    
845                    if (count == null) {
846                            StringBundler query = new StringBundler(3);
847    
848                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
849    
850                            boolean bindUuid = false;
851    
852                            if (uuid == null) {
853                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
854                            }
855                            else if (uuid.equals(StringPool.BLANK)) {
856                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
857                            }
858                            else {
859                                    bindUuid = true;
860    
861                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
862                            }
863    
864                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
865    
866                            String sql = query.toString();
867    
868                            Session session = null;
869    
870                            try {
871                                    session = openSession();
872    
873                                    Query q = session.createQuery(sql);
874    
875                                    QueryPos qPos = QueryPos.getInstance(q);
876    
877                                    if (bindUuid) {
878                                            qPos.add(uuid);
879                                    }
880    
881                                    qPos.add(groupId);
882    
883                                    count = (Long)q.uniqueResult();
884    
885                                    finderCache.putResult(finderPath, finderArgs, count);
886                            }
887                            catch (Exception e) {
888                                    finderCache.removeResult(finderPath, finderArgs);
889    
890                                    throw processException(e);
891                            }
892                            finally {
893                                    closeSession(session);
894                            }
895                    }
896    
897                    return count.intValue();
898            }
899    
900            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
901            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
902            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
903            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
904            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
905                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
906                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
907                            new String[] {
908                                    String.class.getName(), Long.class.getName(),
909                                    
910                            Integer.class.getName(), Integer.class.getName(),
911                                    OrderByComparator.class.getName()
912                            });
913            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
914                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
915                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
916                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
917                            new String[] { String.class.getName(), Long.class.getName() },
918                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
919                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
920                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
921                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
922            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
923                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
924                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
925                            new String[] { String.class.getName(), Long.class.getName() });
926    
927            /**
928             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
929             *
930             * @param uuid the uuid
931             * @param companyId the company ID
932             * @return the matching blogs entries
933             */
934            @Override
935            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
936                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
937                            QueryUtil.ALL_POS, null);
938            }
939    
940            /**
941             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
942             *
943             * <p>
944             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
945             * </p>
946             *
947             * @param uuid the uuid
948             * @param companyId the company ID
949             * @param start the lower bound of the range of blogs entries
950             * @param end the upper bound of the range of blogs entries (not inclusive)
951             * @return the range of matching blogs entries
952             */
953            @Override
954            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
955                    int start, int end) {
956                    return findByUuid_C(uuid, companyId, start, end, null);
957            }
958    
959            /**
960             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
961             *
962             * <p>
963             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
964             * </p>
965             *
966             * @param uuid the uuid
967             * @param companyId the company ID
968             * @param start the lower bound of the range of blogs entries
969             * @param end the upper bound of the range of blogs entries (not inclusive)
970             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
971             * @return the ordered range of matching blogs entries
972             */
973            @Override
974            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
975                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
976                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
977            }
978    
979            /**
980             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
981             *
982             * <p>
983             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
984             * </p>
985             *
986             * @param uuid the uuid
987             * @param companyId the company ID
988             * @param start the lower bound of the range of blogs entries
989             * @param end the upper bound of the range of blogs entries (not inclusive)
990             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
991             * @param retrieveFromCache whether to retrieve from the finder cache
992             * @return the ordered range of matching blogs entries
993             */
994            @Override
995            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
996                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
997                    boolean retrieveFromCache) {
998                    boolean pagination = true;
999                    FinderPath finderPath = null;
1000                    Object[] finderArgs = null;
1001    
1002                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1003                                    (orderByComparator == null)) {
1004                            pagination = false;
1005                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1006                            finderArgs = new Object[] { uuid, companyId };
1007                    }
1008                    else {
1009                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1010                            finderArgs = new Object[] {
1011                                            uuid, companyId,
1012                                            
1013                                            start, end, orderByComparator
1014                                    };
1015                    }
1016    
1017                    List<BlogsEntry> list = null;
1018    
1019                    if (retrieveFromCache) {
1020                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1021                                            finderArgs, this);
1022    
1023                            if ((list != null) && !list.isEmpty()) {
1024                                    for (BlogsEntry blogsEntry : list) {
1025                                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1026                                                            (companyId != blogsEntry.getCompanyId())) {
1027                                                    list = null;
1028    
1029                                                    break;
1030                                            }
1031                                    }
1032                            }
1033                    }
1034    
1035                    if (list == null) {
1036                            StringBundler query = null;
1037    
1038                            if (orderByComparator != null) {
1039                                    query = new StringBundler(4 +
1040                                                    (orderByComparator.getOrderByFields().length * 3));
1041                            }
1042                            else {
1043                                    query = new StringBundler(4);
1044                            }
1045    
1046                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1047    
1048                            boolean bindUuid = false;
1049    
1050                            if (uuid == null) {
1051                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1052                            }
1053                            else if (uuid.equals(StringPool.BLANK)) {
1054                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1055                            }
1056                            else {
1057                                    bindUuid = true;
1058    
1059                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1060                            }
1061    
1062                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1063    
1064                            if (orderByComparator != null) {
1065                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1066                                            orderByComparator);
1067                            }
1068                            else
1069                             if (pagination) {
1070                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1071                            }
1072    
1073                            String sql = query.toString();
1074    
1075                            Session session = null;
1076    
1077                            try {
1078                                    session = openSession();
1079    
1080                                    Query q = session.createQuery(sql);
1081    
1082                                    QueryPos qPos = QueryPos.getInstance(q);
1083    
1084                                    if (bindUuid) {
1085                                            qPos.add(uuid);
1086                                    }
1087    
1088                                    qPos.add(companyId);
1089    
1090                                    if (!pagination) {
1091                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1092                                                            start, end, false);
1093    
1094                                            Collections.sort(list);
1095    
1096                                            list = Collections.unmodifiableList(list);
1097                                    }
1098                                    else {
1099                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1100                                                            start, end);
1101                                    }
1102    
1103                                    cacheResult(list);
1104    
1105                                    finderCache.putResult(finderPath, finderArgs, list);
1106                            }
1107                            catch (Exception e) {
1108                                    finderCache.removeResult(finderPath, finderArgs);
1109    
1110                                    throw processException(e);
1111                            }
1112                            finally {
1113                                    closeSession(session);
1114                            }
1115                    }
1116    
1117                    return list;
1118            }
1119    
1120            /**
1121             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1122             *
1123             * @param uuid the uuid
1124             * @param companyId the company ID
1125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1126             * @return the first matching blogs entry
1127             * @throws NoSuchEntryException if a matching blogs entry could not be found
1128             */
1129            @Override
1130            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1131                    OrderByComparator<BlogsEntry> orderByComparator)
1132                    throws NoSuchEntryException {
1133                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1134                                    orderByComparator);
1135    
1136                    if (blogsEntry != null) {
1137                            return blogsEntry;
1138                    }
1139    
1140                    StringBundler msg = new StringBundler(6);
1141    
1142                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1143    
1144                    msg.append("uuid=");
1145                    msg.append(uuid);
1146    
1147                    msg.append(", companyId=");
1148                    msg.append(companyId);
1149    
1150                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1151    
1152                    throw new NoSuchEntryException(msg.toString());
1153            }
1154    
1155            /**
1156             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1157             *
1158             * @param uuid the uuid
1159             * @param companyId the company ID
1160             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1161             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1162             */
1163            @Override
1164            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1165                    OrderByComparator<BlogsEntry> orderByComparator) {
1166                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1167                                    orderByComparator);
1168    
1169                    if (!list.isEmpty()) {
1170                            return list.get(0);
1171                    }
1172    
1173                    return null;
1174            }
1175    
1176            /**
1177             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1178             *
1179             * @param uuid the uuid
1180             * @param companyId the company ID
1181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1182             * @return the last matching blogs entry
1183             * @throws NoSuchEntryException if a matching blogs entry could not be found
1184             */
1185            @Override
1186            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1187                    OrderByComparator<BlogsEntry> orderByComparator)
1188                    throws NoSuchEntryException {
1189                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1190                                    orderByComparator);
1191    
1192                    if (blogsEntry != null) {
1193                            return blogsEntry;
1194                    }
1195    
1196                    StringBundler msg = new StringBundler(6);
1197    
1198                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1199    
1200                    msg.append("uuid=");
1201                    msg.append(uuid);
1202    
1203                    msg.append(", companyId=");
1204                    msg.append(companyId);
1205    
1206                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1207    
1208                    throw new NoSuchEntryException(msg.toString());
1209            }
1210    
1211            /**
1212             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1213             *
1214             * @param uuid the uuid
1215             * @param companyId the company ID
1216             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1217             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1218             */
1219            @Override
1220            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1221                    OrderByComparator<BlogsEntry> orderByComparator) {
1222                    int count = countByUuid_C(uuid, companyId);
1223    
1224                    if (count == 0) {
1225                            return null;
1226                    }
1227    
1228                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1229                                    orderByComparator);
1230    
1231                    if (!list.isEmpty()) {
1232                            return list.get(0);
1233                    }
1234    
1235                    return null;
1236            }
1237    
1238            /**
1239             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1240             *
1241             * @param entryId the primary key of the current blogs entry
1242             * @param uuid the uuid
1243             * @param companyId the company ID
1244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1245             * @return the previous, current, and next blogs entry
1246             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1247             */
1248            @Override
1249            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1250                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1251                    throws NoSuchEntryException {
1252                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1253    
1254                    Session session = null;
1255    
1256                    try {
1257                            session = openSession();
1258    
1259                            BlogsEntry[] array = new BlogsEntryImpl[3];
1260    
1261                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1262                                            companyId, orderByComparator, true);
1263    
1264                            array[1] = blogsEntry;
1265    
1266                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1267                                            companyId, orderByComparator, false);
1268    
1269                            return array;
1270                    }
1271                    catch (Exception e) {
1272                            throw processException(e);
1273                    }
1274                    finally {
1275                            closeSession(session);
1276                    }
1277            }
1278    
1279            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1280                    BlogsEntry blogsEntry, String uuid, long companyId,
1281                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1282                    StringBundler query = null;
1283    
1284                    if (orderByComparator != null) {
1285                            query = new StringBundler(6 +
1286                                            (orderByComparator.getOrderByFields().length * 6));
1287                    }
1288                    else {
1289                            query = new StringBundler(3);
1290                    }
1291    
1292                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1293    
1294                    boolean bindUuid = false;
1295    
1296                    if (uuid == null) {
1297                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1298                    }
1299                    else if (uuid.equals(StringPool.BLANK)) {
1300                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1301                    }
1302                    else {
1303                            bindUuid = true;
1304    
1305                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1306                    }
1307    
1308                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1309    
1310                    if (orderByComparator != null) {
1311                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1312    
1313                            if (orderByConditionFields.length > 0) {
1314                                    query.append(WHERE_AND);
1315                            }
1316    
1317                            for (int i = 0; i < orderByConditionFields.length; i++) {
1318                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1319                                    query.append(orderByConditionFields[i]);
1320    
1321                                    if ((i + 1) < orderByConditionFields.length) {
1322                                            if (orderByComparator.isAscending() ^ previous) {
1323                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1324                                            }
1325                                            else {
1326                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1327                                            }
1328                                    }
1329                                    else {
1330                                            if (orderByComparator.isAscending() ^ previous) {
1331                                                    query.append(WHERE_GREATER_THAN);
1332                                            }
1333                                            else {
1334                                                    query.append(WHERE_LESSER_THAN);
1335                                            }
1336                                    }
1337                            }
1338    
1339                            query.append(ORDER_BY_CLAUSE);
1340    
1341                            String[] orderByFields = orderByComparator.getOrderByFields();
1342    
1343                            for (int i = 0; i < orderByFields.length; i++) {
1344                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1345                                    query.append(orderByFields[i]);
1346    
1347                                    if ((i + 1) < orderByFields.length) {
1348                                            if (orderByComparator.isAscending() ^ previous) {
1349                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1350                                            }
1351                                            else {
1352                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1353                                            }
1354                                    }
1355                                    else {
1356                                            if (orderByComparator.isAscending() ^ previous) {
1357                                                    query.append(ORDER_BY_ASC);
1358                                            }
1359                                            else {
1360                                                    query.append(ORDER_BY_DESC);
1361                                            }
1362                                    }
1363                            }
1364                    }
1365                    else {
1366                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1367                    }
1368    
1369                    String sql = query.toString();
1370    
1371                    Query q = session.createQuery(sql);
1372    
1373                    q.setFirstResult(0);
1374                    q.setMaxResults(2);
1375    
1376                    QueryPos qPos = QueryPos.getInstance(q);
1377    
1378                    if (bindUuid) {
1379                            qPos.add(uuid);
1380                    }
1381    
1382                    qPos.add(companyId);
1383    
1384                    if (orderByComparator != null) {
1385                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1386    
1387                            for (Object value : values) {
1388                                    qPos.add(value);
1389                            }
1390                    }
1391    
1392                    List<BlogsEntry> list = q.list();
1393    
1394                    if (list.size() == 2) {
1395                            return list.get(1);
1396                    }
1397                    else {
1398                            return null;
1399                    }
1400            }
1401    
1402            /**
1403             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1404             *
1405             * @param uuid the uuid
1406             * @param companyId the company ID
1407             */
1408            @Override
1409            public void removeByUuid_C(String uuid, long companyId) {
1410                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1411                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1412                            remove(blogsEntry);
1413                    }
1414            }
1415    
1416            /**
1417             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1418             *
1419             * @param uuid the uuid
1420             * @param companyId the company ID
1421             * @return the number of matching blogs entries
1422             */
1423            @Override
1424            public int countByUuid_C(String uuid, long companyId) {
1425                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1426    
1427                    Object[] finderArgs = new Object[] { uuid, companyId };
1428    
1429                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1430    
1431                    if (count == null) {
1432                            StringBundler query = new StringBundler(3);
1433    
1434                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1435    
1436                            boolean bindUuid = false;
1437    
1438                            if (uuid == null) {
1439                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1440                            }
1441                            else if (uuid.equals(StringPool.BLANK)) {
1442                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1443                            }
1444                            else {
1445                                    bindUuid = true;
1446    
1447                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1448                            }
1449    
1450                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1451    
1452                            String sql = query.toString();
1453    
1454                            Session session = null;
1455    
1456                            try {
1457                                    session = openSession();
1458    
1459                                    Query q = session.createQuery(sql);
1460    
1461                                    QueryPos qPos = QueryPos.getInstance(q);
1462    
1463                                    if (bindUuid) {
1464                                            qPos.add(uuid);
1465                                    }
1466    
1467                                    qPos.add(companyId);
1468    
1469                                    count = (Long)q.uniqueResult();
1470    
1471                                    finderCache.putResult(finderPath, finderArgs, count);
1472                            }
1473                            catch (Exception e) {
1474                                    finderCache.removeResult(finderPath, finderArgs);
1475    
1476                                    throw processException(e);
1477                            }
1478                            finally {
1479                                    closeSession(session);
1480                            }
1481                    }
1482    
1483                    return count.intValue();
1484            }
1485    
1486            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1487            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1488            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1489            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1490            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1491                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1492                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1493                            new String[] {
1494                                    Long.class.getName(),
1495                                    
1496                            Integer.class.getName(), Integer.class.getName(),
1497                                    OrderByComparator.class.getName()
1498                            });
1499            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1500                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1501                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1502                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1503                            new String[] { Long.class.getName() },
1504                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1505                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1506                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1507            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1508                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1509                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1510                            new String[] { Long.class.getName() });
1511    
1512            /**
1513             * Returns all the blogs entries where groupId = &#63;.
1514             *
1515             * @param groupId the group ID
1516             * @return the matching blogs entries
1517             */
1518            @Override
1519            public List<BlogsEntry> findByGroupId(long groupId) {
1520                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1521            }
1522    
1523            /**
1524             * Returns a range of all the blogs entries where groupId = &#63;.
1525             *
1526             * <p>
1527             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1528             * </p>
1529             *
1530             * @param groupId the group ID
1531             * @param start the lower bound of the range of blogs entries
1532             * @param end the upper bound of the range of blogs entries (not inclusive)
1533             * @return the range of matching blogs entries
1534             */
1535            @Override
1536            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1537                    return findByGroupId(groupId, start, end, null);
1538            }
1539    
1540            /**
1541             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1542             *
1543             * <p>
1544             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1545             * </p>
1546             *
1547             * @param groupId the group ID
1548             * @param start the lower bound of the range of blogs entries
1549             * @param end the upper bound of the range of blogs entries (not inclusive)
1550             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1551             * @return the ordered range of matching blogs entries
1552             */
1553            @Override
1554            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1555                    OrderByComparator<BlogsEntry> orderByComparator) {
1556                    return findByGroupId(groupId, start, end, orderByComparator, true);
1557            }
1558    
1559            /**
1560             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1561             *
1562             * <p>
1563             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1564             * </p>
1565             *
1566             * @param groupId the group ID
1567             * @param start the lower bound of the range of blogs entries
1568             * @param end the upper bound of the range of blogs entries (not inclusive)
1569             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1570             * @param retrieveFromCache whether to retrieve from the finder cache
1571             * @return the ordered range of matching blogs entries
1572             */
1573            @Override
1574            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1575                    OrderByComparator<BlogsEntry> orderByComparator,
1576                    boolean retrieveFromCache) {
1577                    boolean pagination = true;
1578                    FinderPath finderPath = null;
1579                    Object[] finderArgs = null;
1580    
1581                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1582                                    (orderByComparator == null)) {
1583                            pagination = false;
1584                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1585                            finderArgs = new Object[] { groupId };
1586                    }
1587                    else {
1588                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1589                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1590                    }
1591    
1592                    List<BlogsEntry> list = null;
1593    
1594                    if (retrieveFromCache) {
1595                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1596                                            finderArgs, this);
1597    
1598                            if ((list != null) && !list.isEmpty()) {
1599                                    for (BlogsEntry blogsEntry : list) {
1600                                            if ((groupId != blogsEntry.getGroupId())) {
1601                                                    list = null;
1602    
1603                                                    break;
1604                                            }
1605                                    }
1606                            }
1607                    }
1608    
1609                    if (list == null) {
1610                            StringBundler query = null;
1611    
1612                            if (orderByComparator != null) {
1613                                    query = new StringBundler(3 +
1614                                                    (orderByComparator.getOrderByFields().length * 3));
1615                            }
1616                            else {
1617                                    query = new StringBundler(3);
1618                            }
1619    
1620                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1621    
1622                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1623    
1624                            if (orderByComparator != null) {
1625                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1626                                            orderByComparator);
1627                            }
1628                            else
1629                             if (pagination) {
1630                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1631                            }
1632    
1633                            String sql = query.toString();
1634    
1635                            Session session = null;
1636    
1637                            try {
1638                                    session = openSession();
1639    
1640                                    Query q = session.createQuery(sql);
1641    
1642                                    QueryPos qPos = QueryPos.getInstance(q);
1643    
1644                                    qPos.add(groupId);
1645    
1646                                    if (!pagination) {
1647                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1648                                                            start, end, false);
1649    
1650                                            Collections.sort(list);
1651    
1652                                            list = Collections.unmodifiableList(list);
1653                                    }
1654                                    else {
1655                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1656                                                            start, end);
1657                                    }
1658    
1659                                    cacheResult(list);
1660    
1661                                    finderCache.putResult(finderPath, finderArgs, list);
1662                            }
1663                            catch (Exception e) {
1664                                    finderCache.removeResult(finderPath, finderArgs);
1665    
1666                                    throw processException(e);
1667                            }
1668                            finally {
1669                                    closeSession(session);
1670                            }
1671                    }
1672    
1673                    return list;
1674            }
1675    
1676            /**
1677             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1678             *
1679             * @param groupId the group ID
1680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1681             * @return the first matching blogs entry
1682             * @throws NoSuchEntryException if a matching blogs entry could not be found
1683             */
1684            @Override
1685            public BlogsEntry findByGroupId_First(long groupId,
1686                    OrderByComparator<BlogsEntry> orderByComparator)
1687                    throws NoSuchEntryException {
1688                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1689    
1690                    if (blogsEntry != null) {
1691                            return blogsEntry;
1692                    }
1693    
1694                    StringBundler msg = new StringBundler(4);
1695    
1696                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1697    
1698                    msg.append("groupId=");
1699                    msg.append(groupId);
1700    
1701                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1702    
1703                    throw new NoSuchEntryException(msg.toString());
1704            }
1705    
1706            /**
1707             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1708             *
1709             * @param groupId the group ID
1710             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1711             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1712             */
1713            @Override
1714            public BlogsEntry fetchByGroupId_First(long groupId,
1715                    OrderByComparator<BlogsEntry> orderByComparator) {
1716                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1717    
1718                    if (!list.isEmpty()) {
1719                            return list.get(0);
1720                    }
1721    
1722                    return null;
1723            }
1724    
1725            /**
1726             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1727             *
1728             * @param groupId the group ID
1729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1730             * @return the last matching blogs entry
1731             * @throws NoSuchEntryException if a matching blogs entry could not be found
1732             */
1733            @Override
1734            public BlogsEntry findByGroupId_Last(long groupId,
1735                    OrderByComparator<BlogsEntry> orderByComparator)
1736                    throws NoSuchEntryException {
1737                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1738    
1739                    if (blogsEntry != null) {
1740                            return blogsEntry;
1741                    }
1742    
1743                    StringBundler msg = new StringBundler(4);
1744    
1745                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1746    
1747                    msg.append("groupId=");
1748                    msg.append(groupId);
1749    
1750                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1751    
1752                    throw new NoSuchEntryException(msg.toString());
1753            }
1754    
1755            /**
1756             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1757             *
1758             * @param groupId the group ID
1759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1760             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1761             */
1762            @Override
1763            public BlogsEntry fetchByGroupId_Last(long groupId,
1764                    OrderByComparator<BlogsEntry> orderByComparator) {
1765                    int count = countByGroupId(groupId);
1766    
1767                    if (count == 0) {
1768                            return null;
1769                    }
1770    
1771                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1772                                    orderByComparator);
1773    
1774                    if (!list.isEmpty()) {
1775                            return list.get(0);
1776                    }
1777    
1778                    return null;
1779            }
1780    
1781            /**
1782             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1783             *
1784             * @param entryId the primary key of the current blogs entry
1785             * @param groupId the group ID
1786             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1787             * @return the previous, current, and next blogs entry
1788             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1789             */
1790            @Override
1791            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1792                    OrderByComparator<BlogsEntry> orderByComparator)
1793                    throws NoSuchEntryException {
1794                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1795    
1796                    Session session = null;
1797    
1798                    try {
1799                            session = openSession();
1800    
1801                            BlogsEntry[] array = new BlogsEntryImpl[3];
1802    
1803                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1804                                            orderByComparator, true);
1805    
1806                            array[1] = blogsEntry;
1807    
1808                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1809                                            orderByComparator, false);
1810    
1811                            return array;
1812                    }
1813                    catch (Exception e) {
1814                            throw processException(e);
1815                    }
1816                    finally {
1817                            closeSession(session);
1818                    }
1819            }
1820    
1821            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1822                    BlogsEntry blogsEntry, long groupId,
1823                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1824                    StringBundler query = null;
1825    
1826                    if (orderByComparator != null) {
1827                            query = new StringBundler(6 +
1828                                            (orderByComparator.getOrderByFields().length * 6));
1829                    }
1830                    else {
1831                            query = new StringBundler(3);
1832                    }
1833    
1834                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1835    
1836                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1837    
1838                    if (orderByComparator != null) {
1839                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1840    
1841                            if (orderByConditionFields.length > 0) {
1842                                    query.append(WHERE_AND);
1843                            }
1844    
1845                            for (int i = 0; i < orderByConditionFields.length; i++) {
1846                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1847                                    query.append(orderByConditionFields[i]);
1848    
1849                                    if ((i + 1) < orderByConditionFields.length) {
1850                                            if (orderByComparator.isAscending() ^ previous) {
1851                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1852                                            }
1853                                            else {
1854                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1855                                            }
1856                                    }
1857                                    else {
1858                                            if (orderByComparator.isAscending() ^ previous) {
1859                                                    query.append(WHERE_GREATER_THAN);
1860                                            }
1861                                            else {
1862                                                    query.append(WHERE_LESSER_THAN);
1863                                            }
1864                                    }
1865                            }
1866    
1867                            query.append(ORDER_BY_CLAUSE);
1868    
1869                            String[] orderByFields = orderByComparator.getOrderByFields();
1870    
1871                            for (int i = 0; i < orderByFields.length; i++) {
1872                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1873                                    query.append(orderByFields[i]);
1874    
1875                                    if ((i + 1) < orderByFields.length) {
1876                                            if (orderByComparator.isAscending() ^ previous) {
1877                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1878                                            }
1879                                            else {
1880                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1881                                            }
1882                                    }
1883                                    else {
1884                                            if (orderByComparator.isAscending() ^ previous) {
1885                                                    query.append(ORDER_BY_ASC);
1886                                            }
1887                                            else {
1888                                                    query.append(ORDER_BY_DESC);
1889                                            }
1890                                    }
1891                            }
1892                    }
1893                    else {
1894                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1895                    }
1896    
1897                    String sql = query.toString();
1898    
1899                    Query q = session.createQuery(sql);
1900    
1901                    q.setFirstResult(0);
1902                    q.setMaxResults(2);
1903    
1904                    QueryPos qPos = QueryPos.getInstance(q);
1905    
1906                    qPos.add(groupId);
1907    
1908                    if (orderByComparator != null) {
1909                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1910    
1911                            for (Object value : values) {
1912                                    qPos.add(value);
1913                            }
1914                    }
1915    
1916                    List<BlogsEntry> list = q.list();
1917    
1918                    if (list.size() == 2) {
1919                            return list.get(1);
1920                    }
1921                    else {
1922                            return null;
1923                    }
1924            }
1925    
1926            /**
1927             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1928             *
1929             * @param groupId the group ID
1930             * @return the matching blogs entries that the user has permission to view
1931             */
1932            @Override
1933            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1934                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1935                            QueryUtil.ALL_POS, null);
1936            }
1937    
1938            /**
1939             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1940             *
1941             * <p>
1942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1943             * </p>
1944             *
1945             * @param groupId the group ID
1946             * @param start the lower bound of the range of blogs entries
1947             * @param end the upper bound of the range of blogs entries (not inclusive)
1948             * @return the range of matching blogs entries that the user has permission to view
1949             */
1950            @Override
1951            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1952                    return filterFindByGroupId(groupId, start, end, null);
1953            }
1954    
1955            /**
1956             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1957             *
1958             * <p>
1959             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1960             * </p>
1961             *
1962             * @param groupId the group ID
1963             * @param start the lower bound of the range of blogs entries
1964             * @param end the upper bound of the range of blogs entries (not inclusive)
1965             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1966             * @return the ordered range of matching blogs entries that the user has permission to view
1967             */
1968            @Override
1969            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1970                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1971                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1972                            return findByGroupId(groupId, start, end, orderByComparator);
1973                    }
1974    
1975                    StringBundler query = null;
1976    
1977                    if (orderByComparator != null) {
1978                            query = new StringBundler(3 +
1979                                            (orderByComparator.getOrderByFields().length * 3));
1980                    }
1981                    else {
1982                            query = new StringBundler(3);
1983                    }
1984    
1985                    if (getDB().isSupportsInlineDistinct()) {
1986                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1987                    }
1988                    else {
1989                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1990                    }
1991    
1992                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1993    
1994                    if (!getDB().isSupportsInlineDistinct()) {
1995                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1996                    }
1997    
1998                    if (orderByComparator != null) {
1999                            if (getDB().isSupportsInlineDistinct()) {
2000                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2001                                            orderByComparator, true);
2002                            }
2003                            else {
2004                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2005                                            orderByComparator, true);
2006                            }
2007                    }
2008                    else {
2009                            if (getDB().isSupportsInlineDistinct()) {
2010                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2011                            }
2012                            else {
2013                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2014                            }
2015                    }
2016    
2017                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2018                                    BlogsEntry.class.getName(),
2019                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2020    
2021                    Session session = null;
2022    
2023                    try {
2024                            session = openSession();
2025    
2026                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2027    
2028                            if (getDB().isSupportsInlineDistinct()) {
2029                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2030                            }
2031                            else {
2032                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2033                            }
2034    
2035                            QueryPos qPos = QueryPos.getInstance(q);
2036    
2037                            qPos.add(groupId);
2038    
2039                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2040                    }
2041                    catch (Exception e) {
2042                            throw processException(e);
2043                    }
2044                    finally {
2045                            closeSession(session);
2046                    }
2047            }
2048    
2049            /**
2050             * 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;.
2051             *
2052             * @param entryId the primary key of the current blogs entry
2053             * @param groupId the group ID
2054             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2055             * @return the previous, current, and next blogs entry
2056             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2057             */
2058            @Override
2059            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2060                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
2061                    throws NoSuchEntryException {
2062                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2063                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2064                    }
2065    
2066                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2067    
2068                    Session session = null;
2069    
2070                    try {
2071                            session = openSession();
2072    
2073                            BlogsEntry[] array = new BlogsEntryImpl[3];
2074    
2075                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2076                                            groupId, orderByComparator, true);
2077    
2078                            array[1] = blogsEntry;
2079    
2080                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2081                                            groupId, orderByComparator, false);
2082    
2083                            return array;
2084                    }
2085                    catch (Exception e) {
2086                            throw processException(e);
2087                    }
2088                    finally {
2089                            closeSession(session);
2090                    }
2091            }
2092    
2093            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2094                    BlogsEntry blogsEntry, long groupId,
2095                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2096                    StringBundler query = null;
2097    
2098                    if (orderByComparator != null) {
2099                            query = new StringBundler(6 +
2100                                            (orderByComparator.getOrderByFields().length * 6));
2101                    }
2102                    else {
2103                            query = new StringBundler(3);
2104                    }
2105    
2106                    if (getDB().isSupportsInlineDistinct()) {
2107                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2108                    }
2109                    else {
2110                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2111                    }
2112    
2113                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2114    
2115                    if (!getDB().isSupportsInlineDistinct()) {
2116                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2117                    }
2118    
2119                    if (orderByComparator != null) {
2120                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2121    
2122                            if (orderByConditionFields.length > 0) {
2123                                    query.append(WHERE_AND);
2124                            }
2125    
2126                            for (int i = 0; i < orderByConditionFields.length; i++) {
2127                                    if (getDB().isSupportsInlineDistinct()) {
2128                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2129                                    }
2130                                    else {
2131                                            query.append(_ORDER_BY_ENTITY_TABLE);
2132                                    }
2133    
2134                                    query.append(orderByConditionFields[i]);
2135    
2136                                    if ((i + 1) < orderByConditionFields.length) {
2137                                            if (orderByComparator.isAscending() ^ previous) {
2138                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2139                                            }
2140                                            else {
2141                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2142                                            }
2143                                    }
2144                                    else {
2145                                            if (orderByComparator.isAscending() ^ previous) {
2146                                                    query.append(WHERE_GREATER_THAN);
2147                                            }
2148                                            else {
2149                                                    query.append(WHERE_LESSER_THAN);
2150                                            }
2151                                    }
2152                            }
2153    
2154                            query.append(ORDER_BY_CLAUSE);
2155    
2156                            String[] orderByFields = orderByComparator.getOrderByFields();
2157    
2158                            for (int i = 0; i < orderByFields.length; i++) {
2159                                    if (getDB().isSupportsInlineDistinct()) {
2160                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2161                                    }
2162                                    else {
2163                                            query.append(_ORDER_BY_ENTITY_TABLE);
2164                                    }
2165    
2166                                    query.append(orderByFields[i]);
2167    
2168                                    if ((i + 1) < orderByFields.length) {
2169                                            if (orderByComparator.isAscending() ^ previous) {
2170                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2171                                            }
2172                                            else {
2173                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2174                                            }
2175                                    }
2176                                    else {
2177                                            if (orderByComparator.isAscending() ^ previous) {
2178                                                    query.append(ORDER_BY_ASC);
2179                                            }
2180                                            else {
2181                                                    query.append(ORDER_BY_DESC);
2182                                            }
2183                                    }
2184                            }
2185                    }
2186                    else {
2187                            if (getDB().isSupportsInlineDistinct()) {
2188                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2189                            }
2190                            else {
2191                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2192                            }
2193                    }
2194    
2195                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2196                                    BlogsEntry.class.getName(),
2197                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2198    
2199                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2200    
2201                    q.setFirstResult(0);
2202                    q.setMaxResults(2);
2203    
2204                    if (getDB().isSupportsInlineDistinct()) {
2205                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2206                    }
2207                    else {
2208                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2209                    }
2210    
2211                    QueryPos qPos = QueryPos.getInstance(q);
2212    
2213                    qPos.add(groupId);
2214    
2215                    if (orderByComparator != null) {
2216                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2217    
2218                            for (Object value : values) {
2219                                    qPos.add(value);
2220                            }
2221                    }
2222    
2223                    List<BlogsEntry> list = q.list();
2224    
2225                    if (list.size() == 2) {
2226                            return list.get(1);
2227                    }
2228                    else {
2229                            return null;
2230                    }
2231            }
2232    
2233            /**
2234             * Removes all the blogs entries where groupId = &#63; from the database.
2235             *
2236             * @param groupId the group ID
2237             */
2238            @Override
2239            public void removeByGroupId(long groupId) {
2240                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2241                                    QueryUtil.ALL_POS, null)) {
2242                            remove(blogsEntry);
2243                    }
2244            }
2245    
2246            /**
2247             * Returns the number of blogs entries where groupId = &#63;.
2248             *
2249             * @param groupId the group ID
2250             * @return the number of matching blogs entries
2251             */
2252            @Override
2253            public int countByGroupId(long groupId) {
2254                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2255    
2256                    Object[] finderArgs = new Object[] { groupId };
2257    
2258                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2259    
2260                    if (count == null) {
2261                            StringBundler query = new StringBundler(2);
2262    
2263                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2264    
2265                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2266    
2267                            String sql = query.toString();
2268    
2269                            Session session = null;
2270    
2271                            try {
2272                                    session = openSession();
2273    
2274                                    Query q = session.createQuery(sql);
2275    
2276                                    QueryPos qPos = QueryPos.getInstance(q);
2277    
2278                                    qPos.add(groupId);
2279    
2280                                    count = (Long)q.uniqueResult();
2281    
2282                                    finderCache.putResult(finderPath, finderArgs, count);
2283                            }
2284                            catch (Exception e) {
2285                                    finderCache.removeResult(finderPath, finderArgs);
2286    
2287                                    throw processException(e);
2288                            }
2289                            finally {
2290                                    closeSession(session);
2291                            }
2292                    }
2293    
2294                    return count.intValue();
2295            }
2296    
2297            /**
2298             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2299             *
2300             * @param groupId the group ID
2301             * @return the number of matching blogs entries that the user has permission to view
2302             */
2303            @Override
2304            public int filterCountByGroupId(long groupId) {
2305                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2306                            return countByGroupId(groupId);
2307                    }
2308    
2309                    StringBundler query = new StringBundler(2);
2310    
2311                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2312    
2313                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2314    
2315                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2316                                    BlogsEntry.class.getName(),
2317                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2318    
2319                    Session session = null;
2320    
2321                    try {
2322                            session = openSession();
2323    
2324                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2325    
2326                            q.addScalar(COUNT_COLUMN_NAME,
2327                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2328    
2329                            QueryPos qPos = QueryPos.getInstance(q);
2330    
2331                            qPos.add(groupId);
2332    
2333                            Long count = (Long)q.uniqueResult();
2334    
2335                            return count.intValue();
2336                    }
2337                    catch (Exception e) {
2338                            throw processException(e);
2339                    }
2340                    finally {
2341                            closeSession(session);
2342                    }
2343            }
2344    
2345            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2346            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2347                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2348                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2349                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2350                            new String[] {
2351                                    Long.class.getName(),
2352                                    
2353                            Integer.class.getName(), Integer.class.getName(),
2354                                    OrderByComparator.class.getName()
2355                            });
2356            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2357                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2358                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2359                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2360                            new String[] { Long.class.getName() },
2361                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2362                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2363                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2364            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2365                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2366                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2367                            new String[] { Long.class.getName() });
2368    
2369            /**
2370             * Returns all the blogs entries where companyId = &#63;.
2371             *
2372             * @param companyId the company ID
2373             * @return the matching blogs entries
2374             */
2375            @Override
2376            public List<BlogsEntry> findByCompanyId(long companyId) {
2377                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2378                            null);
2379            }
2380    
2381            /**
2382             * Returns a range of all the blogs entries where companyId = &#63;.
2383             *
2384             * <p>
2385             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2386             * </p>
2387             *
2388             * @param companyId the company ID
2389             * @param start the lower bound of the range of blogs entries
2390             * @param end the upper bound of the range of blogs entries (not inclusive)
2391             * @return the range of matching blogs entries
2392             */
2393            @Override
2394            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2395                    return findByCompanyId(companyId, start, end, null);
2396            }
2397    
2398            /**
2399             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2400             *
2401             * <p>
2402             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2403             * </p>
2404             *
2405             * @param companyId the company ID
2406             * @param start the lower bound of the range of blogs entries
2407             * @param end the upper bound of the range of blogs entries (not inclusive)
2408             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2409             * @return the ordered range of matching blogs entries
2410             */
2411            @Override
2412            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2413                    OrderByComparator<BlogsEntry> orderByComparator) {
2414                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2415            }
2416    
2417            /**
2418             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2419             *
2420             * <p>
2421             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2422             * </p>
2423             *
2424             * @param companyId the company ID
2425             * @param start the lower bound of the range of blogs entries
2426             * @param end the upper bound of the range of blogs entries (not inclusive)
2427             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2428             * @param retrieveFromCache whether to retrieve from the finder cache
2429             * @return the ordered range of matching blogs entries
2430             */
2431            @Override
2432            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2433                    OrderByComparator<BlogsEntry> orderByComparator,
2434                    boolean retrieveFromCache) {
2435                    boolean pagination = true;
2436                    FinderPath finderPath = null;
2437                    Object[] finderArgs = null;
2438    
2439                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2440                                    (orderByComparator == null)) {
2441                            pagination = false;
2442                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2443                            finderArgs = new Object[] { companyId };
2444                    }
2445                    else {
2446                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2447                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2448                    }
2449    
2450                    List<BlogsEntry> list = null;
2451    
2452                    if (retrieveFromCache) {
2453                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
2454                                            finderArgs, this);
2455    
2456                            if ((list != null) && !list.isEmpty()) {
2457                                    for (BlogsEntry blogsEntry : list) {
2458                                            if ((companyId != blogsEntry.getCompanyId())) {
2459                                                    list = null;
2460    
2461                                                    break;
2462                                            }
2463                                    }
2464                            }
2465                    }
2466    
2467                    if (list == null) {
2468                            StringBundler query = null;
2469    
2470                            if (orderByComparator != null) {
2471                                    query = new StringBundler(3 +
2472                                                    (orderByComparator.getOrderByFields().length * 3));
2473                            }
2474                            else {
2475                                    query = new StringBundler(3);
2476                            }
2477    
2478                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2479    
2480                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2481    
2482                            if (orderByComparator != null) {
2483                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2484                                            orderByComparator);
2485                            }
2486                            else
2487                             if (pagination) {
2488                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2489                            }
2490    
2491                            String sql = query.toString();
2492    
2493                            Session session = null;
2494    
2495                            try {
2496                                    session = openSession();
2497    
2498                                    Query q = session.createQuery(sql);
2499    
2500                                    QueryPos qPos = QueryPos.getInstance(q);
2501    
2502                                    qPos.add(companyId);
2503    
2504                                    if (!pagination) {
2505                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2506                                                            start, end, false);
2507    
2508                                            Collections.sort(list);
2509    
2510                                            list = Collections.unmodifiableList(list);
2511                                    }
2512                                    else {
2513                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2514                                                            start, end);
2515                                    }
2516    
2517                                    cacheResult(list);
2518    
2519                                    finderCache.putResult(finderPath, finderArgs, list);
2520                            }
2521                            catch (Exception e) {
2522                                    finderCache.removeResult(finderPath, finderArgs);
2523    
2524                                    throw processException(e);
2525                            }
2526                            finally {
2527                                    closeSession(session);
2528                            }
2529                    }
2530    
2531                    return list;
2532            }
2533    
2534            /**
2535             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2536             *
2537             * @param companyId the company ID
2538             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2539             * @return the first matching blogs entry
2540             * @throws NoSuchEntryException if a matching blogs entry could not be found
2541             */
2542            @Override
2543            public BlogsEntry findByCompanyId_First(long companyId,
2544                    OrderByComparator<BlogsEntry> orderByComparator)
2545                    throws NoSuchEntryException {
2546                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2547                                    orderByComparator);
2548    
2549                    if (blogsEntry != null) {
2550                            return blogsEntry;
2551                    }
2552    
2553                    StringBundler msg = new StringBundler(4);
2554    
2555                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2556    
2557                    msg.append("companyId=");
2558                    msg.append(companyId);
2559    
2560                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2561    
2562                    throw new NoSuchEntryException(msg.toString());
2563            }
2564    
2565            /**
2566             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2567             *
2568             * @param companyId the company ID
2569             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2570             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2571             */
2572            @Override
2573            public BlogsEntry fetchByCompanyId_First(long companyId,
2574                    OrderByComparator<BlogsEntry> orderByComparator) {
2575                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2576                                    orderByComparator);
2577    
2578                    if (!list.isEmpty()) {
2579                            return list.get(0);
2580                    }
2581    
2582                    return null;
2583            }
2584    
2585            /**
2586             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2587             *
2588             * @param companyId the company ID
2589             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2590             * @return the last matching blogs entry
2591             * @throws NoSuchEntryException if a matching blogs entry could not be found
2592             */
2593            @Override
2594            public BlogsEntry findByCompanyId_Last(long companyId,
2595                    OrderByComparator<BlogsEntry> orderByComparator)
2596                    throws NoSuchEntryException {
2597                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2598                                    orderByComparator);
2599    
2600                    if (blogsEntry != null) {
2601                            return blogsEntry;
2602                    }
2603    
2604                    StringBundler msg = new StringBundler(4);
2605    
2606                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2607    
2608                    msg.append("companyId=");
2609                    msg.append(companyId);
2610    
2611                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2612    
2613                    throw new NoSuchEntryException(msg.toString());
2614            }
2615    
2616            /**
2617             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2618             *
2619             * @param companyId the company ID
2620             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2621             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2622             */
2623            @Override
2624            public BlogsEntry fetchByCompanyId_Last(long companyId,
2625                    OrderByComparator<BlogsEntry> orderByComparator) {
2626                    int count = countByCompanyId(companyId);
2627    
2628                    if (count == 0) {
2629                            return null;
2630                    }
2631    
2632                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2633                                    orderByComparator);
2634    
2635                    if (!list.isEmpty()) {
2636                            return list.get(0);
2637                    }
2638    
2639                    return null;
2640            }
2641    
2642            /**
2643             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2644             *
2645             * @param entryId the primary key of the current blogs entry
2646             * @param companyId the company ID
2647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2648             * @return the previous, current, and next blogs entry
2649             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2650             */
2651            @Override
2652            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2653                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2654                    throws NoSuchEntryException {
2655                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2656    
2657                    Session session = null;
2658    
2659                    try {
2660                            session = openSession();
2661    
2662                            BlogsEntry[] array = new BlogsEntryImpl[3];
2663    
2664                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2665                                            companyId, orderByComparator, true);
2666    
2667                            array[1] = blogsEntry;
2668    
2669                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2670                                            companyId, orderByComparator, false);
2671    
2672                            return array;
2673                    }
2674                    catch (Exception e) {
2675                            throw processException(e);
2676                    }
2677                    finally {
2678                            closeSession(session);
2679                    }
2680            }
2681    
2682            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2683                    BlogsEntry blogsEntry, long companyId,
2684                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2685                    StringBundler query = null;
2686    
2687                    if (orderByComparator != null) {
2688                            query = new StringBundler(6 +
2689                                            (orderByComparator.getOrderByFields().length * 6));
2690                    }
2691                    else {
2692                            query = new StringBundler(3);
2693                    }
2694    
2695                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2696    
2697                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2698    
2699                    if (orderByComparator != null) {
2700                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2701    
2702                            if (orderByConditionFields.length > 0) {
2703                                    query.append(WHERE_AND);
2704                            }
2705    
2706                            for (int i = 0; i < orderByConditionFields.length; i++) {
2707                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2708                                    query.append(orderByConditionFields[i]);
2709    
2710                                    if ((i + 1) < orderByConditionFields.length) {
2711                                            if (orderByComparator.isAscending() ^ previous) {
2712                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2713                                            }
2714                                            else {
2715                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2716                                            }
2717                                    }
2718                                    else {
2719                                            if (orderByComparator.isAscending() ^ previous) {
2720                                                    query.append(WHERE_GREATER_THAN);
2721                                            }
2722                                            else {
2723                                                    query.append(WHERE_LESSER_THAN);
2724                                            }
2725                                    }
2726                            }
2727    
2728                            query.append(ORDER_BY_CLAUSE);
2729    
2730                            String[] orderByFields = orderByComparator.getOrderByFields();
2731    
2732                            for (int i = 0; i < orderByFields.length; i++) {
2733                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2734                                    query.append(orderByFields[i]);
2735    
2736                                    if ((i + 1) < orderByFields.length) {
2737                                            if (orderByComparator.isAscending() ^ previous) {
2738                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2739                                            }
2740                                            else {
2741                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2742                                            }
2743                                    }
2744                                    else {
2745                                            if (orderByComparator.isAscending() ^ previous) {
2746                                                    query.append(ORDER_BY_ASC);
2747                                            }
2748                                            else {
2749                                                    query.append(ORDER_BY_DESC);
2750                                            }
2751                                    }
2752                            }
2753                    }
2754                    else {
2755                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2756                    }
2757    
2758                    String sql = query.toString();
2759    
2760                    Query q = session.createQuery(sql);
2761    
2762                    q.setFirstResult(0);
2763                    q.setMaxResults(2);
2764    
2765                    QueryPos qPos = QueryPos.getInstance(q);
2766    
2767                    qPos.add(companyId);
2768    
2769                    if (orderByComparator != null) {
2770                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2771    
2772                            for (Object value : values) {
2773                                    qPos.add(value);
2774                            }
2775                    }
2776    
2777                    List<BlogsEntry> list = q.list();
2778    
2779                    if (list.size() == 2) {
2780                            return list.get(1);
2781                    }
2782                    else {
2783                            return null;
2784                    }
2785            }
2786    
2787            /**
2788             * Removes all the blogs entries where companyId = &#63; from the database.
2789             *
2790             * @param companyId the company ID
2791             */
2792            @Override
2793            public void removeByCompanyId(long companyId) {
2794                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2795                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2796                            remove(blogsEntry);
2797                    }
2798            }
2799    
2800            /**
2801             * Returns the number of blogs entries where companyId = &#63;.
2802             *
2803             * @param companyId the company ID
2804             * @return the number of matching blogs entries
2805             */
2806            @Override
2807            public int countByCompanyId(long companyId) {
2808                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2809    
2810                    Object[] finderArgs = new Object[] { companyId };
2811    
2812                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2813    
2814                    if (count == null) {
2815                            StringBundler query = new StringBundler(2);
2816    
2817                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2818    
2819                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2820    
2821                            String sql = query.toString();
2822    
2823                            Session session = null;
2824    
2825                            try {
2826                                    session = openSession();
2827    
2828                                    Query q = session.createQuery(sql);
2829    
2830                                    QueryPos qPos = QueryPos.getInstance(q);
2831    
2832                                    qPos.add(companyId);
2833    
2834                                    count = (Long)q.uniqueResult();
2835    
2836                                    finderCache.putResult(finderPath, finderArgs, count);
2837                            }
2838                            catch (Exception e) {
2839                                    finderCache.removeResult(finderPath, finderArgs);
2840    
2841                                    throw processException(e);
2842                            }
2843                            finally {
2844                                    closeSession(session);
2845                            }
2846                    }
2847    
2848                    return count.intValue();
2849            }
2850    
2851            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2852            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2853                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2854                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2855                            new String[] { Long.class.getName(), String.class.getName() },
2856                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2857                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2858            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2859                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2860                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2861                            new String[] { Long.class.getName(), String.class.getName() });
2862    
2863            /**
2864             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
2865             *
2866             * @param groupId the group ID
2867             * @param urlTitle the url title
2868             * @return the matching blogs entry
2869             * @throws NoSuchEntryException if a matching blogs entry could not be found
2870             */
2871            @Override
2872            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2873                    throws NoSuchEntryException {
2874                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2875    
2876                    if (blogsEntry == null) {
2877                            StringBundler msg = new StringBundler(6);
2878    
2879                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2880    
2881                            msg.append("groupId=");
2882                            msg.append(groupId);
2883    
2884                            msg.append(", urlTitle=");
2885                            msg.append(urlTitle);
2886    
2887                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2888    
2889                            if (_log.isWarnEnabled()) {
2890                                    _log.warn(msg.toString());
2891                            }
2892    
2893                            throw new NoSuchEntryException(msg.toString());
2894                    }
2895    
2896                    return blogsEntry;
2897            }
2898    
2899            /**
2900             * 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.
2901             *
2902             * @param groupId the group ID
2903             * @param urlTitle the url title
2904             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2905             */
2906            @Override
2907            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2908                    return fetchByG_UT(groupId, urlTitle, true);
2909            }
2910    
2911            /**
2912             * 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.
2913             *
2914             * @param groupId the group ID
2915             * @param urlTitle the url title
2916             * @param retrieveFromCache whether to retrieve from the finder cache
2917             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2918             */
2919            @Override
2920            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2921                    boolean retrieveFromCache) {
2922                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2923    
2924                    Object result = null;
2925    
2926                    if (retrieveFromCache) {
2927                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_UT,
2928                                            finderArgs, this);
2929                    }
2930    
2931                    if (result instanceof BlogsEntry) {
2932                            BlogsEntry blogsEntry = (BlogsEntry)result;
2933    
2934                            if ((groupId != blogsEntry.getGroupId()) ||
2935                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
2936                                    result = null;
2937                            }
2938                    }
2939    
2940                    if (result == null) {
2941                            StringBundler query = new StringBundler(4);
2942    
2943                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2944    
2945                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2946    
2947                            boolean bindUrlTitle = false;
2948    
2949                            if (urlTitle == null) {
2950                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2951                            }
2952                            else if (urlTitle.equals(StringPool.BLANK)) {
2953                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2954                            }
2955                            else {
2956                                    bindUrlTitle = true;
2957    
2958                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2959                            }
2960    
2961                            String sql = query.toString();
2962    
2963                            Session session = null;
2964    
2965                            try {
2966                                    session = openSession();
2967    
2968                                    Query q = session.createQuery(sql);
2969    
2970                                    QueryPos qPos = QueryPos.getInstance(q);
2971    
2972                                    qPos.add(groupId);
2973    
2974                                    if (bindUrlTitle) {
2975                                            qPos.add(urlTitle);
2976                                    }
2977    
2978                                    List<BlogsEntry> list = q.list();
2979    
2980                                    if (list.isEmpty()) {
2981                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2982                                                    finderArgs, list);
2983                                    }
2984                                    else {
2985                                            BlogsEntry blogsEntry = list.get(0);
2986    
2987                                            result = blogsEntry;
2988    
2989                                            cacheResult(blogsEntry);
2990    
2991                                            if ((blogsEntry.getGroupId() != groupId) ||
2992                                                            (blogsEntry.getUrlTitle() == null) ||
2993                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
2994                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2995                                                            finderArgs, blogsEntry);
2996                                            }
2997                                    }
2998                            }
2999                            catch (Exception e) {
3000                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, finderArgs);
3001    
3002                                    throw processException(e);
3003                            }
3004                            finally {
3005                                    closeSession(session);
3006                            }
3007                    }
3008    
3009                    if (result instanceof List<?>) {
3010                            return null;
3011                    }
3012                    else {
3013                            return (BlogsEntry)result;
3014                    }
3015            }
3016    
3017            /**
3018             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
3019             *
3020             * @param groupId the group ID
3021             * @param urlTitle the url title
3022             * @return the blogs entry that was removed
3023             */
3024            @Override
3025            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
3026                    throws NoSuchEntryException {
3027                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
3028    
3029                    return remove(blogsEntry);
3030            }
3031    
3032            /**
3033             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
3034             *
3035             * @param groupId the group ID
3036             * @param urlTitle the url title
3037             * @return the number of matching blogs entries
3038             */
3039            @Override
3040            public int countByG_UT(long groupId, String urlTitle) {
3041                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
3042    
3043                    Object[] finderArgs = new Object[] { groupId, urlTitle };
3044    
3045                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3046    
3047                    if (count == null) {
3048                            StringBundler query = new StringBundler(3);
3049    
3050                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3051    
3052                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
3053    
3054                            boolean bindUrlTitle = false;
3055    
3056                            if (urlTitle == null) {
3057                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
3058                            }
3059                            else if (urlTitle.equals(StringPool.BLANK)) {
3060                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
3061                            }
3062                            else {
3063                                    bindUrlTitle = true;
3064    
3065                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
3066                            }
3067    
3068                            String sql = query.toString();
3069    
3070                            Session session = null;
3071    
3072                            try {
3073                                    session = openSession();
3074    
3075                                    Query q = session.createQuery(sql);
3076    
3077                                    QueryPos qPos = QueryPos.getInstance(q);
3078    
3079                                    qPos.add(groupId);
3080    
3081                                    if (bindUrlTitle) {
3082                                            qPos.add(urlTitle);
3083                                    }
3084    
3085                                    count = (Long)q.uniqueResult();
3086    
3087                                    finderCache.putResult(finderPath, finderArgs, count);
3088                            }
3089                            catch (Exception e) {
3090                                    finderCache.removeResult(finderPath, finderArgs);
3091    
3092                                    throw processException(e);
3093                            }
3094                            finally {
3095                                    closeSession(session);
3096                            }
3097                    }
3098    
3099                    return count.intValue();
3100            }
3101    
3102            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3103            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3104            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3105            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3106            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3107                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3108                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3109                            new String[] {
3110                                    Long.class.getName(), Date.class.getName(),
3111                                    
3112                            Integer.class.getName(), Integer.class.getName(),
3113                                    OrderByComparator.class.getName()
3114                            });
3115            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3116                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3117                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3118                            new String[] { Long.class.getName(), Date.class.getName() });
3119    
3120            /**
3121             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3122             *
3123             * @param groupId the group ID
3124             * @param displayDate the display date
3125             * @return the matching blogs entries
3126             */
3127            @Override
3128            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3129                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3130                            QueryUtil.ALL_POS, null);
3131            }
3132    
3133            /**
3134             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3135             *
3136             * <p>
3137             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3138             * </p>
3139             *
3140             * @param groupId the group ID
3141             * @param displayDate the display date
3142             * @param start the lower bound of the range of blogs entries
3143             * @param end the upper bound of the range of blogs entries (not inclusive)
3144             * @return the range of matching blogs entries
3145             */
3146            @Override
3147            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3148                    int start, int end) {
3149                    return findByG_LtD(groupId, displayDate, start, end, null);
3150            }
3151    
3152            /**
3153             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3154             *
3155             * <p>
3156             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3157             * </p>
3158             *
3159             * @param groupId the group ID
3160             * @param displayDate the display date
3161             * @param start the lower bound of the range of blogs entries
3162             * @param end the upper bound of the range of blogs entries (not inclusive)
3163             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3164             * @return the ordered range of matching blogs entries
3165             */
3166            @Override
3167            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3168                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3169                    return findByG_LtD(groupId, displayDate, start, end, orderByComparator,
3170                            true);
3171            }
3172    
3173            /**
3174             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3175             *
3176             * <p>
3177             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3178             * </p>
3179             *
3180             * @param groupId the group ID
3181             * @param displayDate the display date
3182             * @param start the lower bound of the range of blogs entries
3183             * @param end the upper bound of the range of blogs entries (not inclusive)
3184             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3185             * @param retrieveFromCache whether to retrieve from the finder cache
3186             * @return the ordered range of matching blogs entries
3187             */
3188            @Override
3189            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3190                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
3191                    boolean retrieveFromCache) {
3192                    boolean pagination = true;
3193                    FinderPath finderPath = null;
3194                    Object[] finderArgs = null;
3195    
3196                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3197                    finderArgs = new Object[] {
3198                                    groupId, displayDate,
3199                                    
3200                                    start, end, orderByComparator
3201                            };
3202    
3203                    List<BlogsEntry> list = null;
3204    
3205                    if (retrieveFromCache) {
3206                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
3207                                            finderArgs, this);
3208    
3209                            if ((list != null) && !list.isEmpty()) {
3210                                    for (BlogsEntry blogsEntry : list) {
3211                                            if ((groupId != blogsEntry.getGroupId()) ||
3212                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
3213                                                                                                                                            .getTime())) {
3214                                                    list = null;
3215    
3216                                                    break;
3217                                            }
3218                                    }
3219                            }
3220                    }
3221    
3222                    if (list == null) {
3223                            StringBundler query = null;
3224    
3225                            if (orderByComparator != null) {
3226                                    query = new StringBundler(4 +
3227                                                    (orderByComparator.getOrderByFields().length * 3));
3228                            }
3229                            else {
3230                                    query = new StringBundler(4);
3231                            }
3232    
3233                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3234    
3235                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3236    
3237                            boolean bindDisplayDate = false;
3238    
3239                            if (displayDate == null) {
3240                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3241                            }
3242                            else {
3243                                    bindDisplayDate = true;
3244    
3245                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3246                            }
3247    
3248                            if (orderByComparator != null) {
3249                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3250                                            orderByComparator);
3251                            }
3252                            else
3253                             if (pagination) {
3254                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3255                            }
3256    
3257                            String sql = query.toString();
3258    
3259                            Session session = null;
3260    
3261                            try {
3262                                    session = openSession();
3263    
3264                                    Query q = session.createQuery(sql);
3265    
3266                                    QueryPos qPos = QueryPos.getInstance(q);
3267    
3268                                    qPos.add(groupId);
3269    
3270                                    if (bindDisplayDate) {
3271                                            qPos.add(new Timestamp(displayDate.getTime()));
3272                                    }
3273    
3274                                    if (!pagination) {
3275                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3276                                                            start, end, false);
3277    
3278                                            Collections.sort(list);
3279    
3280                                            list = Collections.unmodifiableList(list);
3281                                    }
3282                                    else {
3283                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3284                                                            start, end);
3285                                    }
3286    
3287                                    cacheResult(list);
3288    
3289                                    finderCache.putResult(finderPath, finderArgs, list);
3290                            }
3291                            catch (Exception e) {
3292                                    finderCache.removeResult(finderPath, finderArgs);
3293    
3294                                    throw processException(e);
3295                            }
3296                            finally {
3297                                    closeSession(session);
3298                            }
3299                    }
3300    
3301                    return list;
3302            }
3303    
3304            /**
3305             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3306             *
3307             * @param groupId the group ID
3308             * @param displayDate the display date
3309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3310             * @return the first matching blogs entry
3311             * @throws NoSuchEntryException if a matching blogs entry could not be found
3312             */
3313            @Override
3314            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3315                    OrderByComparator<BlogsEntry> orderByComparator)
3316                    throws NoSuchEntryException {
3317                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3318                                    orderByComparator);
3319    
3320                    if (blogsEntry != null) {
3321                            return blogsEntry;
3322                    }
3323    
3324                    StringBundler msg = new StringBundler(6);
3325    
3326                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3327    
3328                    msg.append("groupId=");
3329                    msg.append(groupId);
3330    
3331                    msg.append(", displayDate=");
3332                    msg.append(displayDate);
3333    
3334                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3335    
3336                    throw new NoSuchEntryException(msg.toString());
3337            }
3338    
3339            /**
3340             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3341             *
3342             * @param groupId the group ID
3343             * @param displayDate the display date
3344             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3345             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3346             */
3347            @Override
3348            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3349                    OrderByComparator<BlogsEntry> orderByComparator) {
3350                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3351                                    orderByComparator);
3352    
3353                    if (!list.isEmpty()) {
3354                            return list.get(0);
3355                    }
3356    
3357                    return null;
3358            }
3359    
3360            /**
3361             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3362             *
3363             * @param groupId the group ID
3364             * @param displayDate the display date
3365             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3366             * @return the last matching blogs entry
3367             * @throws NoSuchEntryException if a matching blogs entry could not be found
3368             */
3369            @Override
3370            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3371                    OrderByComparator<BlogsEntry> orderByComparator)
3372                    throws NoSuchEntryException {
3373                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3374                                    orderByComparator);
3375    
3376                    if (blogsEntry != null) {
3377                            return blogsEntry;
3378                    }
3379    
3380                    StringBundler msg = new StringBundler(6);
3381    
3382                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3383    
3384                    msg.append("groupId=");
3385                    msg.append(groupId);
3386    
3387                    msg.append(", displayDate=");
3388                    msg.append(displayDate);
3389    
3390                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3391    
3392                    throw new NoSuchEntryException(msg.toString());
3393            }
3394    
3395            /**
3396             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3397             *
3398             * @param groupId the group ID
3399             * @param displayDate the display date
3400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3401             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3402             */
3403            @Override
3404            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3405                    OrderByComparator<BlogsEntry> orderByComparator) {
3406                    int count = countByG_LtD(groupId, displayDate);
3407    
3408                    if (count == 0) {
3409                            return null;
3410                    }
3411    
3412                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3413                                    count, orderByComparator);
3414    
3415                    if (!list.isEmpty()) {
3416                            return list.get(0);
3417                    }
3418    
3419                    return null;
3420            }
3421    
3422            /**
3423             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3424             *
3425             * @param entryId the primary key of the current blogs entry
3426             * @param groupId the group ID
3427             * @param displayDate the display date
3428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3429             * @return the previous, current, and next blogs entry
3430             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3431             */
3432            @Override
3433            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3434                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3435                    throws NoSuchEntryException {
3436                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3437    
3438                    Session session = null;
3439    
3440                    try {
3441                            session = openSession();
3442    
3443                            BlogsEntry[] array = new BlogsEntryImpl[3];
3444    
3445                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3446                                            displayDate, orderByComparator, true);
3447    
3448                            array[1] = blogsEntry;
3449    
3450                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3451                                            displayDate, orderByComparator, false);
3452    
3453                            return array;
3454                    }
3455                    catch (Exception e) {
3456                            throw processException(e);
3457                    }
3458                    finally {
3459                            closeSession(session);
3460                    }
3461            }
3462    
3463            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3464                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3465                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3466                    StringBundler query = null;
3467    
3468                    if (orderByComparator != null) {
3469                            query = new StringBundler(6 +
3470                                            (orderByComparator.getOrderByFields().length * 6));
3471                    }
3472                    else {
3473                            query = new StringBundler(3);
3474                    }
3475    
3476                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3477    
3478                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3479    
3480                    boolean bindDisplayDate = false;
3481    
3482                    if (displayDate == null) {
3483                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3484                    }
3485                    else {
3486                            bindDisplayDate = true;
3487    
3488                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3489                    }
3490    
3491                    if (orderByComparator != null) {
3492                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3493    
3494                            if (orderByConditionFields.length > 0) {
3495                                    query.append(WHERE_AND);
3496                            }
3497    
3498                            for (int i = 0; i < orderByConditionFields.length; i++) {
3499                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3500                                    query.append(orderByConditionFields[i]);
3501    
3502                                    if ((i + 1) < orderByConditionFields.length) {
3503                                            if (orderByComparator.isAscending() ^ previous) {
3504                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3505                                            }
3506                                            else {
3507                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3508                                            }
3509                                    }
3510                                    else {
3511                                            if (orderByComparator.isAscending() ^ previous) {
3512                                                    query.append(WHERE_GREATER_THAN);
3513                                            }
3514                                            else {
3515                                                    query.append(WHERE_LESSER_THAN);
3516                                            }
3517                                    }
3518                            }
3519    
3520                            query.append(ORDER_BY_CLAUSE);
3521    
3522                            String[] orderByFields = orderByComparator.getOrderByFields();
3523    
3524                            for (int i = 0; i < orderByFields.length; i++) {
3525                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3526                                    query.append(orderByFields[i]);
3527    
3528                                    if ((i + 1) < orderByFields.length) {
3529                                            if (orderByComparator.isAscending() ^ previous) {
3530                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3531                                            }
3532                                            else {
3533                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3534                                            }
3535                                    }
3536                                    else {
3537                                            if (orderByComparator.isAscending() ^ previous) {
3538                                                    query.append(ORDER_BY_ASC);
3539                                            }
3540                                            else {
3541                                                    query.append(ORDER_BY_DESC);
3542                                            }
3543                                    }
3544                            }
3545                    }
3546                    else {
3547                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3548                    }
3549    
3550                    String sql = query.toString();
3551    
3552                    Query q = session.createQuery(sql);
3553    
3554                    q.setFirstResult(0);
3555                    q.setMaxResults(2);
3556    
3557                    QueryPos qPos = QueryPos.getInstance(q);
3558    
3559                    qPos.add(groupId);
3560    
3561                    if (bindDisplayDate) {
3562                            qPos.add(new Timestamp(displayDate.getTime()));
3563                    }
3564    
3565                    if (orderByComparator != null) {
3566                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3567    
3568                            for (Object value : values) {
3569                                    qPos.add(value);
3570                            }
3571                    }
3572    
3573                    List<BlogsEntry> list = q.list();
3574    
3575                    if (list.size() == 2) {
3576                            return list.get(1);
3577                    }
3578                    else {
3579                            return null;
3580                    }
3581            }
3582    
3583            /**
3584             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3585             *
3586             * @param groupId the group ID
3587             * @param displayDate the display date
3588             * @return the matching blogs entries that the user has permission to view
3589             */
3590            @Override
3591            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3592                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3593                            QueryUtil.ALL_POS, null);
3594            }
3595    
3596            /**
3597             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3598             *
3599             * <p>
3600             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3601             * </p>
3602             *
3603             * @param groupId the group ID
3604             * @param displayDate the display date
3605             * @param start the lower bound of the range of blogs entries
3606             * @param end the upper bound of the range of blogs entries (not inclusive)
3607             * @return the range of matching blogs entries that the user has permission to view
3608             */
3609            @Override
3610            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3611                    int start, int end) {
3612                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3613            }
3614    
3615            /**
3616             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3617             *
3618             * <p>
3619             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3620             * </p>
3621             *
3622             * @param groupId the group ID
3623             * @param displayDate the display date
3624             * @param start the lower bound of the range of blogs entries
3625             * @param end the upper bound of the range of blogs entries (not inclusive)
3626             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3627             * @return the ordered range of matching blogs entries that the user has permission to view
3628             */
3629            @Override
3630            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3631                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3632                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3633                            return findByG_LtD(groupId, displayDate, start, end,
3634                                    orderByComparator);
3635                    }
3636    
3637                    StringBundler query = null;
3638    
3639                    if (orderByComparator != null) {
3640                            query = new StringBundler(4 +
3641                                            (orderByComparator.getOrderByFields().length * 3));
3642                    }
3643                    else {
3644                            query = new StringBundler(4);
3645                    }
3646    
3647                    if (getDB().isSupportsInlineDistinct()) {
3648                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3649                    }
3650                    else {
3651                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3652                    }
3653    
3654                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3655    
3656                    boolean bindDisplayDate = false;
3657    
3658                    if (displayDate == null) {
3659                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3660                    }
3661                    else {
3662                            bindDisplayDate = true;
3663    
3664                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3665                    }
3666    
3667                    if (!getDB().isSupportsInlineDistinct()) {
3668                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3669                    }
3670    
3671                    if (orderByComparator != null) {
3672                            if (getDB().isSupportsInlineDistinct()) {
3673                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3674                                            orderByComparator, true);
3675                            }
3676                            else {
3677                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3678                                            orderByComparator, true);
3679                            }
3680                    }
3681                    else {
3682                            if (getDB().isSupportsInlineDistinct()) {
3683                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3684                            }
3685                            else {
3686                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3687                            }
3688                    }
3689    
3690                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3691                                    BlogsEntry.class.getName(),
3692                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3693    
3694                    Session session = null;
3695    
3696                    try {
3697                            session = openSession();
3698    
3699                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3700    
3701                            if (getDB().isSupportsInlineDistinct()) {
3702                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3703                            }
3704                            else {
3705                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3706                            }
3707    
3708                            QueryPos qPos = QueryPos.getInstance(q);
3709    
3710                            qPos.add(groupId);
3711    
3712                            if (bindDisplayDate) {
3713                                    qPos.add(new Timestamp(displayDate.getTime()));
3714                            }
3715    
3716                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3717                    }
3718                    catch (Exception e) {
3719                            throw processException(e);
3720                    }
3721                    finally {
3722                            closeSession(session);
3723                    }
3724            }
3725    
3726            /**
3727             * 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;.
3728             *
3729             * @param entryId the primary key of the current blogs entry
3730             * @param groupId the group ID
3731             * @param displayDate the display date
3732             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3733             * @return the previous, current, and next blogs entry
3734             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3735             */
3736            @Override
3737            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3738                    long groupId, Date displayDate,
3739                    OrderByComparator<BlogsEntry> orderByComparator)
3740                    throws NoSuchEntryException {
3741                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3742                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3743                                    orderByComparator);
3744                    }
3745    
3746                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3747    
3748                    Session session = null;
3749    
3750                    try {
3751                            session = openSession();
3752    
3753                            BlogsEntry[] array = new BlogsEntryImpl[3];
3754    
3755                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3756                                            groupId, displayDate, orderByComparator, true);
3757    
3758                            array[1] = blogsEntry;
3759    
3760                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3761                                            groupId, displayDate, orderByComparator, false);
3762    
3763                            return array;
3764                    }
3765                    catch (Exception e) {
3766                            throw processException(e);
3767                    }
3768                    finally {
3769                            closeSession(session);
3770                    }
3771            }
3772    
3773            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3774                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3775                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3776                    StringBundler query = null;
3777    
3778                    if (orderByComparator != null) {
3779                            query = new StringBundler(6 +
3780                                            (orderByComparator.getOrderByFields().length * 6));
3781                    }
3782                    else {
3783                            query = new StringBundler(3);
3784                    }
3785    
3786                    if (getDB().isSupportsInlineDistinct()) {
3787                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3788                    }
3789                    else {
3790                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3791                    }
3792    
3793                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3794    
3795                    boolean bindDisplayDate = false;
3796    
3797                    if (displayDate == null) {
3798                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3799                    }
3800                    else {
3801                            bindDisplayDate = true;
3802    
3803                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3804                    }
3805    
3806                    if (!getDB().isSupportsInlineDistinct()) {
3807                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3808                    }
3809    
3810                    if (orderByComparator != null) {
3811                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3812    
3813                            if (orderByConditionFields.length > 0) {
3814                                    query.append(WHERE_AND);
3815                            }
3816    
3817                            for (int i = 0; i < orderByConditionFields.length; i++) {
3818                                    if (getDB().isSupportsInlineDistinct()) {
3819                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3820                                    }
3821                                    else {
3822                                            query.append(_ORDER_BY_ENTITY_TABLE);
3823                                    }
3824    
3825                                    query.append(orderByConditionFields[i]);
3826    
3827                                    if ((i + 1) < orderByConditionFields.length) {
3828                                            if (orderByComparator.isAscending() ^ previous) {
3829                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3830                                            }
3831                                            else {
3832                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3833                                            }
3834                                    }
3835                                    else {
3836                                            if (orderByComparator.isAscending() ^ previous) {
3837                                                    query.append(WHERE_GREATER_THAN);
3838                                            }
3839                                            else {
3840                                                    query.append(WHERE_LESSER_THAN);
3841                                            }
3842                                    }
3843                            }
3844    
3845                            query.append(ORDER_BY_CLAUSE);
3846    
3847                            String[] orderByFields = orderByComparator.getOrderByFields();
3848    
3849                            for (int i = 0; i < orderByFields.length; i++) {
3850                                    if (getDB().isSupportsInlineDistinct()) {
3851                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3852                                    }
3853                                    else {
3854                                            query.append(_ORDER_BY_ENTITY_TABLE);
3855                                    }
3856    
3857                                    query.append(orderByFields[i]);
3858    
3859                                    if ((i + 1) < orderByFields.length) {
3860                                            if (orderByComparator.isAscending() ^ previous) {
3861                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3862                                            }
3863                                            else {
3864                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3865                                            }
3866                                    }
3867                                    else {
3868                                            if (orderByComparator.isAscending() ^ previous) {
3869                                                    query.append(ORDER_BY_ASC);
3870                                            }
3871                                            else {
3872                                                    query.append(ORDER_BY_DESC);
3873                                            }
3874                                    }
3875                            }
3876                    }
3877                    else {
3878                            if (getDB().isSupportsInlineDistinct()) {
3879                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3880                            }
3881                            else {
3882                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3883                            }
3884                    }
3885    
3886                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3887                                    BlogsEntry.class.getName(),
3888                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3889    
3890                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3891    
3892                    q.setFirstResult(0);
3893                    q.setMaxResults(2);
3894    
3895                    if (getDB().isSupportsInlineDistinct()) {
3896                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3897                    }
3898                    else {
3899                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3900                    }
3901    
3902                    QueryPos qPos = QueryPos.getInstance(q);
3903    
3904                    qPos.add(groupId);
3905    
3906                    if (bindDisplayDate) {
3907                            qPos.add(new Timestamp(displayDate.getTime()));
3908                    }
3909    
3910                    if (orderByComparator != null) {
3911                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3912    
3913                            for (Object value : values) {
3914                                    qPos.add(value);
3915                            }
3916                    }
3917    
3918                    List<BlogsEntry> list = q.list();
3919    
3920                    if (list.size() == 2) {
3921                            return list.get(1);
3922                    }
3923                    else {
3924                            return null;
3925                    }
3926            }
3927    
3928            /**
3929             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3930             *
3931             * @param groupId the group ID
3932             * @param displayDate the display date
3933             */
3934            @Override
3935            public void removeByG_LtD(long groupId, Date displayDate) {
3936                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3937                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3938                            remove(blogsEntry);
3939                    }
3940            }
3941    
3942            /**
3943             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3944             *
3945             * @param groupId the group ID
3946             * @param displayDate the display date
3947             * @return the number of matching blogs entries
3948             */
3949            @Override
3950            public int countByG_LtD(long groupId, Date displayDate) {
3951                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3952    
3953                    Object[] finderArgs = new Object[] { groupId, displayDate };
3954    
3955                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3956    
3957                    if (count == null) {
3958                            StringBundler query = new StringBundler(3);
3959    
3960                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3961    
3962                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3963    
3964                            boolean bindDisplayDate = false;
3965    
3966                            if (displayDate == null) {
3967                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3968                            }
3969                            else {
3970                                    bindDisplayDate = true;
3971    
3972                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3973                            }
3974    
3975                            String sql = query.toString();
3976    
3977                            Session session = null;
3978    
3979                            try {
3980                                    session = openSession();
3981    
3982                                    Query q = session.createQuery(sql);
3983    
3984                                    QueryPos qPos = QueryPos.getInstance(q);
3985    
3986                                    qPos.add(groupId);
3987    
3988                                    if (bindDisplayDate) {
3989                                            qPos.add(new Timestamp(displayDate.getTime()));
3990                                    }
3991    
3992                                    count = (Long)q.uniqueResult();
3993    
3994                                    finderCache.putResult(finderPath, finderArgs, count);
3995                            }
3996                            catch (Exception e) {
3997                                    finderCache.removeResult(finderPath, finderArgs);
3998    
3999                                    throw processException(e);
4000                            }
4001                            finally {
4002                                    closeSession(session);
4003                            }
4004                    }
4005    
4006                    return count.intValue();
4007            }
4008    
4009            /**
4010             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4011             *
4012             * @param groupId the group ID
4013             * @param displayDate the display date
4014             * @return the number of matching blogs entries that the user has permission to view
4015             */
4016            @Override
4017            public int filterCountByG_LtD(long groupId, Date displayDate) {
4018                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4019                            return countByG_LtD(groupId, displayDate);
4020                    }
4021    
4022                    StringBundler query = new StringBundler(3);
4023    
4024                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4025    
4026                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4027    
4028                    boolean bindDisplayDate = false;
4029    
4030                    if (displayDate == null) {
4031                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4032                    }
4033                    else {
4034                            bindDisplayDate = true;
4035    
4036                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4037                    }
4038    
4039                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4040                                    BlogsEntry.class.getName(),
4041                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4042    
4043                    Session session = null;
4044    
4045                    try {
4046                            session = openSession();
4047    
4048                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4049    
4050                            q.addScalar(COUNT_COLUMN_NAME,
4051                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4052    
4053                            QueryPos qPos = QueryPos.getInstance(q);
4054    
4055                            qPos.add(groupId);
4056    
4057                            if (bindDisplayDate) {
4058                                    qPos.add(new Timestamp(displayDate.getTime()));
4059                            }
4060    
4061                            Long count = (Long)q.uniqueResult();
4062    
4063                            return count.intValue();
4064                    }
4065                    catch (Exception e) {
4066                            throw processException(e);
4067                    }
4068                    finally {
4069                            closeSession(session);
4070                    }
4071            }
4072    
4073            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4074            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
4075            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
4076            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4077                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4078                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4079                            new String[] {
4080                                    Long.class.getName(), Integer.class.getName(),
4081                                    
4082                            Integer.class.getName(), Integer.class.getName(),
4083                                    OrderByComparator.class.getName()
4084                            });
4085            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4086                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4088                            new String[] { Long.class.getName(), Integer.class.getName() },
4089                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4090                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4091                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4092                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4093            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4094                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4096                            new String[] { Long.class.getName(), Integer.class.getName() });
4097    
4098            /**
4099             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
4100             *
4101             * @param groupId the group ID
4102             * @param status the status
4103             * @return the matching blogs entries
4104             */
4105            @Override
4106            public List<BlogsEntry> findByG_S(long groupId, int status) {
4107                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4108                            null);
4109            }
4110    
4111            /**
4112             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
4113             *
4114             * <p>
4115             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4116             * </p>
4117             *
4118             * @param groupId the group ID
4119             * @param status the status
4120             * @param start the lower bound of the range of blogs entries
4121             * @param end the upper bound of the range of blogs entries (not inclusive)
4122             * @return the range of matching blogs entries
4123             */
4124            @Override
4125            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4126                    int end) {
4127                    return findByG_S(groupId, status, start, end, null);
4128            }
4129    
4130            /**
4131             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4132             *
4133             * <p>
4134             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4135             * </p>
4136             *
4137             * @param groupId the group ID
4138             * @param status the status
4139             * @param start the lower bound of the range of blogs entries
4140             * @param end the upper bound of the range of blogs entries (not inclusive)
4141             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4142             * @return the ordered range of matching blogs entries
4143             */
4144            @Override
4145            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4146                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4147                    return findByG_S(groupId, status, start, end, orderByComparator, true);
4148            }
4149    
4150            /**
4151             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4152             *
4153             * <p>
4154             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4155             * </p>
4156             *
4157             * @param groupId the group ID
4158             * @param status the status
4159             * @param start the lower bound of the range of blogs entries
4160             * @param end the upper bound of the range of blogs entries (not inclusive)
4161             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4162             * @param retrieveFromCache whether to retrieve from the finder cache
4163             * @return the ordered range of matching blogs entries
4164             */
4165            @Override
4166            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4167                    int end, OrderByComparator<BlogsEntry> orderByComparator,
4168                    boolean retrieveFromCache) {
4169                    boolean pagination = true;
4170                    FinderPath finderPath = null;
4171                    Object[] finderArgs = null;
4172    
4173                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4174                                    (orderByComparator == null)) {
4175                            pagination = false;
4176                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4177                            finderArgs = new Object[] { groupId, status };
4178                    }
4179                    else {
4180                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4181                            finderArgs = new Object[] {
4182                                            groupId, status,
4183                                            
4184                                            start, end, orderByComparator
4185                                    };
4186                    }
4187    
4188                    List<BlogsEntry> list = null;
4189    
4190                    if (retrieveFromCache) {
4191                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
4192                                            finderArgs, this);
4193    
4194                            if ((list != null) && !list.isEmpty()) {
4195                                    for (BlogsEntry blogsEntry : list) {
4196                                            if ((groupId != blogsEntry.getGroupId()) ||
4197                                                            (status != blogsEntry.getStatus())) {
4198                                                    list = null;
4199    
4200                                                    break;
4201                                            }
4202                                    }
4203                            }
4204                    }
4205    
4206                    if (list == null) {
4207                            StringBundler query = null;
4208    
4209                            if (orderByComparator != null) {
4210                                    query = new StringBundler(4 +
4211                                                    (orderByComparator.getOrderByFields().length * 3));
4212                            }
4213                            else {
4214                                    query = new StringBundler(4);
4215                            }
4216    
4217                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4218    
4219                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4220    
4221                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4222    
4223                            if (orderByComparator != null) {
4224                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4225                                            orderByComparator);
4226                            }
4227                            else
4228                             if (pagination) {
4229                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4230                            }
4231    
4232                            String sql = query.toString();
4233    
4234                            Session session = null;
4235    
4236                            try {
4237                                    session = openSession();
4238    
4239                                    Query q = session.createQuery(sql);
4240    
4241                                    QueryPos qPos = QueryPos.getInstance(q);
4242    
4243                                    qPos.add(groupId);
4244    
4245                                    qPos.add(status);
4246    
4247                                    if (!pagination) {
4248                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4249                                                            start, end, false);
4250    
4251                                            Collections.sort(list);
4252    
4253                                            list = Collections.unmodifiableList(list);
4254                                    }
4255                                    else {
4256                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4257                                                            start, end);
4258                                    }
4259    
4260                                    cacheResult(list);
4261    
4262                                    finderCache.putResult(finderPath, finderArgs, list);
4263                            }
4264                            catch (Exception e) {
4265                                    finderCache.removeResult(finderPath, finderArgs);
4266    
4267                                    throw processException(e);
4268                            }
4269                            finally {
4270                                    closeSession(session);
4271                            }
4272                    }
4273    
4274                    return list;
4275            }
4276    
4277            /**
4278             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4279             *
4280             * @param groupId the group ID
4281             * @param status the status
4282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4283             * @return the first matching blogs entry
4284             * @throws NoSuchEntryException if a matching blogs entry could not be found
4285             */
4286            @Override
4287            public BlogsEntry findByG_S_First(long groupId, int status,
4288                    OrderByComparator<BlogsEntry> orderByComparator)
4289                    throws NoSuchEntryException {
4290                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4291                                    orderByComparator);
4292    
4293                    if (blogsEntry != null) {
4294                            return blogsEntry;
4295                    }
4296    
4297                    StringBundler msg = new StringBundler(6);
4298    
4299                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4300    
4301                    msg.append("groupId=");
4302                    msg.append(groupId);
4303    
4304                    msg.append(", status=");
4305                    msg.append(status);
4306    
4307                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4308    
4309                    throw new NoSuchEntryException(msg.toString());
4310            }
4311    
4312            /**
4313             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4314             *
4315             * @param groupId the group ID
4316             * @param status the status
4317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4318             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4319             */
4320            @Override
4321            public BlogsEntry fetchByG_S_First(long groupId, int status,
4322                    OrderByComparator<BlogsEntry> orderByComparator) {
4323                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4324                                    orderByComparator);
4325    
4326                    if (!list.isEmpty()) {
4327                            return list.get(0);
4328                    }
4329    
4330                    return null;
4331            }
4332    
4333            /**
4334             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4335             *
4336             * @param groupId the group ID
4337             * @param status the status
4338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4339             * @return the last matching blogs entry
4340             * @throws NoSuchEntryException if a matching blogs entry could not be found
4341             */
4342            @Override
4343            public BlogsEntry findByG_S_Last(long groupId, int status,
4344                    OrderByComparator<BlogsEntry> orderByComparator)
4345                    throws NoSuchEntryException {
4346                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4347                                    orderByComparator);
4348    
4349                    if (blogsEntry != null) {
4350                            return blogsEntry;
4351                    }
4352    
4353                    StringBundler msg = new StringBundler(6);
4354    
4355                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4356    
4357                    msg.append("groupId=");
4358                    msg.append(groupId);
4359    
4360                    msg.append(", status=");
4361                    msg.append(status);
4362    
4363                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4364    
4365                    throw new NoSuchEntryException(msg.toString());
4366            }
4367    
4368            /**
4369             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4370             *
4371             * @param groupId the group ID
4372             * @param status the status
4373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4374             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4375             */
4376            @Override
4377            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4378                    OrderByComparator<BlogsEntry> orderByComparator) {
4379                    int count = countByG_S(groupId, status);
4380    
4381                    if (count == 0) {
4382                            return null;
4383                    }
4384    
4385                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4386                                    orderByComparator);
4387    
4388                    if (!list.isEmpty()) {
4389                            return list.get(0);
4390                    }
4391    
4392                    return null;
4393            }
4394    
4395            /**
4396             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4397             *
4398             * @param entryId the primary key of the current blogs entry
4399             * @param groupId the group ID
4400             * @param status the status
4401             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4402             * @return the previous, current, and next blogs entry
4403             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4404             */
4405            @Override
4406            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4407                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4408                    throws NoSuchEntryException {
4409                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4410    
4411                    Session session = null;
4412    
4413                    try {
4414                            session = openSession();
4415    
4416                            BlogsEntry[] array = new BlogsEntryImpl[3];
4417    
4418                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4419                                            status, orderByComparator, true);
4420    
4421                            array[1] = blogsEntry;
4422    
4423                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4424                                            status, orderByComparator, false);
4425    
4426                            return array;
4427                    }
4428                    catch (Exception e) {
4429                            throw processException(e);
4430                    }
4431                    finally {
4432                            closeSession(session);
4433                    }
4434            }
4435    
4436            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4437                    BlogsEntry blogsEntry, long groupId, int status,
4438                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4439                    StringBundler query = null;
4440    
4441                    if (orderByComparator != null) {
4442                            query = new StringBundler(6 +
4443                                            (orderByComparator.getOrderByFields().length * 6));
4444                    }
4445                    else {
4446                            query = new StringBundler(3);
4447                    }
4448    
4449                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4450    
4451                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4452    
4453                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4454    
4455                    if (orderByComparator != null) {
4456                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4457    
4458                            if (orderByConditionFields.length > 0) {
4459                                    query.append(WHERE_AND);
4460                            }
4461    
4462                            for (int i = 0; i < orderByConditionFields.length; i++) {
4463                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4464                                    query.append(orderByConditionFields[i]);
4465    
4466                                    if ((i + 1) < orderByConditionFields.length) {
4467                                            if (orderByComparator.isAscending() ^ previous) {
4468                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4469                                            }
4470                                            else {
4471                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4472                                            }
4473                                    }
4474                                    else {
4475                                            if (orderByComparator.isAscending() ^ previous) {
4476                                                    query.append(WHERE_GREATER_THAN);
4477                                            }
4478                                            else {
4479                                                    query.append(WHERE_LESSER_THAN);
4480                                            }
4481                                    }
4482                            }
4483    
4484                            query.append(ORDER_BY_CLAUSE);
4485    
4486                            String[] orderByFields = orderByComparator.getOrderByFields();
4487    
4488                            for (int i = 0; i < orderByFields.length; i++) {
4489                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4490                                    query.append(orderByFields[i]);
4491    
4492                                    if ((i + 1) < orderByFields.length) {
4493                                            if (orderByComparator.isAscending() ^ previous) {
4494                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4495                                            }
4496                                            else {
4497                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4498                                            }
4499                                    }
4500                                    else {
4501                                            if (orderByComparator.isAscending() ^ previous) {
4502                                                    query.append(ORDER_BY_ASC);
4503                                            }
4504                                            else {
4505                                                    query.append(ORDER_BY_DESC);
4506                                            }
4507                                    }
4508                            }
4509                    }
4510                    else {
4511                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4512                    }
4513    
4514                    String sql = query.toString();
4515    
4516                    Query q = session.createQuery(sql);
4517    
4518                    q.setFirstResult(0);
4519                    q.setMaxResults(2);
4520    
4521                    QueryPos qPos = QueryPos.getInstance(q);
4522    
4523                    qPos.add(groupId);
4524    
4525                    qPos.add(status);
4526    
4527                    if (orderByComparator != null) {
4528                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4529    
4530                            for (Object value : values) {
4531                                    qPos.add(value);
4532                            }
4533                    }
4534    
4535                    List<BlogsEntry> list = q.list();
4536    
4537                    if (list.size() == 2) {
4538                            return list.get(1);
4539                    }
4540                    else {
4541                            return null;
4542                    }
4543            }
4544    
4545            /**
4546             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4547             *
4548             * @param groupId the group ID
4549             * @param status the status
4550             * @return the matching blogs entries that the user has permission to view
4551             */
4552            @Override
4553            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4554                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4555                            QueryUtil.ALL_POS, null);
4556            }
4557    
4558            /**
4559             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4560             *
4561             * <p>
4562             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4563             * </p>
4564             *
4565             * @param groupId the group ID
4566             * @param status the status
4567             * @param start the lower bound of the range of blogs entries
4568             * @param end the upper bound of the range of blogs entries (not inclusive)
4569             * @return the range of matching blogs entries that the user has permission to view
4570             */
4571            @Override
4572            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4573                    int start, int end) {
4574                    return filterFindByG_S(groupId, status, start, end, null);
4575            }
4576    
4577            /**
4578             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4579             *
4580             * <p>
4581             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4582             * </p>
4583             *
4584             * @param groupId the group ID
4585             * @param status the status
4586             * @param start the lower bound of the range of blogs entries
4587             * @param end the upper bound of the range of blogs entries (not inclusive)
4588             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4589             * @return the ordered range of matching blogs entries that the user has permission to view
4590             */
4591            @Override
4592            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4593                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4594                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4595                            return findByG_S(groupId, status, start, end, orderByComparator);
4596                    }
4597    
4598                    StringBundler query = null;
4599    
4600                    if (orderByComparator != null) {
4601                            query = new StringBundler(4 +
4602                                            (orderByComparator.getOrderByFields().length * 3));
4603                    }
4604                    else {
4605                            query = new StringBundler(4);
4606                    }
4607    
4608                    if (getDB().isSupportsInlineDistinct()) {
4609                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4610                    }
4611                    else {
4612                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4613                    }
4614    
4615                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4616    
4617                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4618    
4619                    if (!getDB().isSupportsInlineDistinct()) {
4620                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4621                    }
4622    
4623                    if (orderByComparator != null) {
4624                            if (getDB().isSupportsInlineDistinct()) {
4625                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4626                                            orderByComparator, true);
4627                            }
4628                            else {
4629                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4630                                            orderByComparator, true);
4631                            }
4632                    }
4633                    else {
4634                            if (getDB().isSupportsInlineDistinct()) {
4635                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4636                            }
4637                            else {
4638                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4639                            }
4640                    }
4641    
4642                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4643                                    BlogsEntry.class.getName(),
4644                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4645    
4646                    Session session = null;
4647    
4648                    try {
4649                            session = openSession();
4650    
4651                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4652    
4653                            if (getDB().isSupportsInlineDistinct()) {
4654                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4655                            }
4656                            else {
4657                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4658                            }
4659    
4660                            QueryPos qPos = QueryPos.getInstance(q);
4661    
4662                            qPos.add(groupId);
4663    
4664                            qPos.add(status);
4665    
4666                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4667                    }
4668                    catch (Exception e) {
4669                            throw processException(e);
4670                    }
4671                    finally {
4672                            closeSession(session);
4673                    }
4674            }
4675    
4676            /**
4677             * 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;.
4678             *
4679             * @param entryId the primary key of the current blogs entry
4680             * @param groupId the group ID
4681             * @param status the status
4682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4683             * @return the previous, current, and next blogs entry
4684             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4685             */
4686            @Override
4687            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4688                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4689                    throws NoSuchEntryException {
4690                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4691                            return findByG_S_PrevAndNext(entryId, groupId, status,
4692                                    orderByComparator);
4693                    }
4694    
4695                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4696    
4697                    Session session = null;
4698    
4699                    try {
4700                            session = openSession();
4701    
4702                            BlogsEntry[] array = new BlogsEntryImpl[3];
4703    
4704                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4705                                            status, orderByComparator, true);
4706    
4707                            array[1] = blogsEntry;
4708    
4709                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4710                                            status, orderByComparator, false);
4711    
4712                            return array;
4713                    }
4714                    catch (Exception e) {
4715                            throw processException(e);
4716                    }
4717                    finally {
4718                            closeSession(session);
4719                    }
4720            }
4721    
4722            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4723                    BlogsEntry blogsEntry, long groupId, int status,
4724                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4725                    StringBundler query = null;
4726    
4727                    if (orderByComparator != null) {
4728                            query = new StringBundler(6 +
4729                                            (orderByComparator.getOrderByFields().length * 6));
4730                    }
4731                    else {
4732                            query = new StringBundler(3);
4733                    }
4734    
4735                    if (getDB().isSupportsInlineDistinct()) {
4736                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4737                    }
4738                    else {
4739                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4740                    }
4741    
4742                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4743    
4744                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4745    
4746                    if (!getDB().isSupportsInlineDistinct()) {
4747                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4748                    }
4749    
4750                    if (orderByComparator != null) {
4751                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4752    
4753                            if (orderByConditionFields.length > 0) {
4754                                    query.append(WHERE_AND);
4755                            }
4756    
4757                            for (int i = 0; i < orderByConditionFields.length; i++) {
4758                                    if (getDB().isSupportsInlineDistinct()) {
4759                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4760                                    }
4761                                    else {
4762                                            query.append(_ORDER_BY_ENTITY_TABLE);
4763                                    }
4764    
4765                                    query.append(orderByConditionFields[i]);
4766    
4767                                    if ((i + 1) < orderByConditionFields.length) {
4768                                            if (orderByComparator.isAscending() ^ previous) {
4769                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4770                                            }
4771                                            else {
4772                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4773                                            }
4774                                    }
4775                                    else {
4776                                            if (orderByComparator.isAscending() ^ previous) {
4777                                                    query.append(WHERE_GREATER_THAN);
4778                                            }
4779                                            else {
4780                                                    query.append(WHERE_LESSER_THAN);
4781                                            }
4782                                    }
4783                            }
4784    
4785                            query.append(ORDER_BY_CLAUSE);
4786    
4787                            String[] orderByFields = orderByComparator.getOrderByFields();
4788    
4789                            for (int i = 0; i < orderByFields.length; i++) {
4790                                    if (getDB().isSupportsInlineDistinct()) {
4791                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4792                                    }
4793                                    else {
4794                                            query.append(_ORDER_BY_ENTITY_TABLE);
4795                                    }
4796    
4797                                    query.append(orderByFields[i]);
4798    
4799                                    if ((i + 1) < orderByFields.length) {
4800                                            if (orderByComparator.isAscending() ^ previous) {
4801                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4802                                            }
4803                                            else {
4804                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4805                                            }
4806                                    }
4807                                    else {
4808                                            if (orderByComparator.isAscending() ^ previous) {
4809                                                    query.append(ORDER_BY_ASC);
4810                                            }
4811                                            else {
4812                                                    query.append(ORDER_BY_DESC);
4813                                            }
4814                                    }
4815                            }
4816                    }
4817                    else {
4818                            if (getDB().isSupportsInlineDistinct()) {
4819                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4820                            }
4821                            else {
4822                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4823                            }
4824                    }
4825    
4826                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4827                                    BlogsEntry.class.getName(),
4828                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4829    
4830                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4831    
4832                    q.setFirstResult(0);
4833                    q.setMaxResults(2);
4834    
4835                    if (getDB().isSupportsInlineDistinct()) {
4836                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4837                    }
4838                    else {
4839                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4840                    }
4841    
4842                    QueryPos qPos = QueryPos.getInstance(q);
4843    
4844                    qPos.add(groupId);
4845    
4846                    qPos.add(status);
4847    
4848                    if (orderByComparator != null) {
4849                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4850    
4851                            for (Object value : values) {
4852                                    qPos.add(value);
4853                            }
4854                    }
4855    
4856                    List<BlogsEntry> list = q.list();
4857    
4858                    if (list.size() == 2) {
4859                            return list.get(1);
4860                    }
4861                    else {
4862                            return null;
4863                    }
4864            }
4865    
4866            /**
4867             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4868             *
4869             * @param groupId the group ID
4870             * @param status the status
4871             */
4872            @Override
4873            public void removeByG_S(long groupId, int status) {
4874                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4875                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4876                            remove(blogsEntry);
4877                    }
4878            }
4879    
4880            /**
4881             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4882             *
4883             * @param groupId the group ID
4884             * @param status the status
4885             * @return the number of matching blogs entries
4886             */
4887            @Override
4888            public int countByG_S(long groupId, int status) {
4889                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4890    
4891                    Object[] finderArgs = new Object[] { groupId, status };
4892    
4893                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4894    
4895                    if (count == null) {
4896                            StringBundler query = new StringBundler(3);
4897    
4898                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4899    
4900                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4901    
4902                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4903    
4904                            String sql = query.toString();
4905    
4906                            Session session = null;
4907    
4908                            try {
4909                                    session = openSession();
4910    
4911                                    Query q = session.createQuery(sql);
4912    
4913                                    QueryPos qPos = QueryPos.getInstance(q);
4914    
4915                                    qPos.add(groupId);
4916    
4917                                    qPos.add(status);
4918    
4919                                    count = (Long)q.uniqueResult();
4920    
4921                                    finderCache.putResult(finderPath, finderArgs, count);
4922                            }
4923                            catch (Exception e) {
4924                                    finderCache.removeResult(finderPath, finderArgs);
4925    
4926                                    throw processException(e);
4927                            }
4928                            finally {
4929                                    closeSession(session);
4930                            }
4931                    }
4932    
4933                    return count.intValue();
4934            }
4935    
4936            /**
4937             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4938             *
4939             * @param groupId the group ID
4940             * @param status the status
4941             * @return the number of matching blogs entries that the user has permission to view
4942             */
4943            @Override
4944            public int filterCountByG_S(long groupId, int status) {
4945                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4946                            return countByG_S(groupId, status);
4947                    }
4948    
4949                    StringBundler query = new StringBundler(3);
4950    
4951                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4952    
4953                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4954    
4955                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4956    
4957                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4958                                    BlogsEntry.class.getName(),
4959                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4960    
4961                    Session session = null;
4962    
4963                    try {
4964                            session = openSession();
4965    
4966                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4967    
4968                            q.addScalar(COUNT_COLUMN_NAME,
4969                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4970    
4971                            QueryPos qPos = QueryPos.getInstance(q);
4972    
4973                            qPos.add(groupId);
4974    
4975                            qPos.add(status);
4976    
4977                            Long count = (Long)q.uniqueResult();
4978    
4979                            return count.intValue();
4980                    }
4981                    catch (Exception e) {
4982                            throw processException(e);
4983                    }
4984                    finally {
4985                            closeSession(session);
4986                    }
4987            }
4988    
4989            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4990            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
4991            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4992                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4993                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
4994                            new String[] {
4995                                    Long.class.getName(), Integer.class.getName(),
4996                                    
4997                            Integer.class.getName(), Integer.class.getName(),
4998                                    OrderByComparator.class.getName()
4999                            });
5000            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5001                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5002                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
5003                            new String[] { Long.class.getName(), Integer.class.getName() });
5004    
5005            /**
5006             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5007             *
5008             * @param groupId the group ID
5009             * @param status the status
5010             * @return the matching blogs entries
5011             */
5012            @Override
5013            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
5014                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
5015                            QueryUtil.ALL_POS, null);
5016            }
5017    
5018            /**
5019             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5020             *
5021             * <p>
5022             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5023             * </p>
5024             *
5025             * @param groupId the group ID
5026             * @param status the status
5027             * @param start the lower bound of the range of blogs entries
5028             * @param end the upper bound of the range of blogs entries (not inclusive)
5029             * @return the range of matching blogs entries
5030             */
5031            @Override
5032            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5033                    int end) {
5034                    return findByG_NotS(groupId, status, start, end, null);
5035            }
5036    
5037            /**
5038             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5039             *
5040             * <p>
5041             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5042             * </p>
5043             *
5044             * @param groupId the group ID
5045             * @param status the status
5046             * @param start the lower bound of the range of blogs entries
5047             * @param end the upper bound of the range of blogs entries (not inclusive)
5048             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5049             * @return the ordered range of matching blogs entries
5050             */
5051            @Override
5052            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5053                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5054                    return findByG_NotS(groupId, status, start, end, orderByComparator, true);
5055            }
5056    
5057            /**
5058             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5059             *
5060             * <p>
5061             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5062             * </p>
5063             *
5064             * @param groupId the group ID
5065             * @param status the status
5066             * @param start the lower bound of the range of blogs entries
5067             * @param end the upper bound of the range of blogs entries (not inclusive)
5068             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5069             * @param retrieveFromCache whether to retrieve from the finder cache
5070             * @return the ordered range of matching blogs entries
5071             */
5072            @Override
5073            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5074                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5075                    boolean retrieveFromCache) {
5076                    boolean pagination = true;
5077                    FinderPath finderPath = null;
5078                    Object[] finderArgs = null;
5079    
5080                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
5081                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
5082    
5083                    List<BlogsEntry> list = null;
5084    
5085                    if (retrieveFromCache) {
5086                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
5087                                            finderArgs, this);
5088    
5089                            if ((list != null) && !list.isEmpty()) {
5090                                    for (BlogsEntry blogsEntry : list) {
5091                                            if ((groupId != blogsEntry.getGroupId()) ||
5092                                                            (status == blogsEntry.getStatus())) {
5093                                                    list = null;
5094    
5095                                                    break;
5096                                            }
5097                                    }
5098                            }
5099                    }
5100    
5101                    if (list == null) {
5102                            StringBundler query = null;
5103    
5104                            if (orderByComparator != null) {
5105                                    query = new StringBundler(4 +
5106                                                    (orderByComparator.getOrderByFields().length * 3));
5107                            }
5108                            else {
5109                                    query = new StringBundler(4);
5110                            }
5111    
5112                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5113    
5114                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5115    
5116                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5117    
5118                            if (orderByComparator != null) {
5119                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5120                                            orderByComparator);
5121                            }
5122                            else
5123                             if (pagination) {
5124                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5125                            }
5126    
5127                            String sql = query.toString();
5128    
5129                            Session session = null;
5130    
5131                            try {
5132                                    session = openSession();
5133    
5134                                    Query q = session.createQuery(sql);
5135    
5136                                    QueryPos qPos = QueryPos.getInstance(q);
5137    
5138                                    qPos.add(groupId);
5139    
5140                                    qPos.add(status);
5141    
5142                                    if (!pagination) {
5143                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5144                                                            start, end, false);
5145    
5146                                            Collections.sort(list);
5147    
5148                                            list = Collections.unmodifiableList(list);
5149                                    }
5150                                    else {
5151                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5152                                                            start, end);
5153                                    }
5154    
5155                                    cacheResult(list);
5156    
5157                                    finderCache.putResult(finderPath, finderArgs, list);
5158                            }
5159                            catch (Exception e) {
5160                                    finderCache.removeResult(finderPath, finderArgs);
5161    
5162                                    throw processException(e);
5163                            }
5164                            finally {
5165                                    closeSession(session);
5166                            }
5167                    }
5168    
5169                    return list;
5170            }
5171    
5172            /**
5173             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5174             *
5175             * @param groupId the group ID
5176             * @param status the status
5177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5178             * @return the first matching blogs entry
5179             * @throws NoSuchEntryException if a matching blogs entry could not be found
5180             */
5181            @Override
5182            public BlogsEntry findByG_NotS_First(long groupId, int status,
5183                    OrderByComparator<BlogsEntry> orderByComparator)
5184                    throws NoSuchEntryException {
5185                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5186                                    orderByComparator);
5187    
5188                    if (blogsEntry != null) {
5189                            return blogsEntry;
5190                    }
5191    
5192                    StringBundler msg = new StringBundler(6);
5193    
5194                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5195    
5196                    msg.append("groupId=");
5197                    msg.append(groupId);
5198    
5199                    msg.append(", status=");
5200                    msg.append(status);
5201    
5202                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5203    
5204                    throw new NoSuchEntryException(msg.toString());
5205            }
5206    
5207            /**
5208             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5209             *
5210             * @param groupId the group ID
5211             * @param status the status
5212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5213             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5214             */
5215            @Override
5216            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5217                    OrderByComparator<BlogsEntry> orderByComparator) {
5218                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5219                                    orderByComparator);
5220    
5221                    if (!list.isEmpty()) {
5222                            return list.get(0);
5223                    }
5224    
5225                    return null;
5226            }
5227    
5228            /**
5229             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5230             *
5231             * @param groupId the group ID
5232             * @param status the status
5233             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5234             * @return the last matching blogs entry
5235             * @throws NoSuchEntryException if a matching blogs entry could not be found
5236             */
5237            @Override
5238            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5239                    OrderByComparator<BlogsEntry> orderByComparator)
5240                    throws NoSuchEntryException {
5241                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5242                                    orderByComparator);
5243    
5244                    if (blogsEntry != null) {
5245                            return blogsEntry;
5246                    }
5247    
5248                    StringBundler msg = new StringBundler(6);
5249    
5250                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5251    
5252                    msg.append("groupId=");
5253                    msg.append(groupId);
5254    
5255                    msg.append(", status=");
5256                    msg.append(status);
5257    
5258                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5259    
5260                    throw new NoSuchEntryException(msg.toString());
5261            }
5262    
5263            /**
5264             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5265             *
5266             * @param groupId the group ID
5267             * @param status the status
5268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5269             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5270             */
5271            @Override
5272            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5273                    OrderByComparator<BlogsEntry> orderByComparator) {
5274                    int count = countByG_NotS(groupId, status);
5275    
5276                    if (count == 0) {
5277                            return null;
5278                    }
5279    
5280                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5281                                    orderByComparator);
5282    
5283                    if (!list.isEmpty()) {
5284                            return list.get(0);
5285                    }
5286    
5287                    return null;
5288            }
5289    
5290            /**
5291             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5292             *
5293             * @param entryId the primary key of the current blogs entry
5294             * @param groupId the group ID
5295             * @param status the status
5296             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5297             * @return the previous, current, and next blogs entry
5298             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5299             */
5300            @Override
5301            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5302                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5303                    throws NoSuchEntryException {
5304                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5305    
5306                    Session session = null;
5307    
5308                    try {
5309                            session = openSession();
5310    
5311                            BlogsEntry[] array = new BlogsEntryImpl[3];
5312    
5313                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5314                                            status, orderByComparator, true);
5315    
5316                            array[1] = blogsEntry;
5317    
5318                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5319                                            status, orderByComparator, false);
5320    
5321                            return array;
5322                    }
5323                    catch (Exception e) {
5324                            throw processException(e);
5325                    }
5326                    finally {
5327                            closeSession(session);
5328                    }
5329            }
5330    
5331            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5332                    BlogsEntry blogsEntry, long groupId, int status,
5333                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5334                    StringBundler query = null;
5335    
5336                    if (orderByComparator != null) {
5337                            query = new StringBundler(6 +
5338                                            (orderByComparator.getOrderByFields().length * 6));
5339                    }
5340                    else {
5341                            query = new StringBundler(3);
5342                    }
5343    
5344                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5345    
5346                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5347    
5348                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5349    
5350                    if (orderByComparator != null) {
5351                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5352    
5353                            if (orderByConditionFields.length > 0) {
5354                                    query.append(WHERE_AND);
5355                            }
5356    
5357                            for (int i = 0; i < orderByConditionFields.length; i++) {
5358                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5359                                    query.append(orderByConditionFields[i]);
5360    
5361                                    if ((i + 1) < orderByConditionFields.length) {
5362                                            if (orderByComparator.isAscending() ^ previous) {
5363                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5364                                            }
5365                                            else {
5366                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5367                                            }
5368                                    }
5369                                    else {
5370                                            if (orderByComparator.isAscending() ^ previous) {
5371                                                    query.append(WHERE_GREATER_THAN);
5372                                            }
5373                                            else {
5374                                                    query.append(WHERE_LESSER_THAN);
5375                                            }
5376                                    }
5377                            }
5378    
5379                            query.append(ORDER_BY_CLAUSE);
5380    
5381                            String[] orderByFields = orderByComparator.getOrderByFields();
5382    
5383                            for (int i = 0; i < orderByFields.length; i++) {
5384                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5385                                    query.append(orderByFields[i]);
5386    
5387                                    if ((i + 1) < orderByFields.length) {
5388                                            if (orderByComparator.isAscending() ^ previous) {
5389                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5390                                            }
5391                                            else {
5392                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5393                                            }
5394                                    }
5395                                    else {
5396                                            if (orderByComparator.isAscending() ^ previous) {
5397                                                    query.append(ORDER_BY_ASC);
5398                                            }
5399                                            else {
5400                                                    query.append(ORDER_BY_DESC);
5401                                            }
5402                                    }
5403                            }
5404                    }
5405                    else {
5406                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5407                    }
5408    
5409                    String sql = query.toString();
5410    
5411                    Query q = session.createQuery(sql);
5412    
5413                    q.setFirstResult(0);
5414                    q.setMaxResults(2);
5415    
5416                    QueryPos qPos = QueryPos.getInstance(q);
5417    
5418                    qPos.add(groupId);
5419    
5420                    qPos.add(status);
5421    
5422                    if (orderByComparator != null) {
5423                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5424    
5425                            for (Object value : values) {
5426                                    qPos.add(value);
5427                            }
5428                    }
5429    
5430                    List<BlogsEntry> list = q.list();
5431    
5432                    if (list.size() == 2) {
5433                            return list.get(1);
5434                    }
5435                    else {
5436                            return null;
5437                    }
5438            }
5439    
5440            /**
5441             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5442             *
5443             * @param groupId the group ID
5444             * @param status the status
5445             * @return the matching blogs entries that the user has permission to view
5446             */
5447            @Override
5448            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5449                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5450                            QueryUtil.ALL_POS, null);
5451            }
5452    
5453            /**
5454             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5455             *
5456             * <p>
5457             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5458             * </p>
5459             *
5460             * @param groupId the group ID
5461             * @param status the status
5462             * @param start the lower bound of the range of blogs entries
5463             * @param end the upper bound of the range of blogs entries (not inclusive)
5464             * @return the range of matching blogs entries that the user has permission to view
5465             */
5466            @Override
5467            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5468                    int start, int end) {
5469                    return filterFindByG_NotS(groupId, status, start, end, null);
5470            }
5471    
5472            /**
5473             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5474             *
5475             * <p>
5476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5477             * </p>
5478             *
5479             * @param groupId the group ID
5480             * @param status the status
5481             * @param start the lower bound of the range of blogs entries
5482             * @param end the upper bound of the range of blogs entries (not inclusive)
5483             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5484             * @return the ordered range of matching blogs entries that the user has permission to view
5485             */
5486            @Override
5487            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5488                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5489                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5490                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5491                    }
5492    
5493                    StringBundler query = null;
5494    
5495                    if (orderByComparator != null) {
5496                            query = new StringBundler(4 +
5497                                            (orderByComparator.getOrderByFields().length * 3));
5498                    }
5499                    else {
5500                            query = new StringBundler(4);
5501                    }
5502    
5503                    if (getDB().isSupportsInlineDistinct()) {
5504                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5505                    }
5506                    else {
5507                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5508                    }
5509    
5510                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5511    
5512                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5513    
5514                    if (!getDB().isSupportsInlineDistinct()) {
5515                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5516                    }
5517    
5518                    if (orderByComparator != null) {
5519                            if (getDB().isSupportsInlineDistinct()) {
5520                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5521                                            orderByComparator, true);
5522                            }
5523                            else {
5524                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5525                                            orderByComparator, true);
5526                            }
5527                    }
5528                    else {
5529                            if (getDB().isSupportsInlineDistinct()) {
5530                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5531                            }
5532                            else {
5533                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5534                            }
5535                    }
5536    
5537                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5538                                    BlogsEntry.class.getName(),
5539                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5540    
5541                    Session session = null;
5542    
5543                    try {
5544                            session = openSession();
5545    
5546                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5547    
5548                            if (getDB().isSupportsInlineDistinct()) {
5549                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5550                            }
5551                            else {
5552                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5553                            }
5554    
5555                            QueryPos qPos = QueryPos.getInstance(q);
5556    
5557                            qPos.add(groupId);
5558    
5559                            qPos.add(status);
5560    
5561                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5562                    }
5563                    catch (Exception e) {
5564                            throw processException(e);
5565                    }
5566                    finally {
5567                            closeSession(session);
5568                    }
5569            }
5570    
5571            /**
5572             * 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;.
5573             *
5574             * @param entryId the primary key of the current blogs entry
5575             * @param groupId the group ID
5576             * @param status the status
5577             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5578             * @return the previous, current, and next blogs entry
5579             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5580             */
5581            @Override
5582            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5583                    long groupId, int status,
5584                    OrderByComparator<BlogsEntry> orderByComparator)
5585                    throws NoSuchEntryException {
5586                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5587                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5588                                    orderByComparator);
5589                    }
5590    
5591                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5592    
5593                    Session session = null;
5594    
5595                    try {
5596                            session = openSession();
5597    
5598                            BlogsEntry[] array = new BlogsEntryImpl[3];
5599    
5600                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5601                                            groupId, status, orderByComparator, true);
5602    
5603                            array[1] = blogsEntry;
5604    
5605                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5606                                            groupId, status, orderByComparator, false);
5607    
5608                            return array;
5609                    }
5610                    catch (Exception e) {
5611                            throw processException(e);
5612                    }
5613                    finally {
5614                            closeSession(session);
5615                    }
5616            }
5617    
5618            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5619                    BlogsEntry blogsEntry, long groupId, int status,
5620                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5621                    StringBundler query = null;
5622    
5623                    if (orderByComparator != null) {
5624                            query = new StringBundler(6 +
5625                                            (orderByComparator.getOrderByFields().length * 6));
5626                    }
5627                    else {
5628                            query = new StringBundler(3);
5629                    }
5630    
5631                    if (getDB().isSupportsInlineDistinct()) {
5632                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5633                    }
5634                    else {
5635                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5636                    }
5637    
5638                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5639    
5640                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5641    
5642                    if (!getDB().isSupportsInlineDistinct()) {
5643                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5644                    }
5645    
5646                    if (orderByComparator != null) {
5647                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5648    
5649                            if (orderByConditionFields.length > 0) {
5650                                    query.append(WHERE_AND);
5651                            }
5652    
5653                            for (int i = 0; i < orderByConditionFields.length; i++) {
5654                                    if (getDB().isSupportsInlineDistinct()) {
5655                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5656                                    }
5657                                    else {
5658                                            query.append(_ORDER_BY_ENTITY_TABLE);
5659                                    }
5660    
5661                                    query.append(orderByConditionFields[i]);
5662    
5663                                    if ((i + 1) < orderByConditionFields.length) {
5664                                            if (orderByComparator.isAscending() ^ previous) {
5665                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5666                                            }
5667                                            else {
5668                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5669                                            }
5670                                    }
5671                                    else {
5672                                            if (orderByComparator.isAscending() ^ previous) {
5673                                                    query.append(WHERE_GREATER_THAN);
5674                                            }
5675                                            else {
5676                                                    query.append(WHERE_LESSER_THAN);
5677                                            }
5678                                    }
5679                            }
5680    
5681                            query.append(ORDER_BY_CLAUSE);
5682    
5683                            String[] orderByFields = orderByComparator.getOrderByFields();
5684    
5685                            for (int i = 0; i < orderByFields.length; i++) {
5686                                    if (getDB().isSupportsInlineDistinct()) {
5687                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5688                                    }
5689                                    else {
5690                                            query.append(_ORDER_BY_ENTITY_TABLE);
5691                                    }
5692    
5693                                    query.append(orderByFields[i]);
5694    
5695                                    if ((i + 1) < orderByFields.length) {
5696                                            if (orderByComparator.isAscending() ^ previous) {
5697                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5698                                            }
5699                                            else {
5700                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5701                                            }
5702                                    }
5703                                    else {
5704                                            if (orderByComparator.isAscending() ^ previous) {
5705                                                    query.append(ORDER_BY_ASC);
5706                                            }
5707                                            else {
5708                                                    query.append(ORDER_BY_DESC);
5709                                            }
5710                                    }
5711                            }
5712                    }
5713                    else {
5714                            if (getDB().isSupportsInlineDistinct()) {
5715                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5716                            }
5717                            else {
5718                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5719                            }
5720                    }
5721    
5722                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5723                                    BlogsEntry.class.getName(),
5724                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5725    
5726                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5727    
5728                    q.setFirstResult(0);
5729                    q.setMaxResults(2);
5730    
5731                    if (getDB().isSupportsInlineDistinct()) {
5732                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5733                    }
5734                    else {
5735                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5736                    }
5737    
5738                    QueryPos qPos = QueryPos.getInstance(q);
5739    
5740                    qPos.add(groupId);
5741    
5742                    qPos.add(status);
5743    
5744                    if (orderByComparator != null) {
5745                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5746    
5747                            for (Object value : values) {
5748                                    qPos.add(value);
5749                            }
5750                    }
5751    
5752                    List<BlogsEntry> list = q.list();
5753    
5754                    if (list.size() == 2) {
5755                            return list.get(1);
5756                    }
5757                    else {
5758                            return null;
5759                    }
5760            }
5761    
5762            /**
5763             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5764             *
5765             * @param groupId the group ID
5766             * @param status the status
5767             */
5768            @Override
5769            public void removeByG_NotS(long groupId, int status) {
5770                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5771                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5772                            remove(blogsEntry);
5773                    }
5774            }
5775    
5776            /**
5777             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5778             *
5779             * @param groupId the group ID
5780             * @param status the status
5781             * @return the number of matching blogs entries
5782             */
5783            @Override
5784            public int countByG_NotS(long groupId, int status) {
5785                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5786    
5787                    Object[] finderArgs = new Object[] { groupId, status };
5788    
5789                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5790    
5791                    if (count == null) {
5792                            StringBundler query = new StringBundler(3);
5793    
5794                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5795    
5796                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5797    
5798                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5799    
5800                            String sql = query.toString();
5801    
5802                            Session session = null;
5803    
5804                            try {
5805                                    session = openSession();
5806    
5807                                    Query q = session.createQuery(sql);
5808    
5809                                    QueryPos qPos = QueryPos.getInstance(q);
5810    
5811                                    qPos.add(groupId);
5812    
5813                                    qPos.add(status);
5814    
5815                                    count = (Long)q.uniqueResult();
5816    
5817                                    finderCache.putResult(finderPath, finderArgs, count);
5818                            }
5819                            catch (Exception e) {
5820                                    finderCache.removeResult(finderPath, finderArgs);
5821    
5822                                    throw processException(e);
5823                            }
5824                            finally {
5825                                    closeSession(session);
5826                            }
5827                    }
5828    
5829                    return count.intValue();
5830            }
5831    
5832            /**
5833             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5834             *
5835             * @param groupId the group ID
5836             * @param status the status
5837             * @return the number of matching blogs entries that the user has permission to view
5838             */
5839            @Override
5840            public int filterCountByG_NotS(long groupId, int status) {
5841                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5842                            return countByG_NotS(groupId, status);
5843                    }
5844    
5845                    StringBundler query = new StringBundler(3);
5846    
5847                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5848    
5849                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5850    
5851                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5852    
5853                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5854                                    BlogsEntry.class.getName(),
5855                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5856    
5857                    Session session = null;
5858    
5859                    try {
5860                            session = openSession();
5861    
5862                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5863    
5864                            q.addScalar(COUNT_COLUMN_NAME,
5865                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5866    
5867                            QueryPos qPos = QueryPos.getInstance(q);
5868    
5869                            qPos.add(groupId);
5870    
5871                            qPos.add(status);
5872    
5873                            Long count = (Long)q.uniqueResult();
5874    
5875                            return count.intValue();
5876                    }
5877                    catch (Exception e) {
5878                            throw processException(e);
5879                    }
5880                    finally {
5881                            closeSession(session);
5882                    }
5883            }
5884    
5885            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5886            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5887            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5888                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5889                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5890                            new String[] {
5891                                    Long.class.getName(), Long.class.getName(),
5892                                    
5893                            Integer.class.getName(), Integer.class.getName(),
5894                                    OrderByComparator.class.getName()
5895                            });
5896            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5897                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5898                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5899                            new String[] { Long.class.getName(), Long.class.getName() },
5900                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5901                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5902                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5903                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5904            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5905                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5906                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5907                            new String[] { Long.class.getName(), Long.class.getName() });
5908    
5909            /**
5910             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5911             *
5912             * @param companyId the company ID
5913             * @param userId the user ID
5914             * @return the matching blogs entries
5915             */
5916            @Override
5917            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5918                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5919                            QueryUtil.ALL_POS, null);
5920            }
5921    
5922            /**
5923             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5924             *
5925             * <p>
5926             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5927             * </p>
5928             *
5929             * @param companyId the company ID
5930             * @param userId the user ID
5931             * @param start the lower bound of the range of blogs entries
5932             * @param end the upper bound of the range of blogs entries (not inclusive)
5933             * @return the range of matching blogs entries
5934             */
5935            @Override
5936            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5937                    int end) {
5938                    return findByC_U(companyId, userId, start, end, null);
5939            }
5940    
5941            /**
5942             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5943             *
5944             * <p>
5945             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5946             * </p>
5947             *
5948             * @param companyId the company ID
5949             * @param userId the user ID
5950             * @param start the lower bound of the range of blogs entries
5951             * @param end the upper bound of the range of blogs entries (not inclusive)
5952             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5953             * @return the ordered range of matching blogs entries
5954             */
5955            @Override
5956            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5957                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5958                    return findByC_U(companyId, userId, start, end, orderByComparator, true);
5959            }
5960    
5961            /**
5962             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5963             *
5964             * <p>
5965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5966             * </p>
5967             *
5968             * @param companyId the company ID
5969             * @param userId the user ID
5970             * @param start the lower bound of the range of blogs entries
5971             * @param end the upper bound of the range of blogs entries (not inclusive)
5972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5973             * @param retrieveFromCache whether to retrieve from the finder cache
5974             * @return the ordered range of matching blogs entries
5975             */
5976            @Override
5977            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5978                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5979                    boolean retrieveFromCache) {
5980                    boolean pagination = true;
5981                    FinderPath finderPath = null;
5982                    Object[] finderArgs = null;
5983    
5984                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5985                                    (orderByComparator == null)) {
5986                            pagination = false;
5987                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
5988                            finderArgs = new Object[] { companyId, userId };
5989                    }
5990                    else {
5991                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
5992                            finderArgs = new Object[] {
5993                                            companyId, userId,
5994                                            
5995                                            start, end, orderByComparator
5996                                    };
5997                    }
5998    
5999                    List<BlogsEntry> list = null;
6000    
6001                    if (retrieveFromCache) {
6002                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6003                                            finderArgs, this);
6004    
6005                            if ((list != null) && !list.isEmpty()) {
6006                                    for (BlogsEntry blogsEntry : list) {
6007                                            if ((companyId != blogsEntry.getCompanyId()) ||
6008                                                            (userId != blogsEntry.getUserId())) {
6009                                                    list = null;
6010    
6011                                                    break;
6012                                            }
6013                                    }
6014                            }
6015                    }
6016    
6017                    if (list == null) {
6018                            StringBundler query = null;
6019    
6020                            if (orderByComparator != null) {
6021                                    query = new StringBundler(4 +
6022                                                    (orderByComparator.getOrderByFields().length * 3));
6023                            }
6024                            else {
6025                                    query = new StringBundler(4);
6026                            }
6027    
6028                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6029    
6030                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6031    
6032                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6033    
6034                            if (orderByComparator != null) {
6035                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6036                                            orderByComparator);
6037                            }
6038                            else
6039                             if (pagination) {
6040                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6041                            }
6042    
6043                            String sql = query.toString();
6044    
6045                            Session session = null;
6046    
6047                            try {
6048                                    session = openSession();
6049    
6050                                    Query q = session.createQuery(sql);
6051    
6052                                    QueryPos qPos = QueryPos.getInstance(q);
6053    
6054                                    qPos.add(companyId);
6055    
6056                                    qPos.add(userId);
6057    
6058                                    if (!pagination) {
6059                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6060                                                            start, end, false);
6061    
6062                                            Collections.sort(list);
6063    
6064                                            list = Collections.unmodifiableList(list);
6065                                    }
6066                                    else {
6067                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6068                                                            start, end);
6069                                    }
6070    
6071                                    cacheResult(list);
6072    
6073                                    finderCache.putResult(finderPath, finderArgs, list);
6074                            }
6075                            catch (Exception e) {
6076                                    finderCache.removeResult(finderPath, finderArgs);
6077    
6078                                    throw processException(e);
6079                            }
6080                            finally {
6081                                    closeSession(session);
6082                            }
6083                    }
6084    
6085                    return list;
6086            }
6087    
6088            /**
6089             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6090             *
6091             * @param companyId the company ID
6092             * @param userId the user ID
6093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6094             * @return the first matching blogs entry
6095             * @throws NoSuchEntryException if a matching blogs entry could not be found
6096             */
6097            @Override
6098            public BlogsEntry findByC_U_First(long companyId, long userId,
6099                    OrderByComparator<BlogsEntry> orderByComparator)
6100                    throws NoSuchEntryException {
6101                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
6102                                    orderByComparator);
6103    
6104                    if (blogsEntry != null) {
6105                            return blogsEntry;
6106                    }
6107    
6108                    StringBundler msg = new StringBundler(6);
6109    
6110                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6111    
6112                    msg.append("companyId=");
6113                    msg.append(companyId);
6114    
6115                    msg.append(", userId=");
6116                    msg.append(userId);
6117    
6118                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6119    
6120                    throw new NoSuchEntryException(msg.toString());
6121            }
6122    
6123            /**
6124             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6125             *
6126             * @param companyId the company ID
6127             * @param userId the user ID
6128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6129             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6130             */
6131            @Override
6132            public BlogsEntry fetchByC_U_First(long companyId, long userId,
6133                    OrderByComparator<BlogsEntry> orderByComparator) {
6134                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
6135                                    orderByComparator);
6136    
6137                    if (!list.isEmpty()) {
6138                            return list.get(0);
6139                    }
6140    
6141                    return null;
6142            }
6143    
6144            /**
6145             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6146             *
6147             * @param companyId the company ID
6148             * @param userId the user ID
6149             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6150             * @return the last matching blogs entry
6151             * @throws NoSuchEntryException if a matching blogs entry could not be found
6152             */
6153            @Override
6154            public BlogsEntry findByC_U_Last(long companyId, long userId,
6155                    OrderByComparator<BlogsEntry> orderByComparator)
6156                    throws NoSuchEntryException {
6157                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
6158                                    orderByComparator);
6159    
6160                    if (blogsEntry != null) {
6161                            return blogsEntry;
6162                    }
6163    
6164                    StringBundler msg = new StringBundler(6);
6165    
6166                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6167    
6168                    msg.append("companyId=");
6169                    msg.append(companyId);
6170    
6171                    msg.append(", userId=");
6172                    msg.append(userId);
6173    
6174                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6175    
6176                    throw new NoSuchEntryException(msg.toString());
6177            }
6178    
6179            /**
6180             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6181             *
6182             * @param companyId the company ID
6183             * @param userId the user ID
6184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6185             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6186             */
6187            @Override
6188            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
6189                    OrderByComparator<BlogsEntry> orderByComparator) {
6190                    int count = countByC_U(companyId, userId);
6191    
6192                    if (count == 0) {
6193                            return null;
6194                    }
6195    
6196                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
6197                                    orderByComparator);
6198    
6199                    if (!list.isEmpty()) {
6200                            return list.get(0);
6201                    }
6202    
6203                    return null;
6204            }
6205    
6206            /**
6207             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6208             *
6209             * @param entryId the primary key of the current blogs entry
6210             * @param companyId the company ID
6211             * @param userId the user ID
6212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6213             * @return the previous, current, and next blogs entry
6214             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6215             */
6216            @Override
6217            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6218                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6219                    throws NoSuchEntryException {
6220                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6221    
6222                    Session session = null;
6223    
6224                    try {
6225                            session = openSession();
6226    
6227                            BlogsEntry[] array = new BlogsEntryImpl[3];
6228    
6229                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6230                                            userId, orderByComparator, true);
6231    
6232                            array[1] = blogsEntry;
6233    
6234                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6235                                            userId, orderByComparator, false);
6236    
6237                            return array;
6238                    }
6239                    catch (Exception e) {
6240                            throw processException(e);
6241                    }
6242                    finally {
6243                            closeSession(session);
6244                    }
6245            }
6246    
6247            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6248                    BlogsEntry blogsEntry, long companyId, long userId,
6249                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6250                    StringBundler query = null;
6251    
6252                    if (orderByComparator != null) {
6253                            query = new StringBundler(6 +
6254                                            (orderByComparator.getOrderByFields().length * 6));
6255                    }
6256                    else {
6257                            query = new StringBundler(3);
6258                    }
6259    
6260                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6261    
6262                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6263    
6264                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6265    
6266                    if (orderByComparator != null) {
6267                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6268    
6269                            if (orderByConditionFields.length > 0) {
6270                                    query.append(WHERE_AND);
6271                            }
6272    
6273                            for (int i = 0; i < orderByConditionFields.length; i++) {
6274                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6275                                    query.append(orderByConditionFields[i]);
6276    
6277                                    if ((i + 1) < orderByConditionFields.length) {
6278                                            if (orderByComparator.isAscending() ^ previous) {
6279                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6280                                            }
6281                                            else {
6282                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6283                                            }
6284                                    }
6285                                    else {
6286                                            if (orderByComparator.isAscending() ^ previous) {
6287                                                    query.append(WHERE_GREATER_THAN);
6288                                            }
6289                                            else {
6290                                                    query.append(WHERE_LESSER_THAN);
6291                                            }
6292                                    }
6293                            }
6294    
6295                            query.append(ORDER_BY_CLAUSE);
6296    
6297                            String[] orderByFields = orderByComparator.getOrderByFields();
6298    
6299                            for (int i = 0; i < orderByFields.length; i++) {
6300                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6301                                    query.append(orderByFields[i]);
6302    
6303                                    if ((i + 1) < orderByFields.length) {
6304                                            if (orderByComparator.isAscending() ^ previous) {
6305                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6306                                            }
6307                                            else {
6308                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6309                                            }
6310                                    }
6311                                    else {
6312                                            if (orderByComparator.isAscending() ^ previous) {
6313                                                    query.append(ORDER_BY_ASC);
6314                                            }
6315                                            else {
6316                                                    query.append(ORDER_BY_DESC);
6317                                            }
6318                                    }
6319                            }
6320                    }
6321                    else {
6322                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6323                    }
6324    
6325                    String sql = query.toString();
6326    
6327                    Query q = session.createQuery(sql);
6328    
6329                    q.setFirstResult(0);
6330                    q.setMaxResults(2);
6331    
6332                    QueryPos qPos = QueryPos.getInstance(q);
6333    
6334                    qPos.add(companyId);
6335    
6336                    qPos.add(userId);
6337    
6338                    if (orderByComparator != null) {
6339                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6340    
6341                            for (Object value : values) {
6342                                    qPos.add(value);
6343                            }
6344                    }
6345    
6346                    List<BlogsEntry> list = q.list();
6347    
6348                    if (list.size() == 2) {
6349                            return list.get(1);
6350                    }
6351                    else {
6352                            return null;
6353                    }
6354            }
6355    
6356            /**
6357             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6358             *
6359             * @param companyId the company ID
6360             * @param userId the user ID
6361             */
6362            @Override
6363            public void removeByC_U(long companyId, long userId) {
6364                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6365                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6366                            remove(blogsEntry);
6367                    }
6368            }
6369    
6370            /**
6371             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6372             *
6373             * @param companyId the company ID
6374             * @param userId the user ID
6375             * @return the number of matching blogs entries
6376             */
6377            @Override
6378            public int countByC_U(long companyId, long userId) {
6379                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6380    
6381                    Object[] finderArgs = new Object[] { companyId, userId };
6382    
6383                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6384    
6385                    if (count == null) {
6386                            StringBundler query = new StringBundler(3);
6387    
6388                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6389    
6390                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6391    
6392                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6393    
6394                            String sql = query.toString();
6395    
6396                            Session session = null;
6397    
6398                            try {
6399                                    session = openSession();
6400    
6401                                    Query q = session.createQuery(sql);
6402    
6403                                    QueryPos qPos = QueryPos.getInstance(q);
6404    
6405                                    qPos.add(companyId);
6406    
6407                                    qPos.add(userId);
6408    
6409                                    count = (Long)q.uniqueResult();
6410    
6411                                    finderCache.putResult(finderPath, finderArgs, count);
6412                            }
6413                            catch (Exception e) {
6414                                    finderCache.removeResult(finderPath, finderArgs);
6415    
6416                                    throw processException(e);
6417                            }
6418                            finally {
6419                                    closeSession(session);
6420                            }
6421                    }
6422    
6423                    return count.intValue();
6424            }
6425    
6426            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6427            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6428            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6429                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6430                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6431                            new String[] {
6432                                    Long.class.getName(), Date.class.getName(),
6433                                    
6434                            Integer.class.getName(), Integer.class.getName(),
6435                                    OrderByComparator.class.getName()
6436                            });
6437            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6438                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6439                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6440                            new String[] { Long.class.getName(), Date.class.getName() });
6441    
6442            /**
6443             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6444             *
6445             * @param companyId the company ID
6446             * @param displayDate the display date
6447             * @return the matching blogs entries
6448             */
6449            @Override
6450            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6451                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6452                            QueryUtil.ALL_POS, null);
6453            }
6454    
6455            /**
6456             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6457             *
6458             * <p>
6459             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6460             * </p>
6461             *
6462             * @param companyId the company ID
6463             * @param displayDate the display date
6464             * @param start the lower bound of the range of blogs entries
6465             * @param end the upper bound of the range of blogs entries (not inclusive)
6466             * @return the range of matching blogs entries
6467             */
6468            @Override
6469            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6470                    int start, int end) {
6471                    return findByC_LtD(companyId, displayDate, start, end, null);
6472            }
6473    
6474            /**
6475             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6476             *
6477             * <p>
6478             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6479             * </p>
6480             *
6481             * @param companyId the company ID
6482             * @param displayDate the display date
6483             * @param start the lower bound of the range of blogs entries
6484             * @param end the upper bound of the range of blogs entries (not inclusive)
6485             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6486             * @return the ordered range of matching blogs entries
6487             */
6488            @Override
6489            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6490                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6491                    return findByC_LtD(companyId, displayDate, start, end,
6492                            orderByComparator, true);
6493            }
6494    
6495            /**
6496             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6497             *
6498             * <p>
6499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6500             * </p>
6501             *
6502             * @param companyId the company ID
6503             * @param displayDate the display date
6504             * @param start the lower bound of the range of blogs entries
6505             * @param end the upper bound of the range of blogs entries (not inclusive)
6506             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6507             * @param retrieveFromCache whether to retrieve from the finder cache
6508             * @return the ordered range of matching blogs entries
6509             */
6510            @Override
6511            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6512                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
6513                    boolean retrieveFromCache) {
6514                    boolean pagination = true;
6515                    FinderPath finderPath = null;
6516                    Object[] finderArgs = null;
6517    
6518                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6519                    finderArgs = new Object[] {
6520                                    companyId, displayDate,
6521                                    
6522                                    start, end, orderByComparator
6523                            };
6524    
6525                    List<BlogsEntry> list = null;
6526    
6527                    if (retrieveFromCache) {
6528                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6529                                            finderArgs, this);
6530    
6531                            if ((list != null) && !list.isEmpty()) {
6532                                    for (BlogsEntry blogsEntry : list) {
6533                                            if ((companyId != blogsEntry.getCompanyId()) ||
6534                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
6535                                                                                                                                            .getTime())) {
6536                                                    list = null;
6537    
6538                                                    break;
6539                                            }
6540                                    }
6541                            }
6542                    }
6543    
6544                    if (list == null) {
6545                            StringBundler query = null;
6546    
6547                            if (orderByComparator != null) {
6548                                    query = new StringBundler(4 +
6549                                                    (orderByComparator.getOrderByFields().length * 3));
6550                            }
6551                            else {
6552                                    query = new StringBundler(4);
6553                            }
6554    
6555                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6556    
6557                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6558    
6559                            boolean bindDisplayDate = false;
6560    
6561                            if (displayDate == null) {
6562                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6563                            }
6564                            else {
6565                                    bindDisplayDate = true;
6566    
6567                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6568                            }
6569    
6570                            if (orderByComparator != null) {
6571                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6572                                            orderByComparator);
6573                            }
6574                            else
6575                             if (pagination) {
6576                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6577                            }
6578    
6579                            String sql = query.toString();
6580    
6581                            Session session = null;
6582    
6583                            try {
6584                                    session = openSession();
6585    
6586                                    Query q = session.createQuery(sql);
6587    
6588                                    QueryPos qPos = QueryPos.getInstance(q);
6589    
6590                                    qPos.add(companyId);
6591    
6592                                    if (bindDisplayDate) {
6593                                            qPos.add(new Timestamp(displayDate.getTime()));
6594                                    }
6595    
6596                                    if (!pagination) {
6597                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6598                                                            start, end, false);
6599    
6600                                            Collections.sort(list);
6601    
6602                                            list = Collections.unmodifiableList(list);
6603                                    }
6604                                    else {
6605                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6606                                                            start, end);
6607                                    }
6608    
6609                                    cacheResult(list);
6610    
6611                                    finderCache.putResult(finderPath, finderArgs, list);
6612                            }
6613                            catch (Exception e) {
6614                                    finderCache.removeResult(finderPath, finderArgs);
6615    
6616                                    throw processException(e);
6617                            }
6618                            finally {
6619                                    closeSession(session);
6620                            }
6621                    }
6622    
6623                    return list;
6624            }
6625    
6626            /**
6627             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6628             *
6629             * @param companyId the company ID
6630             * @param displayDate the display date
6631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6632             * @return the first matching blogs entry
6633             * @throws NoSuchEntryException if a matching blogs entry could not be found
6634             */
6635            @Override
6636            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6637                    OrderByComparator<BlogsEntry> orderByComparator)
6638                    throws NoSuchEntryException {
6639                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6640                                    orderByComparator);
6641    
6642                    if (blogsEntry != null) {
6643                            return blogsEntry;
6644                    }
6645    
6646                    StringBundler msg = new StringBundler(6);
6647    
6648                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6649    
6650                    msg.append("companyId=");
6651                    msg.append(companyId);
6652    
6653                    msg.append(", displayDate=");
6654                    msg.append(displayDate);
6655    
6656                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6657    
6658                    throw new NoSuchEntryException(msg.toString());
6659            }
6660    
6661            /**
6662             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6663             *
6664             * @param companyId the company ID
6665             * @param displayDate the display date
6666             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6667             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6668             */
6669            @Override
6670            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6671                    OrderByComparator<BlogsEntry> orderByComparator) {
6672                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6673                                    orderByComparator);
6674    
6675                    if (!list.isEmpty()) {
6676                            return list.get(0);
6677                    }
6678    
6679                    return null;
6680            }
6681    
6682            /**
6683             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6684             *
6685             * @param companyId the company ID
6686             * @param displayDate the display date
6687             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6688             * @return the last matching blogs entry
6689             * @throws NoSuchEntryException if a matching blogs entry could not be found
6690             */
6691            @Override
6692            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6693                    OrderByComparator<BlogsEntry> orderByComparator)
6694                    throws NoSuchEntryException {
6695                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6696                                    orderByComparator);
6697    
6698                    if (blogsEntry != null) {
6699                            return blogsEntry;
6700                    }
6701    
6702                    StringBundler msg = new StringBundler(6);
6703    
6704                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6705    
6706                    msg.append("companyId=");
6707                    msg.append(companyId);
6708    
6709                    msg.append(", displayDate=");
6710                    msg.append(displayDate);
6711    
6712                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6713    
6714                    throw new NoSuchEntryException(msg.toString());
6715            }
6716    
6717            /**
6718             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6719             *
6720             * @param companyId the company ID
6721             * @param displayDate the display date
6722             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6723             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6724             */
6725            @Override
6726            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6727                    OrderByComparator<BlogsEntry> orderByComparator) {
6728                    int count = countByC_LtD(companyId, displayDate);
6729    
6730                    if (count == 0) {
6731                            return null;
6732                    }
6733    
6734                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6735                                    count, orderByComparator);
6736    
6737                    if (!list.isEmpty()) {
6738                            return list.get(0);
6739                    }
6740    
6741                    return null;
6742            }
6743    
6744            /**
6745             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6746             *
6747             * @param entryId the primary key of the current blogs entry
6748             * @param companyId the company ID
6749             * @param displayDate the display date
6750             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6751             * @return the previous, current, and next blogs entry
6752             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6753             */
6754            @Override
6755            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6756                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6757                    throws NoSuchEntryException {
6758                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6759    
6760                    Session session = null;
6761    
6762                    try {
6763                            session = openSession();
6764    
6765                            BlogsEntry[] array = new BlogsEntryImpl[3];
6766    
6767                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6768                                            displayDate, orderByComparator, true);
6769    
6770                            array[1] = blogsEntry;
6771    
6772                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6773                                            displayDate, orderByComparator, false);
6774    
6775                            return array;
6776                    }
6777                    catch (Exception e) {
6778                            throw processException(e);
6779                    }
6780                    finally {
6781                            closeSession(session);
6782                    }
6783            }
6784    
6785            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6786                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6787                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6788                    StringBundler query = null;
6789    
6790                    if (orderByComparator != null) {
6791                            query = new StringBundler(6 +
6792                                            (orderByComparator.getOrderByFields().length * 6));
6793                    }
6794                    else {
6795                            query = new StringBundler(3);
6796                    }
6797    
6798                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6799    
6800                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6801    
6802                    boolean bindDisplayDate = false;
6803    
6804                    if (displayDate == null) {
6805                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6806                    }
6807                    else {
6808                            bindDisplayDate = true;
6809    
6810                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6811                    }
6812    
6813                    if (orderByComparator != null) {
6814                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6815    
6816                            if (orderByConditionFields.length > 0) {
6817                                    query.append(WHERE_AND);
6818                            }
6819    
6820                            for (int i = 0; i < orderByConditionFields.length; i++) {
6821                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6822                                    query.append(orderByConditionFields[i]);
6823    
6824                                    if ((i + 1) < orderByConditionFields.length) {
6825                                            if (orderByComparator.isAscending() ^ previous) {
6826                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6827                                            }
6828                                            else {
6829                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6830                                            }
6831                                    }
6832                                    else {
6833                                            if (orderByComparator.isAscending() ^ previous) {
6834                                                    query.append(WHERE_GREATER_THAN);
6835                                            }
6836                                            else {
6837                                                    query.append(WHERE_LESSER_THAN);
6838                                            }
6839                                    }
6840                            }
6841    
6842                            query.append(ORDER_BY_CLAUSE);
6843    
6844                            String[] orderByFields = orderByComparator.getOrderByFields();
6845    
6846                            for (int i = 0; i < orderByFields.length; i++) {
6847                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6848                                    query.append(orderByFields[i]);
6849    
6850                                    if ((i + 1) < orderByFields.length) {
6851                                            if (orderByComparator.isAscending() ^ previous) {
6852                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6853                                            }
6854                                            else {
6855                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6856                                            }
6857                                    }
6858                                    else {
6859                                            if (orderByComparator.isAscending() ^ previous) {
6860                                                    query.append(ORDER_BY_ASC);
6861                                            }
6862                                            else {
6863                                                    query.append(ORDER_BY_DESC);
6864                                            }
6865                                    }
6866                            }
6867                    }
6868                    else {
6869                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6870                    }
6871    
6872                    String sql = query.toString();
6873    
6874                    Query q = session.createQuery(sql);
6875    
6876                    q.setFirstResult(0);
6877                    q.setMaxResults(2);
6878    
6879                    QueryPos qPos = QueryPos.getInstance(q);
6880    
6881                    qPos.add(companyId);
6882    
6883                    if (bindDisplayDate) {
6884                            qPos.add(new Timestamp(displayDate.getTime()));
6885                    }
6886    
6887                    if (orderByComparator != null) {
6888                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6889    
6890                            for (Object value : values) {
6891                                    qPos.add(value);
6892                            }
6893                    }
6894    
6895                    List<BlogsEntry> list = q.list();
6896    
6897                    if (list.size() == 2) {
6898                            return list.get(1);
6899                    }
6900                    else {
6901                            return null;
6902                    }
6903            }
6904    
6905            /**
6906             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6907             *
6908             * @param companyId the company ID
6909             * @param displayDate the display date
6910             */
6911            @Override
6912            public void removeByC_LtD(long companyId, Date displayDate) {
6913                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6914                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6915                            remove(blogsEntry);
6916                    }
6917            }
6918    
6919            /**
6920             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6921             *
6922             * @param companyId the company ID
6923             * @param displayDate the display date
6924             * @return the number of matching blogs entries
6925             */
6926            @Override
6927            public int countByC_LtD(long companyId, Date displayDate) {
6928                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6929    
6930                    Object[] finderArgs = new Object[] { companyId, displayDate };
6931    
6932                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6933    
6934                    if (count == null) {
6935                            StringBundler query = new StringBundler(3);
6936    
6937                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6938    
6939                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6940    
6941                            boolean bindDisplayDate = false;
6942    
6943                            if (displayDate == null) {
6944                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6945                            }
6946                            else {
6947                                    bindDisplayDate = true;
6948    
6949                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6950                            }
6951    
6952                            String sql = query.toString();
6953    
6954                            Session session = null;
6955    
6956                            try {
6957                                    session = openSession();
6958    
6959                                    Query q = session.createQuery(sql);
6960    
6961                                    QueryPos qPos = QueryPos.getInstance(q);
6962    
6963                                    qPos.add(companyId);
6964    
6965                                    if (bindDisplayDate) {
6966                                            qPos.add(new Timestamp(displayDate.getTime()));
6967                                    }
6968    
6969                                    count = (Long)q.uniqueResult();
6970    
6971                                    finderCache.putResult(finderPath, finderArgs, count);
6972                            }
6973                            catch (Exception e) {
6974                                    finderCache.removeResult(finderPath, finderArgs);
6975    
6976                                    throw processException(e);
6977                            }
6978                            finally {
6979                                    closeSession(session);
6980                            }
6981                    }
6982    
6983                    return count.intValue();
6984            }
6985    
6986            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6987            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
6988            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
6989            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6990                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6991                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
6992                            new String[] {
6993                                    Long.class.getName(), Integer.class.getName(),
6994                                    
6995                            Integer.class.getName(), Integer.class.getName(),
6996                                    OrderByComparator.class.getName()
6997                            });
6998            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6999                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7000                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
7001                            new String[] { Long.class.getName(), Integer.class.getName() },
7002                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
7003                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
7004                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
7005                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
7006            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7007                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7008                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
7009                            new String[] { Long.class.getName(), Integer.class.getName() });
7010    
7011            /**
7012             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
7013             *
7014             * @param companyId the company ID
7015             * @param status the status
7016             * @return the matching blogs entries
7017             */
7018            @Override
7019            public List<BlogsEntry> findByC_S(long companyId, int status) {
7020                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
7021                            QueryUtil.ALL_POS, null);
7022            }
7023    
7024            /**
7025             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
7026             *
7027             * <p>
7028             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7029             * </p>
7030             *
7031             * @param companyId the company ID
7032             * @param status the status
7033             * @param start the lower bound of the range of blogs entries
7034             * @param end the upper bound of the range of blogs entries (not inclusive)
7035             * @return the range of matching blogs entries
7036             */
7037            @Override
7038            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7039                    int end) {
7040                    return findByC_S(companyId, status, start, end, null);
7041            }
7042    
7043            /**
7044             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7045             *
7046             * <p>
7047             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7048             * </p>
7049             *
7050             * @param companyId the company ID
7051             * @param status the status
7052             * @param start the lower bound of the range of blogs entries
7053             * @param end the upper bound of the range of blogs entries (not inclusive)
7054             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7055             * @return the ordered range of matching blogs entries
7056             */
7057            @Override
7058            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7059                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7060                    return findByC_S(companyId, status, start, end, orderByComparator, true);
7061            }
7062    
7063            /**
7064             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7065             *
7066             * <p>
7067             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7068             * </p>
7069             *
7070             * @param companyId the company ID
7071             * @param status the status
7072             * @param start the lower bound of the range of blogs entries
7073             * @param end the upper bound of the range of blogs entries (not inclusive)
7074             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7075             * @param retrieveFromCache whether to retrieve from the finder cache
7076             * @return the ordered range of matching blogs entries
7077             */
7078            @Override
7079            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7080                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7081                    boolean retrieveFromCache) {
7082                    boolean pagination = true;
7083                    FinderPath finderPath = null;
7084                    Object[] finderArgs = null;
7085    
7086                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7087                                    (orderByComparator == null)) {
7088                            pagination = false;
7089                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
7090                            finderArgs = new Object[] { companyId, status };
7091                    }
7092                    else {
7093                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
7094                            finderArgs = new Object[] {
7095                                            companyId, status,
7096                                            
7097                                            start, end, orderByComparator
7098                                    };
7099                    }
7100    
7101                    List<BlogsEntry> list = null;
7102    
7103                    if (retrieveFromCache) {
7104                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7105                                            finderArgs, this);
7106    
7107                            if ((list != null) && !list.isEmpty()) {
7108                                    for (BlogsEntry blogsEntry : list) {
7109                                            if ((companyId != blogsEntry.getCompanyId()) ||
7110                                                            (status != blogsEntry.getStatus())) {
7111                                                    list = null;
7112    
7113                                                    break;
7114                                            }
7115                                    }
7116                            }
7117                    }
7118    
7119                    if (list == null) {
7120                            StringBundler query = null;
7121    
7122                            if (orderByComparator != null) {
7123                                    query = new StringBundler(4 +
7124                                                    (orderByComparator.getOrderByFields().length * 3));
7125                            }
7126                            else {
7127                                    query = new StringBundler(4);
7128                            }
7129    
7130                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7131    
7132                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7133    
7134                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7135    
7136                            if (orderByComparator != null) {
7137                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7138                                            orderByComparator);
7139                            }
7140                            else
7141                             if (pagination) {
7142                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7143                            }
7144    
7145                            String sql = query.toString();
7146    
7147                            Session session = null;
7148    
7149                            try {
7150                                    session = openSession();
7151    
7152                                    Query q = session.createQuery(sql);
7153    
7154                                    QueryPos qPos = QueryPos.getInstance(q);
7155    
7156                                    qPos.add(companyId);
7157    
7158                                    qPos.add(status);
7159    
7160                                    if (!pagination) {
7161                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7162                                                            start, end, false);
7163    
7164                                            Collections.sort(list);
7165    
7166                                            list = Collections.unmodifiableList(list);
7167                                    }
7168                                    else {
7169                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7170                                                            start, end);
7171                                    }
7172    
7173                                    cacheResult(list);
7174    
7175                                    finderCache.putResult(finderPath, finderArgs, list);
7176                            }
7177                            catch (Exception e) {
7178                                    finderCache.removeResult(finderPath, finderArgs);
7179    
7180                                    throw processException(e);
7181                            }
7182                            finally {
7183                                    closeSession(session);
7184                            }
7185                    }
7186    
7187                    return list;
7188            }
7189    
7190            /**
7191             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7192             *
7193             * @param companyId the company ID
7194             * @param status the status
7195             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7196             * @return the first matching blogs entry
7197             * @throws NoSuchEntryException if a matching blogs entry could not be found
7198             */
7199            @Override
7200            public BlogsEntry findByC_S_First(long companyId, int status,
7201                    OrderByComparator<BlogsEntry> orderByComparator)
7202                    throws NoSuchEntryException {
7203                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
7204                                    orderByComparator);
7205    
7206                    if (blogsEntry != null) {
7207                            return blogsEntry;
7208                    }
7209    
7210                    StringBundler msg = new StringBundler(6);
7211    
7212                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7213    
7214                    msg.append("companyId=");
7215                    msg.append(companyId);
7216    
7217                    msg.append(", status=");
7218                    msg.append(status);
7219    
7220                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7221    
7222                    throw new NoSuchEntryException(msg.toString());
7223            }
7224    
7225            /**
7226             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7227             *
7228             * @param companyId the company ID
7229             * @param status the status
7230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7231             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7232             */
7233            @Override
7234            public BlogsEntry fetchByC_S_First(long companyId, int status,
7235                    OrderByComparator<BlogsEntry> orderByComparator) {
7236                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
7237                                    orderByComparator);
7238    
7239                    if (!list.isEmpty()) {
7240                            return list.get(0);
7241                    }
7242    
7243                    return null;
7244            }
7245    
7246            /**
7247             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7248             *
7249             * @param companyId the company ID
7250             * @param status the status
7251             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7252             * @return the last matching blogs entry
7253             * @throws NoSuchEntryException if a matching blogs entry could not be found
7254             */
7255            @Override
7256            public BlogsEntry findByC_S_Last(long companyId, int status,
7257                    OrderByComparator<BlogsEntry> orderByComparator)
7258                    throws NoSuchEntryException {
7259                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7260                                    orderByComparator);
7261    
7262                    if (blogsEntry != null) {
7263                            return blogsEntry;
7264                    }
7265    
7266                    StringBundler msg = new StringBundler(6);
7267    
7268                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7269    
7270                    msg.append("companyId=");
7271                    msg.append(companyId);
7272    
7273                    msg.append(", status=");
7274                    msg.append(status);
7275    
7276                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7277    
7278                    throw new NoSuchEntryException(msg.toString());
7279            }
7280    
7281            /**
7282             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7283             *
7284             * @param companyId the company ID
7285             * @param status the status
7286             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7287             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7288             */
7289            @Override
7290            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7291                    OrderByComparator<BlogsEntry> orderByComparator) {
7292                    int count = countByC_S(companyId, status);
7293    
7294                    if (count == 0) {
7295                            return null;
7296                    }
7297    
7298                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7299                                    orderByComparator);
7300    
7301                    if (!list.isEmpty()) {
7302                            return list.get(0);
7303                    }
7304    
7305                    return null;
7306            }
7307    
7308            /**
7309             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7310             *
7311             * @param entryId the primary key of the current blogs entry
7312             * @param companyId the company ID
7313             * @param status the status
7314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7315             * @return the previous, current, and next blogs entry
7316             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7317             */
7318            @Override
7319            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7320                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7321                    throws NoSuchEntryException {
7322                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7323    
7324                    Session session = null;
7325    
7326                    try {
7327                            session = openSession();
7328    
7329                            BlogsEntry[] array = new BlogsEntryImpl[3];
7330    
7331                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7332                                            status, orderByComparator, true);
7333    
7334                            array[1] = blogsEntry;
7335    
7336                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7337                                            status, orderByComparator, false);
7338    
7339                            return array;
7340                    }
7341                    catch (Exception e) {
7342                            throw processException(e);
7343                    }
7344                    finally {
7345                            closeSession(session);
7346                    }
7347            }
7348    
7349            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7350                    BlogsEntry blogsEntry, long companyId, int status,
7351                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7352                    StringBundler query = null;
7353    
7354                    if (orderByComparator != null) {
7355                            query = new StringBundler(6 +
7356                                            (orderByComparator.getOrderByFields().length * 6));
7357                    }
7358                    else {
7359                            query = new StringBundler(3);
7360                    }
7361    
7362                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7363    
7364                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7365    
7366                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7367    
7368                    if (orderByComparator != null) {
7369                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7370    
7371                            if (orderByConditionFields.length > 0) {
7372                                    query.append(WHERE_AND);
7373                            }
7374    
7375                            for (int i = 0; i < orderByConditionFields.length; i++) {
7376                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7377                                    query.append(orderByConditionFields[i]);
7378    
7379                                    if ((i + 1) < orderByConditionFields.length) {
7380                                            if (orderByComparator.isAscending() ^ previous) {
7381                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7382                                            }
7383                                            else {
7384                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7385                                            }
7386                                    }
7387                                    else {
7388                                            if (orderByComparator.isAscending() ^ previous) {
7389                                                    query.append(WHERE_GREATER_THAN);
7390                                            }
7391                                            else {
7392                                                    query.append(WHERE_LESSER_THAN);
7393                                            }
7394                                    }
7395                            }
7396    
7397                            query.append(ORDER_BY_CLAUSE);
7398    
7399                            String[] orderByFields = orderByComparator.getOrderByFields();
7400    
7401                            for (int i = 0; i < orderByFields.length; i++) {
7402                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7403                                    query.append(orderByFields[i]);
7404    
7405                                    if ((i + 1) < orderByFields.length) {
7406                                            if (orderByComparator.isAscending() ^ previous) {
7407                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7408                                            }
7409                                            else {
7410                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7411                                            }
7412                                    }
7413                                    else {
7414                                            if (orderByComparator.isAscending() ^ previous) {
7415                                                    query.append(ORDER_BY_ASC);
7416                                            }
7417                                            else {
7418                                                    query.append(ORDER_BY_DESC);
7419                                            }
7420                                    }
7421                            }
7422                    }
7423                    else {
7424                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7425                    }
7426    
7427                    String sql = query.toString();
7428    
7429                    Query q = session.createQuery(sql);
7430    
7431                    q.setFirstResult(0);
7432                    q.setMaxResults(2);
7433    
7434                    QueryPos qPos = QueryPos.getInstance(q);
7435    
7436                    qPos.add(companyId);
7437    
7438                    qPos.add(status);
7439    
7440                    if (orderByComparator != null) {
7441                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7442    
7443                            for (Object value : values) {
7444                                    qPos.add(value);
7445                            }
7446                    }
7447    
7448                    List<BlogsEntry> list = q.list();
7449    
7450                    if (list.size() == 2) {
7451                            return list.get(1);
7452                    }
7453                    else {
7454                            return null;
7455                    }
7456            }
7457    
7458            /**
7459             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7460             *
7461             * @param companyId the company ID
7462             * @param status the status
7463             */
7464            @Override
7465            public void removeByC_S(long companyId, int status) {
7466                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7467                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7468                            remove(blogsEntry);
7469                    }
7470            }
7471    
7472            /**
7473             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7474             *
7475             * @param companyId the company ID
7476             * @param status the status
7477             * @return the number of matching blogs entries
7478             */
7479            @Override
7480            public int countByC_S(long companyId, int status) {
7481                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7482    
7483                    Object[] finderArgs = new Object[] { companyId, status };
7484    
7485                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7486    
7487                    if (count == null) {
7488                            StringBundler query = new StringBundler(3);
7489    
7490                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7491    
7492                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7493    
7494                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7495    
7496                            String sql = query.toString();
7497    
7498                            Session session = null;
7499    
7500                            try {
7501                                    session = openSession();
7502    
7503                                    Query q = session.createQuery(sql);
7504    
7505                                    QueryPos qPos = QueryPos.getInstance(q);
7506    
7507                                    qPos.add(companyId);
7508    
7509                                    qPos.add(status);
7510    
7511                                    count = (Long)q.uniqueResult();
7512    
7513                                    finderCache.putResult(finderPath, finderArgs, count);
7514                            }
7515                            catch (Exception e) {
7516                                    finderCache.removeResult(finderPath, finderArgs);
7517    
7518                                    throw processException(e);
7519                            }
7520                            finally {
7521                                    closeSession(session);
7522                            }
7523                    }
7524    
7525                    return count.intValue();
7526            }
7527    
7528            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7529            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7530            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7531                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7532                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7533                            new String[] {
7534                                    Long.class.getName(), Integer.class.getName(),
7535                                    
7536                            Integer.class.getName(), Integer.class.getName(),
7537                                    OrderByComparator.class.getName()
7538                            });
7539            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7540                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7541                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7542                            new String[] { Long.class.getName(), Integer.class.getName() });
7543    
7544            /**
7545             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7546             *
7547             * @param companyId the company ID
7548             * @param status the status
7549             * @return the matching blogs entries
7550             */
7551            @Override
7552            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7553                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7554                            QueryUtil.ALL_POS, null);
7555            }
7556    
7557            /**
7558             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7559             *
7560             * <p>
7561             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7562             * </p>
7563             *
7564             * @param companyId the company ID
7565             * @param status the status
7566             * @param start the lower bound of the range of blogs entries
7567             * @param end the upper bound of the range of blogs entries (not inclusive)
7568             * @return the range of matching blogs entries
7569             */
7570            @Override
7571            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7572                    int end) {
7573                    return findByC_NotS(companyId, status, start, end, null);
7574            }
7575    
7576            /**
7577             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7578             *
7579             * <p>
7580             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7581             * </p>
7582             *
7583             * @param companyId the company ID
7584             * @param status the status
7585             * @param start the lower bound of the range of blogs entries
7586             * @param end the upper bound of the range of blogs entries (not inclusive)
7587             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7588             * @return the ordered range of matching blogs entries
7589             */
7590            @Override
7591            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7592                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7593                    return findByC_NotS(companyId, status, start, end, orderByComparator,
7594                            true);
7595            }
7596    
7597            /**
7598             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7599             *
7600             * <p>
7601             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7602             * </p>
7603             *
7604             * @param companyId the company ID
7605             * @param status the status
7606             * @param start the lower bound of the range of blogs entries
7607             * @param end the upper bound of the range of blogs entries (not inclusive)
7608             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7609             * @param retrieveFromCache whether to retrieve from the finder cache
7610             * @return the ordered range of matching blogs entries
7611             */
7612            @Override
7613            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7614                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7615                    boolean retrieveFromCache) {
7616                    boolean pagination = true;
7617                    FinderPath finderPath = null;
7618                    Object[] finderArgs = null;
7619    
7620                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7621                    finderArgs = new Object[] {
7622                                    companyId, status,
7623                                    
7624                                    start, end, orderByComparator
7625                            };
7626    
7627                    List<BlogsEntry> list = null;
7628    
7629                    if (retrieveFromCache) {
7630                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7631                                            finderArgs, this);
7632    
7633                            if ((list != null) && !list.isEmpty()) {
7634                                    for (BlogsEntry blogsEntry : list) {
7635                                            if ((companyId != blogsEntry.getCompanyId()) ||
7636                                                            (status == blogsEntry.getStatus())) {
7637                                                    list = null;
7638    
7639                                                    break;
7640                                            }
7641                                    }
7642                            }
7643                    }
7644    
7645                    if (list == null) {
7646                            StringBundler query = null;
7647    
7648                            if (orderByComparator != null) {
7649                                    query = new StringBundler(4 +
7650                                                    (orderByComparator.getOrderByFields().length * 3));
7651                            }
7652                            else {
7653                                    query = new StringBundler(4);
7654                            }
7655    
7656                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7657    
7658                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7659    
7660                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7661    
7662                            if (orderByComparator != null) {
7663                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7664                                            orderByComparator);
7665                            }
7666                            else
7667                             if (pagination) {
7668                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7669                            }
7670    
7671                            String sql = query.toString();
7672    
7673                            Session session = null;
7674    
7675                            try {
7676                                    session = openSession();
7677    
7678                                    Query q = session.createQuery(sql);
7679    
7680                                    QueryPos qPos = QueryPos.getInstance(q);
7681    
7682                                    qPos.add(companyId);
7683    
7684                                    qPos.add(status);
7685    
7686                                    if (!pagination) {
7687                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7688                                                            start, end, false);
7689    
7690                                            Collections.sort(list);
7691    
7692                                            list = Collections.unmodifiableList(list);
7693                                    }
7694                                    else {
7695                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7696                                                            start, end);
7697                                    }
7698    
7699                                    cacheResult(list);
7700    
7701                                    finderCache.putResult(finderPath, finderArgs, list);
7702                            }
7703                            catch (Exception e) {
7704                                    finderCache.removeResult(finderPath, finderArgs);
7705    
7706                                    throw processException(e);
7707                            }
7708                            finally {
7709                                    closeSession(session);
7710                            }
7711                    }
7712    
7713                    return list;
7714            }
7715    
7716            /**
7717             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7718             *
7719             * @param companyId the company ID
7720             * @param status the status
7721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7722             * @return the first matching blogs entry
7723             * @throws NoSuchEntryException if a matching blogs entry could not be found
7724             */
7725            @Override
7726            public BlogsEntry findByC_NotS_First(long companyId, int status,
7727                    OrderByComparator<BlogsEntry> orderByComparator)
7728                    throws NoSuchEntryException {
7729                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7730                                    orderByComparator);
7731    
7732                    if (blogsEntry != null) {
7733                            return blogsEntry;
7734                    }
7735    
7736                    StringBundler msg = new StringBundler(6);
7737    
7738                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7739    
7740                    msg.append("companyId=");
7741                    msg.append(companyId);
7742    
7743                    msg.append(", status=");
7744                    msg.append(status);
7745    
7746                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7747    
7748                    throw new NoSuchEntryException(msg.toString());
7749            }
7750    
7751            /**
7752             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7753             *
7754             * @param companyId the company ID
7755             * @param status the status
7756             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7757             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7758             */
7759            @Override
7760            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7761                    OrderByComparator<BlogsEntry> orderByComparator) {
7762                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7763                                    orderByComparator);
7764    
7765                    if (!list.isEmpty()) {
7766                            return list.get(0);
7767                    }
7768    
7769                    return null;
7770            }
7771    
7772            /**
7773             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7774             *
7775             * @param companyId the company ID
7776             * @param status the status
7777             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7778             * @return the last matching blogs entry
7779             * @throws NoSuchEntryException if a matching blogs entry could not be found
7780             */
7781            @Override
7782            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7783                    OrderByComparator<BlogsEntry> orderByComparator)
7784                    throws NoSuchEntryException {
7785                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7786                                    orderByComparator);
7787    
7788                    if (blogsEntry != null) {
7789                            return blogsEntry;
7790                    }
7791    
7792                    StringBundler msg = new StringBundler(6);
7793    
7794                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7795    
7796                    msg.append("companyId=");
7797                    msg.append(companyId);
7798    
7799                    msg.append(", status=");
7800                    msg.append(status);
7801    
7802                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7803    
7804                    throw new NoSuchEntryException(msg.toString());
7805            }
7806    
7807            /**
7808             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7809             *
7810             * @param companyId the company ID
7811             * @param status the status
7812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7813             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7814             */
7815            @Override
7816            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7817                    OrderByComparator<BlogsEntry> orderByComparator) {
7818                    int count = countByC_NotS(companyId, status);
7819    
7820                    if (count == 0) {
7821                            return null;
7822                    }
7823    
7824                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7825                                    count, orderByComparator);
7826    
7827                    if (!list.isEmpty()) {
7828                            return list.get(0);
7829                    }
7830    
7831                    return null;
7832            }
7833    
7834            /**
7835             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7836             *
7837             * @param entryId the primary key of the current blogs entry
7838             * @param companyId the company ID
7839             * @param status the status
7840             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7841             * @return the previous, current, and next blogs entry
7842             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7843             */
7844            @Override
7845            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7846                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7847                    throws NoSuchEntryException {
7848                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7849    
7850                    Session session = null;
7851    
7852                    try {
7853                            session = openSession();
7854    
7855                            BlogsEntry[] array = new BlogsEntryImpl[3];
7856    
7857                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7858                                            status, orderByComparator, true);
7859    
7860                            array[1] = blogsEntry;
7861    
7862                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7863                                            status, orderByComparator, false);
7864    
7865                            return array;
7866                    }
7867                    catch (Exception e) {
7868                            throw processException(e);
7869                    }
7870                    finally {
7871                            closeSession(session);
7872                    }
7873            }
7874    
7875            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7876                    BlogsEntry blogsEntry, long companyId, int status,
7877                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7878                    StringBundler query = null;
7879    
7880                    if (orderByComparator != null) {
7881                            query = new StringBundler(6 +
7882                                            (orderByComparator.getOrderByFields().length * 6));
7883                    }
7884                    else {
7885                            query = new StringBundler(3);
7886                    }
7887    
7888                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7889    
7890                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7891    
7892                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7893    
7894                    if (orderByComparator != null) {
7895                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7896    
7897                            if (orderByConditionFields.length > 0) {
7898                                    query.append(WHERE_AND);
7899                            }
7900    
7901                            for (int i = 0; i < orderByConditionFields.length; i++) {
7902                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7903                                    query.append(orderByConditionFields[i]);
7904    
7905                                    if ((i + 1) < orderByConditionFields.length) {
7906                                            if (orderByComparator.isAscending() ^ previous) {
7907                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7908                                            }
7909                                            else {
7910                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7911                                            }
7912                                    }
7913                                    else {
7914                                            if (orderByComparator.isAscending() ^ previous) {
7915                                                    query.append(WHERE_GREATER_THAN);
7916                                            }
7917                                            else {
7918                                                    query.append(WHERE_LESSER_THAN);
7919                                            }
7920                                    }
7921                            }
7922    
7923                            query.append(ORDER_BY_CLAUSE);
7924    
7925                            String[] orderByFields = orderByComparator.getOrderByFields();
7926    
7927                            for (int i = 0; i < orderByFields.length; i++) {
7928                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7929                                    query.append(orderByFields[i]);
7930    
7931                                    if ((i + 1) < orderByFields.length) {
7932                                            if (orderByComparator.isAscending() ^ previous) {
7933                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7934                                            }
7935                                            else {
7936                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7937                                            }
7938                                    }
7939                                    else {
7940                                            if (orderByComparator.isAscending() ^ previous) {
7941                                                    query.append(ORDER_BY_ASC);
7942                                            }
7943                                            else {
7944                                                    query.append(ORDER_BY_DESC);
7945                                            }
7946                                    }
7947                            }
7948                    }
7949                    else {
7950                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7951                    }
7952    
7953                    String sql = query.toString();
7954    
7955                    Query q = session.createQuery(sql);
7956    
7957                    q.setFirstResult(0);
7958                    q.setMaxResults(2);
7959    
7960                    QueryPos qPos = QueryPos.getInstance(q);
7961    
7962                    qPos.add(companyId);
7963    
7964                    qPos.add(status);
7965    
7966                    if (orderByComparator != null) {
7967                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7968    
7969                            for (Object value : values) {
7970                                    qPos.add(value);
7971                            }
7972                    }
7973    
7974                    List<BlogsEntry> list = q.list();
7975    
7976                    if (list.size() == 2) {
7977                            return list.get(1);
7978                    }
7979                    else {
7980                            return null;
7981                    }
7982            }
7983    
7984            /**
7985             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
7986             *
7987             * @param companyId the company ID
7988             * @param status the status
7989             */
7990            @Override
7991            public void removeByC_NotS(long companyId, int status) {
7992                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
7993                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7994                            remove(blogsEntry);
7995                    }
7996            }
7997    
7998            /**
7999             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
8000             *
8001             * @param companyId the company ID
8002             * @param status the status
8003             * @return the number of matching blogs entries
8004             */
8005            @Override
8006            public int countByC_NotS(long companyId, int status) {
8007                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
8008    
8009                    Object[] finderArgs = new Object[] { companyId, status };
8010    
8011                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8012    
8013                    if (count == null) {
8014                            StringBundler query = new StringBundler(3);
8015    
8016                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8017    
8018                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
8019    
8020                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
8021    
8022                            String sql = query.toString();
8023    
8024                            Session session = null;
8025    
8026                            try {
8027                                    session = openSession();
8028    
8029                                    Query q = session.createQuery(sql);
8030    
8031                                    QueryPos qPos = QueryPos.getInstance(q);
8032    
8033                                    qPos.add(companyId);
8034    
8035                                    qPos.add(status);
8036    
8037                                    count = (Long)q.uniqueResult();
8038    
8039                                    finderCache.putResult(finderPath, finderArgs, count);
8040                            }
8041                            catch (Exception e) {
8042                                    finderCache.removeResult(finderPath, finderArgs);
8043    
8044                                    throw processException(e);
8045                            }
8046                            finally {
8047                                    closeSession(session);
8048                            }
8049                    }
8050    
8051                    return count.intValue();
8052            }
8053    
8054            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8055            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
8056            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8057                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8058                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
8059                            new String[] {
8060                                    Date.class.getName(), Integer.class.getName(),
8061                                    
8062                            Integer.class.getName(), Integer.class.getName(),
8063                                    OrderByComparator.class.getName()
8064                            });
8065            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8066                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8067                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
8068                            new String[] { Date.class.getName(), Integer.class.getName() });
8069    
8070            /**
8071             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8072             *
8073             * @param displayDate the display date
8074             * @param status the status
8075             * @return the matching blogs entries
8076             */
8077            @Override
8078            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
8079                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
8080                            QueryUtil.ALL_POS, null);
8081            }
8082    
8083            /**
8084             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8085             *
8086             * <p>
8087             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8088             * </p>
8089             *
8090             * @param displayDate the display date
8091             * @param status the status
8092             * @param start the lower bound of the range of blogs entries
8093             * @param end the upper bound of the range of blogs entries (not inclusive)
8094             * @return the range of matching blogs entries
8095             */
8096            @Override
8097            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8098                    int start, int end) {
8099                    return findByLtD_S(displayDate, status, start, end, null);
8100            }
8101    
8102            /**
8103             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8104             *
8105             * <p>
8106             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8107             * </p>
8108             *
8109             * @param displayDate the display date
8110             * @param status the status
8111             * @param start the lower bound of the range of blogs entries
8112             * @param end the upper bound of the range of blogs entries (not inclusive)
8113             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8114             * @return the ordered range of matching blogs entries
8115             */
8116            @Override
8117            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8118                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
8119                    return findByLtD_S(displayDate, status, start, end, orderByComparator,
8120                            true);
8121            }
8122    
8123            /**
8124             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8125             *
8126             * <p>
8127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8128             * </p>
8129             *
8130             * @param displayDate the display date
8131             * @param status the status
8132             * @param start the lower bound of the range of blogs entries
8133             * @param end the upper bound of the range of blogs entries (not inclusive)
8134             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8135             * @param retrieveFromCache whether to retrieve from the finder cache
8136             * @return the ordered range of matching blogs entries
8137             */
8138            @Override
8139            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8140                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
8141                    boolean retrieveFromCache) {
8142                    boolean pagination = true;
8143                    FinderPath finderPath = null;
8144                    Object[] finderArgs = null;
8145    
8146                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
8147                    finderArgs = new Object[] {
8148                                    displayDate, status,
8149                                    
8150                                    start, end, orderByComparator
8151                            };
8152    
8153                    List<BlogsEntry> list = null;
8154    
8155                    if (retrieveFromCache) {
8156                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8157                                            finderArgs, this);
8158    
8159                            if ((list != null) && !list.isEmpty()) {
8160                                    for (BlogsEntry blogsEntry : list) {
8161                                            if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
8162                                                                                                                                    .getTime()) ||
8163                                                            (status != blogsEntry.getStatus())) {
8164                                                    list = null;
8165    
8166                                                    break;
8167                                            }
8168                                    }
8169                            }
8170                    }
8171    
8172                    if (list == null) {
8173                            StringBundler query = null;
8174    
8175                            if (orderByComparator != null) {
8176                                    query = new StringBundler(4 +
8177                                                    (orderByComparator.getOrderByFields().length * 3));
8178                            }
8179                            else {
8180                                    query = new StringBundler(4);
8181                            }
8182    
8183                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8184    
8185                            boolean bindDisplayDate = false;
8186    
8187                            if (displayDate == null) {
8188                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8189                            }
8190                            else {
8191                                    bindDisplayDate = true;
8192    
8193                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8194                            }
8195    
8196                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8197    
8198                            if (orderByComparator != null) {
8199                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8200                                            orderByComparator);
8201                            }
8202                            else
8203                             if (pagination) {
8204                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8205                            }
8206    
8207                            String sql = query.toString();
8208    
8209                            Session session = null;
8210    
8211                            try {
8212                                    session = openSession();
8213    
8214                                    Query q = session.createQuery(sql);
8215    
8216                                    QueryPos qPos = QueryPos.getInstance(q);
8217    
8218                                    if (bindDisplayDate) {
8219                                            qPos.add(new Timestamp(displayDate.getTime()));
8220                                    }
8221    
8222                                    qPos.add(status);
8223    
8224                                    if (!pagination) {
8225                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8226                                                            start, end, false);
8227    
8228                                            Collections.sort(list);
8229    
8230                                            list = Collections.unmodifiableList(list);
8231                                    }
8232                                    else {
8233                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8234                                                            start, end);
8235                                    }
8236    
8237                                    cacheResult(list);
8238    
8239                                    finderCache.putResult(finderPath, finderArgs, list);
8240                            }
8241                            catch (Exception e) {
8242                                    finderCache.removeResult(finderPath, finderArgs);
8243    
8244                                    throw processException(e);
8245                            }
8246                            finally {
8247                                    closeSession(session);
8248                            }
8249                    }
8250    
8251                    return list;
8252            }
8253    
8254            /**
8255             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8256             *
8257             * @param displayDate the display date
8258             * @param status the status
8259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8260             * @return the first matching blogs entry
8261             * @throws NoSuchEntryException if a matching blogs entry could not be found
8262             */
8263            @Override
8264            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8265                    OrderByComparator<BlogsEntry> orderByComparator)
8266                    throws NoSuchEntryException {
8267                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8268                                    orderByComparator);
8269    
8270                    if (blogsEntry != null) {
8271                            return blogsEntry;
8272                    }
8273    
8274                    StringBundler msg = new StringBundler(6);
8275    
8276                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8277    
8278                    msg.append("displayDate=");
8279                    msg.append(displayDate);
8280    
8281                    msg.append(", status=");
8282                    msg.append(status);
8283    
8284                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8285    
8286                    throw new NoSuchEntryException(msg.toString());
8287            }
8288    
8289            /**
8290             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8291             *
8292             * @param displayDate the display date
8293             * @param status the status
8294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8295             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8296             */
8297            @Override
8298            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8299                    OrderByComparator<BlogsEntry> orderByComparator) {
8300                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8301                                    orderByComparator);
8302    
8303                    if (!list.isEmpty()) {
8304                            return list.get(0);
8305                    }
8306    
8307                    return null;
8308            }
8309    
8310            /**
8311             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8312             *
8313             * @param displayDate the display date
8314             * @param status the status
8315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8316             * @return the last matching blogs entry
8317             * @throws NoSuchEntryException if a matching blogs entry could not be found
8318             */
8319            @Override
8320            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8321                    OrderByComparator<BlogsEntry> orderByComparator)
8322                    throws NoSuchEntryException {
8323                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8324                                    orderByComparator);
8325    
8326                    if (blogsEntry != null) {
8327                            return blogsEntry;
8328                    }
8329    
8330                    StringBundler msg = new StringBundler(6);
8331    
8332                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8333    
8334                    msg.append("displayDate=");
8335                    msg.append(displayDate);
8336    
8337                    msg.append(", status=");
8338                    msg.append(status);
8339    
8340                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8341    
8342                    throw new NoSuchEntryException(msg.toString());
8343            }
8344    
8345            /**
8346             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8347             *
8348             * @param displayDate the display date
8349             * @param status the status
8350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8351             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8352             */
8353            @Override
8354            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8355                    OrderByComparator<BlogsEntry> orderByComparator) {
8356                    int count = countByLtD_S(displayDate, status);
8357    
8358                    if (count == 0) {
8359                            return null;
8360                    }
8361    
8362                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8363                                    count, orderByComparator);
8364    
8365                    if (!list.isEmpty()) {
8366                            return list.get(0);
8367                    }
8368    
8369                    return null;
8370            }
8371    
8372            /**
8373             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8374             *
8375             * @param entryId the primary key of the current blogs entry
8376             * @param displayDate the display date
8377             * @param status the status
8378             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8379             * @return the previous, current, and next blogs entry
8380             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8381             */
8382            @Override
8383            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8384                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8385                    throws NoSuchEntryException {
8386                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8387    
8388                    Session session = null;
8389    
8390                    try {
8391                            session = openSession();
8392    
8393                            BlogsEntry[] array = new BlogsEntryImpl[3];
8394    
8395                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8396                                            status, orderByComparator, true);
8397    
8398                            array[1] = blogsEntry;
8399    
8400                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8401                                            status, orderByComparator, false);
8402    
8403                            return array;
8404                    }
8405                    catch (Exception e) {
8406                            throw processException(e);
8407                    }
8408                    finally {
8409                            closeSession(session);
8410                    }
8411            }
8412    
8413            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8414                    BlogsEntry blogsEntry, Date displayDate, int status,
8415                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8416                    StringBundler query = null;
8417    
8418                    if (orderByComparator != null) {
8419                            query = new StringBundler(6 +
8420                                            (orderByComparator.getOrderByFields().length * 6));
8421                    }
8422                    else {
8423                            query = new StringBundler(3);
8424                    }
8425    
8426                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8427    
8428                    boolean bindDisplayDate = false;
8429    
8430                    if (displayDate == null) {
8431                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8432                    }
8433                    else {
8434                            bindDisplayDate = true;
8435    
8436                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8437                    }
8438    
8439                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8440    
8441                    if (orderByComparator != null) {
8442                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8443    
8444                            if (orderByConditionFields.length > 0) {
8445                                    query.append(WHERE_AND);
8446                            }
8447    
8448                            for (int i = 0; i < orderByConditionFields.length; i++) {
8449                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8450                                    query.append(orderByConditionFields[i]);
8451    
8452                                    if ((i + 1) < orderByConditionFields.length) {
8453                                            if (orderByComparator.isAscending() ^ previous) {
8454                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8455                                            }
8456                                            else {
8457                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8458                                            }
8459                                    }
8460                                    else {
8461                                            if (orderByComparator.isAscending() ^ previous) {
8462                                                    query.append(WHERE_GREATER_THAN);
8463                                            }
8464                                            else {
8465                                                    query.append(WHERE_LESSER_THAN);
8466                                            }
8467                                    }
8468                            }
8469    
8470                            query.append(ORDER_BY_CLAUSE);
8471    
8472                            String[] orderByFields = orderByComparator.getOrderByFields();
8473    
8474                            for (int i = 0; i < orderByFields.length; i++) {
8475                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8476                                    query.append(orderByFields[i]);
8477    
8478                                    if ((i + 1) < orderByFields.length) {
8479                                            if (orderByComparator.isAscending() ^ previous) {
8480                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8481                                            }
8482                                            else {
8483                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8484                                            }
8485                                    }
8486                                    else {
8487                                            if (orderByComparator.isAscending() ^ previous) {
8488                                                    query.append(ORDER_BY_ASC);
8489                                            }
8490                                            else {
8491                                                    query.append(ORDER_BY_DESC);
8492                                            }
8493                                    }
8494                            }
8495                    }
8496                    else {
8497                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8498                    }
8499    
8500                    String sql = query.toString();
8501    
8502                    Query q = session.createQuery(sql);
8503    
8504                    q.setFirstResult(0);
8505                    q.setMaxResults(2);
8506    
8507                    QueryPos qPos = QueryPos.getInstance(q);
8508    
8509                    if (bindDisplayDate) {
8510                            qPos.add(new Timestamp(displayDate.getTime()));
8511                    }
8512    
8513                    qPos.add(status);
8514    
8515                    if (orderByComparator != null) {
8516                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8517    
8518                            for (Object value : values) {
8519                                    qPos.add(value);
8520                            }
8521                    }
8522    
8523                    List<BlogsEntry> list = q.list();
8524    
8525                    if (list.size() == 2) {
8526                            return list.get(1);
8527                    }
8528                    else {
8529                            return null;
8530                    }
8531            }
8532    
8533            /**
8534             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8535             *
8536             * @param displayDate the display date
8537             * @param status the status
8538             */
8539            @Override
8540            public void removeByLtD_S(Date displayDate, int status) {
8541                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8542                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8543                            remove(blogsEntry);
8544                    }
8545            }
8546    
8547            /**
8548             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8549             *
8550             * @param displayDate the display date
8551             * @param status the status
8552             * @return the number of matching blogs entries
8553             */
8554            @Override
8555            public int countByLtD_S(Date displayDate, int status) {
8556                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8557    
8558                    Object[] finderArgs = new Object[] { displayDate, status };
8559    
8560                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8561    
8562                    if (count == null) {
8563                            StringBundler query = new StringBundler(3);
8564    
8565                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8566    
8567                            boolean bindDisplayDate = false;
8568    
8569                            if (displayDate == null) {
8570                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8571                            }
8572                            else {
8573                                    bindDisplayDate = true;
8574    
8575                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8576                            }
8577    
8578                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8579    
8580                            String sql = query.toString();
8581    
8582                            Session session = null;
8583    
8584                            try {
8585                                    session = openSession();
8586    
8587                                    Query q = session.createQuery(sql);
8588    
8589                                    QueryPos qPos = QueryPos.getInstance(q);
8590    
8591                                    if (bindDisplayDate) {
8592                                            qPos.add(new Timestamp(displayDate.getTime()));
8593                                    }
8594    
8595                                    qPos.add(status);
8596    
8597                                    count = (Long)q.uniqueResult();
8598    
8599                                    finderCache.putResult(finderPath, finderArgs, count);
8600                            }
8601                            catch (Exception e) {
8602                                    finderCache.removeResult(finderPath, finderArgs);
8603    
8604                                    throw processException(e);
8605                            }
8606                            finally {
8607                                    closeSession(session);
8608                            }
8609                    }
8610    
8611                    return count.intValue();
8612            }
8613    
8614            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
8615            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8616            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8617            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8618                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8619                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8620                            new String[] {
8621                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8622                                    
8623                            Integer.class.getName(), Integer.class.getName(),
8624                                    OrderByComparator.class.getName()
8625                            });
8626            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8627                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8628                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8629                            new String[] {
8630                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8631                            });
8632    
8633            /**
8634             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8635             *
8636             * @param groupId the group ID
8637             * @param userId the user ID
8638             * @param displayDate the display date
8639             * @return the matching blogs entries
8640             */
8641            @Override
8642            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8643                    Date displayDate) {
8644                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8645                            QueryUtil.ALL_POS, null);
8646            }
8647    
8648            /**
8649             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8650             *
8651             * <p>
8652             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8653             * </p>
8654             *
8655             * @param groupId the group ID
8656             * @param userId the user ID
8657             * @param displayDate the display date
8658             * @param start the lower bound of the range of blogs entries
8659             * @param end the upper bound of the range of blogs entries (not inclusive)
8660             * @return the range of matching blogs entries
8661             */
8662            @Override
8663            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8664                    Date displayDate, int start, int end) {
8665                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8666            }
8667    
8668            /**
8669             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8670             *
8671             * <p>
8672             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8673             * </p>
8674             *
8675             * @param groupId the group ID
8676             * @param userId the user ID
8677             * @param displayDate the display date
8678             * @param start the lower bound of the range of blogs entries
8679             * @param end the upper bound of the range of blogs entries (not inclusive)
8680             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8681             * @return the ordered range of matching blogs entries
8682             */
8683            @Override
8684            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8685                    Date displayDate, int start, int end,
8686                    OrderByComparator<BlogsEntry> orderByComparator) {
8687                    return findByG_U_LtD(groupId, userId, displayDate, start, end,
8688                            orderByComparator, true);
8689            }
8690    
8691            /**
8692             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8693             *
8694             * <p>
8695             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8696             * </p>
8697             *
8698             * @param groupId the group ID
8699             * @param userId the user ID
8700             * @param displayDate the display date
8701             * @param start the lower bound of the range of blogs entries
8702             * @param end the upper bound of the range of blogs entries (not inclusive)
8703             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8704             * @param retrieveFromCache whether to retrieve from the finder cache
8705             * @return the ordered range of matching blogs entries
8706             */
8707            @Override
8708            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8709                    Date displayDate, int start, int end,
8710                    OrderByComparator<BlogsEntry> orderByComparator,
8711                    boolean retrieveFromCache) {
8712                    boolean pagination = true;
8713                    FinderPath finderPath = null;
8714                    Object[] finderArgs = null;
8715    
8716                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8717                    finderArgs = new Object[] {
8718                                    groupId, userId, displayDate,
8719                                    
8720                                    start, end, orderByComparator
8721                            };
8722    
8723                    List<BlogsEntry> list = null;
8724    
8725                    if (retrieveFromCache) {
8726                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8727                                            finderArgs, this);
8728    
8729                            if ((list != null) && !list.isEmpty()) {
8730                                    for (BlogsEntry blogsEntry : list) {
8731                                            if ((groupId != blogsEntry.getGroupId()) ||
8732                                                            (userId != blogsEntry.getUserId()) ||
8733                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
8734                                                                                                                                            .getTime())) {
8735                                                    list = null;
8736    
8737                                                    break;
8738                                            }
8739                                    }
8740                            }
8741                    }
8742    
8743                    if (list == null) {
8744                            StringBundler query = null;
8745    
8746                            if (orderByComparator != null) {
8747                                    query = new StringBundler(5 +
8748                                                    (orderByComparator.getOrderByFields().length * 3));
8749                            }
8750                            else {
8751                                    query = new StringBundler(5);
8752                            }
8753    
8754                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8755    
8756                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8757    
8758                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8759    
8760                            boolean bindDisplayDate = false;
8761    
8762                            if (displayDate == null) {
8763                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8764                            }
8765                            else {
8766                                    bindDisplayDate = true;
8767    
8768                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8769                            }
8770    
8771                            if (orderByComparator != null) {
8772                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8773                                            orderByComparator);
8774                            }
8775                            else
8776                             if (pagination) {
8777                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8778                            }
8779    
8780                            String sql = query.toString();
8781    
8782                            Session session = null;
8783    
8784                            try {
8785                                    session = openSession();
8786    
8787                                    Query q = session.createQuery(sql);
8788    
8789                                    QueryPos qPos = QueryPos.getInstance(q);
8790    
8791                                    qPos.add(groupId);
8792    
8793                                    qPos.add(userId);
8794    
8795                                    if (bindDisplayDate) {
8796                                            qPos.add(new Timestamp(displayDate.getTime()));
8797                                    }
8798    
8799                                    if (!pagination) {
8800                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8801                                                            start, end, false);
8802    
8803                                            Collections.sort(list);
8804    
8805                                            list = Collections.unmodifiableList(list);
8806                                    }
8807                                    else {
8808                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8809                                                            start, end);
8810                                    }
8811    
8812                                    cacheResult(list);
8813    
8814                                    finderCache.putResult(finderPath, finderArgs, list);
8815                            }
8816                            catch (Exception e) {
8817                                    finderCache.removeResult(finderPath, finderArgs);
8818    
8819                                    throw processException(e);
8820                            }
8821                            finally {
8822                                    closeSession(session);
8823                            }
8824                    }
8825    
8826                    return list;
8827            }
8828    
8829            /**
8830             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8831             *
8832             * @param groupId the group ID
8833             * @param userId the user ID
8834             * @param displayDate the display date
8835             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8836             * @return the first matching blogs entry
8837             * @throws NoSuchEntryException if a matching blogs entry could not be found
8838             */
8839            @Override
8840            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8841                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8842                    throws NoSuchEntryException {
8843                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8844                                    displayDate, orderByComparator);
8845    
8846                    if (blogsEntry != null) {
8847                            return blogsEntry;
8848                    }
8849    
8850                    StringBundler msg = new StringBundler(8);
8851    
8852                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8853    
8854                    msg.append("groupId=");
8855                    msg.append(groupId);
8856    
8857                    msg.append(", userId=");
8858                    msg.append(userId);
8859    
8860                    msg.append(", displayDate=");
8861                    msg.append(displayDate);
8862    
8863                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8864    
8865                    throw new NoSuchEntryException(msg.toString());
8866            }
8867    
8868            /**
8869             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8870             *
8871             * @param groupId the group ID
8872             * @param userId the user ID
8873             * @param displayDate the display date
8874             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8875             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8876             */
8877            @Override
8878            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8879                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8880                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8881                                    1, orderByComparator);
8882    
8883                    if (!list.isEmpty()) {
8884                            return list.get(0);
8885                    }
8886    
8887                    return null;
8888            }
8889    
8890            /**
8891             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8892             *
8893             * @param groupId the group ID
8894             * @param userId the user ID
8895             * @param displayDate the display date
8896             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8897             * @return the last matching blogs entry
8898             * @throws NoSuchEntryException if a matching blogs entry could not be found
8899             */
8900            @Override
8901            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8902                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8903                    throws NoSuchEntryException {
8904                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8905                                    displayDate, orderByComparator);
8906    
8907                    if (blogsEntry != null) {
8908                            return blogsEntry;
8909                    }
8910    
8911                    StringBundler msg = new StringBundler(8);
8912    
8913                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8914    
8915                    msg.append("groupId=");
8916                    msg.append(groupId);
8917    
8918                    msg.append(", userId=");
8919                    msg.append(userId);
8920    
8921                    msg.append(", displayDate=");
8922                    msg.append(displayDate);
8923    
8924                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8925    
8926                    throw new NoSuchEntryException(msg.toString());
8927            }
8928    
8929            /**
8930             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8931             *
8932             * @param groupId the group ID
8933             * @param userId the user ID
8934             * @param displayDate the display date
8935             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8936             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8937             */
8938            @Override
8939            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8940                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8941                    int count = countByG_U_LtD(groupId, userId, displayDate);
8942    
8943                    if (count == 0) {
8944                            return null;
8945                    }
8946    
8947                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8948                                    count - 1, count, orderByComparator);
8949    
8950                    if (!list.isEmpty()) {
8951                            return list.get(0);
8952                    }
8953    
8954                    return null;
8955            }
8956    
8957            /**
8958             * 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;.
8959             *
8960             * @param entryId the primary key of the current blogs entry
8961             * @param groupId the group ID
8962             * @param userId the user ID
8963             * @param displayDate the display date
8964             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8965             * @return the previous, current, and next blogs entry
8966             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8967             */
8968            @Override
8969            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8970                    long userId, Date displayDate,
8971                    OrderByComparator<BlogsEntry> orderByComparator)
8972                    throws NoSuchEntryException {
8973                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8974    
8975                    Session session = null;
8976    
8977                    try {
8978                            session = openSession();
8979    
8980                            BlogsEntry[] array = new BlogsEntryImpl[3];
8981    
8982                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8983                                            userId, displayDate, orderByComparator, true);
8984    
8985                            array[1] = blogsEntry;
8986    
8987                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8988                                            userId, displayDate, orderByComparator, false);
8989    
8990                            return array;
8991                    }
8992                    catch (Exception e) {
8993                            throw processException(e);
8994                    }
8995                    finally {
8996                            closeSession(session);
8997                    }
8998            }
8999    
9000            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
9001                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9002                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9003                    StringBundler query = null;
9004    
9005                    if (orderByComparator != null) {
9006                            query = new StringBundler(6 +
9007                                            (orderByComparator.getOrderByFields().length * 6));
9008                    }
9009                    else {
9010                            query = new StringBundler(3);
9011                    }
9012    
9013                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9014    
9015                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9016    
9017                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9018    
9019                    boolean bindDisplayDate = false;
9020    
9021                    if (displayDate == null) {
9022                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9023                    }
9024                    else {
9025                            bindDisplayDate = true;
9026    
9027                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9028                    }
9029    
9030                    if (orderByComparator != null) {
9031                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9032    
9033                            if (orderByConditionFields.length > 0) {
9034                                    query.append(WHERE_AND);
9035                            }
9036    
9037                            for (int i = 0; i < orderByConditionFields.length; i++) {
9038                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9039                                    query.append(orderByConditionFields[i]);
9040    
9041                                    if ((i + 1) < orderByConditionFields.length) {
9042                                            if (orderByComparator.isAscending() ^ previous) {
9043                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9044                                            }
9045                                            else {
9046                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9047                                            }
9048                                    }
9049                                    else {
9050                                            if (orderByComparator.isAscending() ^ previous) {
9051                                                    query.append(WHERE_GREATER_THAN);
9052                                            }
9053                                            else {
9054                                                    query.append(WHERE_LESSER_THAN);
9055                                            }
9056                                    }
9057                            }
9058    
9059                            query.append(ORDER_BY_CLAUSE);
9060    
9061                            String[] orderByFields = orderByComparator.getOrderByFields();
9062    
9063                            for (int i = 0; i < orderByFields.length; i++) {
9064                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9065                                    query.append(orderByFields[i]);
9066    
9067                                    if ((i + 1) < orderByFields.length) {
9068                                            if (orderByComparator.isAscending() ^ previous) {
9069                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9070                                            }
9071                                            else {
9072                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9073                                            }
9074                                    }
9075                                    else {
9076                                            if (orderByComparator.isAscending() ^ previous) {
9077                                                    query.append(ORDER_BY_ASC);
9078                                            }
9079                                            else {
9080                                                    query.append(ORDER_BY_DESC);
9081                                            }
9082                                    }
9083                            }
9084                    }
9085                    else {
9086                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9087                    }
9088    
9089                    String sql = query.toString();
9090    
9091                    Query q = session.createQuery(sql);
9092    
9093                    q.setFirstResult(0);
9094                    q.setMaxResults(2);
9095    
9096                    QueryPos qPos = QueryPos.getInstance(q);
9097    
9098                    qPos.add(groupId);
9099    
9100                    qPos.add(userId);
9101    
9102                    if (bindDisplayDate) {
9103                            qPos.add(new Timestamp(displayDate.getTime()));
9104                    }
9105    
9106                    if (orderByComparator != null) {
9107                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9108    
9109                            for (Object value : values) {
9110                                    qPos.add(value);
9111                            }
9112                    }
9113    
9114                    List<BlogsEntry> list = q.list();
9115    
9116                    if (list.size() == 2) {
9117                            return list.get(1);
9118                    }
9119                    else {
9120                            return null;
9121                    }
9122            }
9123    
9124            /**
9125             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9126             *
9127             * @param groupId the group ID
9128             * @param userId the user ID
9129             * @param displayDate the display date
9130             * @return the matching blogs entries that the user has permission to view
9131             */
9132            @Override
9133            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9134                    Date displayDate) {
9135                    return filterFindByG_U_LtD(groupId, userId, displayDate,
9136                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9137            }
9138    
9139            /**
9140             * 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;.
9141             *
9142             * <p>
9143             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9144             * </p>
9145             *
9146             * @param groupId the group ID
9147             * @param userId the user ID
9148             * @param displayDate the display date
9149             * @param start the lower bound of the range of blogs entries
9150             * @param end the upper bound of the range of blogs entries (not inclusive)
9151             * @return the range of matching blogs entries that the user has permission to view
9152             */
9153            @Override
9154            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9155                    Date displayDate, int start, int end) {
9156                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
9157                            null);
9158            }
9159    
9160            /**
9161             * 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;.
9162             *
9163             * <p>
9164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9165             * </p>
9166             *
9167             * @param groupId the group ID
9168             * @param userId the user ID
9169             * @param displayDate the display date
9170             * @param start the lower bound of the range of blogs entries
9171             * @param end the upper bound of the range of blogs entries (not inclusive)
9172             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9173             * @return the ordered range of matching blogs entries that the user has permission to view
9174             */
9175            @Override
9176            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9177                    Date displayDate, int start, int end,
9178                    OrderByComparator<BlogsEntry> orderByComparator) {
9179                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9180                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
9181                                    orderByComparator);
9182                    }
9183    
9184                    StringBundler query = null;
9185    
9186                    if (orderByComparator != null) {
9187                            query = new StringBundler(5 +
9188                                            (orderByComparator.getOrderByFields().length * 3));
9189                    }
9190                    else {
9191                            query = new StringBundler(5);
9192                    }
9193    
9194                    if (getDB().isSupportsInlineDistinct()) {
9195                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9196                    }
9197                    else {
9198                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9199                    }
9200    
9201                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9202    
9203                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9204    
9205                    boolean bindDisplayDate = false;
9206    
9207                    if (displayDate == null) {
9208                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9209                    }
9210                    else {
9211                            bindDisplayDate = true;
9212    
9213                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9214                    }
9215    
9216                    if (!getDB().isSupportsInlineDistinct()) {
9217                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9218                    }
9219    
9220                    if (orderByComparator != null) {
9221                            if (getDB().isSupportsInlineDistinct()) {
9222                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9223                                            orderByComparator, true);
9224                            }
9225                            else {
9226                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9227                                            orderByComparator, true);
9228                            }
9229                    }
9230                    else {
9231                            if (getDB().isSupportsInlineDistinct()) {
9232                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9233                            }
9234                            else {
9235                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9236                            }
9237                    }
9238    
9239                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9240                                    BlogsEntry.class.getName(),
9241                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9242    
9243                    Session session = null;
9244    
9245                    try {
9246                            session = openSession();
9247    
9248                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9249    
9250                            if (getDB().isSupportsInlineDistinct()) {
9251                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9252                            }
9253                            else {
9254                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9255                            }
9256    
9257                            QueryPos qPos = QueryPos.getInstance(q);
9258    
9259                            qPos.add(groupId);
9260    
9261                            qPos.add(userId);
9262    
9263                            if (bindDisplayDate) {
9264                                    qPos.add(new Timestamp(displayDate.getTime()));
9265                            }
9266    
9267                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9268                    }
9269                    catch (Exception e) {
9270                            throw processException(e);
9271                    }
9272                    finally {
9273                            closeSession(session);
9274                    }
9275            }
9276    
9277            /**
9278             * 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;.
9279             *
9280             * @param entryId the primary key of the current blogs entry
9281             * @param groupId the group ID
9282             * @param userId the user ID
9283             * @param displayDate the display date
9284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9285             * @return the previous, current, and next blogs entry
9286             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9287             */
9288            @Override
9289            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
9290                    long groupId, long userId, Date displayDate,
9291                    OrderByComparator<BlogsEntry> orderByComparator)
9292                    throws NoSuchEntryException {
9293                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9294                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
9295                                    displayDate, orderByComparator);
9296                    }
9297    
9298                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9299    
9300                    Session session = null;
9301    
9302                    try {
9303                            session = openSession();
9304    
9305                            BlogsEntry[] array = new BlogsEntryImpl[3];
9306    
9307                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9308                                            groupId, userId, displayDate, orderByComparator, true);
9309    
9310                            array[1] = blogsEntry;
9311    
9312                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9313                                            groupId, userId, displayDate, orderByComparator, false);
9314    
9315                            return array;
9316                    }
9317                    catch (Exception e) {
9318                            throw processException(e);
9319                    }
9320                    finally {
9321                            closeSession(session);
9322                    }
9323            }
9324    
9325            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
9326                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9327                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9328                    StringBundler query = null;
9329    
9330                    if (orderByComparator != null) {
9331                            query = new StringBundler(6 +
9332                                            (orderByComparator.getOrderByFields().length * 6));
9333                    }
9334                    else {
9335                            query = new StringBundler(3);
9336                    }
9337    
9338                    if (getDB().isSupportsInlineDistinct()) {
9339                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9340                    }
9341                    else {
9342                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9343                    }
9344    
9345                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9346    
9347                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9348    
9349                    boolean bindDisplayDate = false;
9350    
9351                    if (displayDate == null) {
9352                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9353                    }
9354                    else {
9355                            bindDisplayDate = true;
9356    
9357                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9358                    }
9359    
9360                    if (!getDB().isSupportsInlineDistinct()) {
9361                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9362                    }
9363    
9364                    if (orderByComparator != null) {
9365                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9366    
9367                            if (orderByConditionFields.length > 0) {
9368                                    query.append(WHERE_AND);
9369                            }
9370    
9371                            for (int i = 0; i < orderByConditionFields.length; i++) {
9372                                    if (getDB().isSupportsInlineDistinct()) {
9373                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9374                                    }
9375                                    else {
9376                                            query.append(_ORDER_BY_ENTITY_TABLE);
9377                                    }
9378    
9379                                    query.append(orderByConditionFields[i]);
9380    
9381                                    if ((i + 1) < orderByConditionFields.length) {
9382                                            if (orderByComparator.isAscending() ^ previous) {
9383                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9384                                            }
9385                                            else {
9386                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9387                                            }
9388                                    }
9389                                    else {
9390                                            if (orderByComparator.isAscending() ^ previous) {
9391                                                    query.append(WHERE_GREATER_THAN);
9392                                            }
9393                                            else {
9394                                                    query.append(WHERE_LESSER_THAN);
9395                                            }
9396                                    }
9397                            }
9398    
9399                            query.append(ORDER_BY_CLAUSE);
9400    
9401                            String[] orderByFields = orderByComparator.getOrderByFields();
9402    
9403                            for (int i = 0; i < orderByFields.length; i++) {
9404                                    if (getDB().isSupportsInlineDistinct()) {
9405                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9406                                    }
9407                                    else {
9408                                            query.append(_ORDER_BY_ENTITY_TABLE);
9409                                    }
9410    
9411                                    query.append(orderByFields[i]);
9412    
9413                                    if ((i + 1) < orderByFields.length) {
9414                                            if (orderByComparator.isAscending() ^ previous) {
9415                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9416                                            }
9417                                            else {
9418                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9419                                            }
9420                                    }
9421                                    else {
9422                                            if (orderByComparator.isAscending() ^ previous) {
9423                                                    query.append(ORDER_BY_ASC);
9424                                            }
9425                                            else {
9426                                                    query.append(ORDER_BY_DESC);
9427                                            }
9428                                    }
9429                            }
9430                    }
9431                    else {
9432                            if (getDB().isSupportsInlineDistinct()) {
9433                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9434                            }
9435                            else {
9436                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9437                            }
9438                    }
9439    
9440                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9441                                    BlogsEntry.class.getName(),
9442                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9443    
9444                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9445    
9446                    q.setFirstResult(0);
9447                    q.setMaxResults(2);
9448    
9449                    if (getDB().isSupportsInlineDistinct()) {
9450                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9451                    }
9452                    else {
9453                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9454                    }
9455    
9456                    QueryPos qPos = QueryPos.getInstance(q);
9457    
9458                    qPos.add(groupId);
9459    
9460                    qPos.add(userId);
9461    
9462                    if (bindDisplayDate) {
9463                            qPos.add(new Timestamp(displayDate.getTime()));
9464                    }
9465    
9466                    if (orderByComparator != null) {
9467                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9468    
9469                            for (Object value : values) {
9470                                    qPos.add(value);
9471                            }
9472                    }
9473    
9474                    List<BlogsEntry> list = q.list();
9475    
9476                    if (list.size() == 2) {
9477                            return list.get(1);
9478                    }
9479                    else {
9480                            return null;
9481                    }
9482            }
9483    
9484            /**
9485             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9486             *
9487             * @param groupId the group ID
9488             * @param userId the user ID
9489             * @param displayDate the display date
9490             */
9491            @Override
9492            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9493                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9494                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9495                            remove(blogsEntry);
9496                    }
9497            }
9498    
9499            /**
9500             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9501             *
9502             * @param groupId the group ID
9503             * @param userId the user ID
9504             * @param displayDate the display date
9505             * @return the number of matching blogs entries
9506             */
9507            @Override
9508            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9509                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9510    
9511                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9512    
9513                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9514    
9515                    if (count == null) {
9516                            StringBundler query = new StringBundler(4);
9517    
9518                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9519    
9520                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9521    
9522                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9523    
9524                            boolean bindDisplayDate = false;
9525    
9526                            if (displayDate == null) {
9527                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9528                            }
9529                            else {
9530                                    bindDisplayDate = true;
9531    
9532                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9533                            }
9534    
9535                            String sql = query.toString();
9536    
9537                            Session session = null;
9538    
9539                            try {
9540                                    session = openSession();
9541    
9542                                    Query q = session.createQuery(sql);
9543    
9544                                    QueryPos qPos = QueryPos.getInstance(q);
9545    
9546                                    qPos.add(groupId);
9547    
9548                                    qPos.add(userId);
9549    
9550                                    if (bindDisplayDate) {
9551                                            qPos.add(new Timestamp(displayDate.getTime()));
9552                                    }
9553    
9554                                    count = (Long)q.uniqueResult();
9555    
9556                                    finderCache.putResult(finderPath, finderArgs, count);
9557                            }
9558                            catch (Exception e) {
9559                                    finderCache.removeResult(finderPath, finderArgs);
9560    
9561                                    throw processException(e);
9562                            }
9563                            finally {
9564                                    closeSession(session);
9565                            }
9566                    }
9567    
9568                    return count.intValue();
9569            }
9570    
9571            /**
9572             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9573             *
9574             * @param groupId the group ID
9575             * @param userId the user ID
9576             * @param displayDate the display date
9577             * @return the number of matching blogs entries that the user has permission to view
9578             */
9579            @Override
9580            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9581                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9582                            return countByG_U_LtD(groupId, userId, displayDate);
9583                    }
9584    
9585                    StringBundler query = new StringBundler(4);
9586    
9587                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9588    
9589                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9590    
9591                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9592    
9593                    boolean bindDisplayDate = false;
9594    
9595                    if (displayDate == null) {
9596                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9597                    }
9598                    else {
9599                            bindDisplayDate = true;
9600    
9601                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9602                    }
9603    
9604                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9605                                    BlogsEntry.class.getName(),
9606                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9607    
9608                    Session session = null;
9609    
9610                    try {
9611                            session = openSession();
9612    
9613                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9614    
9615                            q.addScalar(COUNT_COLUMN_NAME,
9616                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9617    
9618                            QueryPos qPos = QueryPos.getInstance(q);
9619    
9620                            qPos.add(groupId);
9621    
9622                            qPos.add(userId);
9623    
9624                            if (bindDisplayDate) {
9625                                    qPos.add(new Timestamp(displayDate.getTime()));
9626                            }
9627    
9628                            Long count = (Long)q.uniqueResult();
9629    
9630                            return count.intValue();
9631                    }
9632                    catch (Exception e) {
9633                            throw processException(e);
9634                    }
9635                    finally {
9636                            closeSession(session);
9637                    }
9638            }
9639    
9640            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9641            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9642            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
9643            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9644            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9645                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9646                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9647                            new String[] {
9648                                    Long.class.getName(), Long.class.getName(),
9649                                    Integer.class.getName(),
9650                                    
9651                            Integer.class.getName(), Integer.class.getName(),
9652                                    OrderByComparator.class.getName()
9653                            });
9654            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9655                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9656                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9657                            new String[] {
9658                                    Long.class.getName(), Long.class.getName(),
9659                                    Integer.class.getName()
9660                            },
9661                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9662                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9663                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9664                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9665                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9666            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9667                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9668                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9669                            new String[] {
9670                                    Long.class.getName(), Long.class.getName(),
9671                                    Integer.class.getName()
9672                            });
9673    
9674            /**
9675             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9676             *
9677             * @param groupId the group ID
9678             * @param userId the user ID
9679             * @param status the status
9680             * @return the matching blogs entries
9681             */
9682            @Override
9683            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9684                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9685                            QueryUtil.ALL_POS, null);
9686            }
9687    
9688            /**
9689             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9690             *
9691             * <p>
9692             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9693             * </p>
9694             *
9695             * @param groupId the group ID
9696             * @param userId the user ID
9697             * @param status the status
9698             * @param start the lower bound of the range of blogs entries
9699             * @param end the upper bound of the range of blogs entries (not inclusive)
9700             * @return the range of matching blogs entries
9701             */
9702            @Override
9703            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9704                    int start, int end) {
9705                    return findByG_U_S(groupId, userId, status, start, end, null);
9706            }
9707    
9708            /**
9709             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9710             *
9711             * <p>
9712             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9713             * </p>
9714             *
9715             * @param groupId the group ID
9716             * @param userId the user ID
9717             * @param status the status
9718             * @param start the lower bound of the range of blogs entries
9719             * @param end the upper bound of the range of blogs entries (not inclusive)
9720             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9721             * @return the ordered range of matching blogs entries
9722             */
9723            @Override
9724            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9725                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9726                    return findByG_U_S(groupId, userId, status, start, end,
9727                            orderByComparator, true);
9728            }
9729    
9730            /**
9731             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9732             *
9733             * <p>
9734             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9735             * </p>
9736             *
9737             * @param groupId the group ID
9738             * @param userId the user ID
9739             * @param status the status
9740             * @param start the lower bound of the range of blogs entries
9741             * @param end the upper bound of the range of blogs entries (not inclusive)
9742             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9743             * @param retrieveFromCache whether to retrieve from the finder cache
9744             * @return the ordered range of matching blogs entries
9745             */
9746            @Override
9747            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9748                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
9749                    boolean retrieveFromCache) {
9750                    boolean pagination = true;
9751                    FinderPath finderPath = null;
9752                    Object[] finderArgs = null;
9753    
9754                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9755                                    (orderByComparator == null)) {
9756                            pagination = false;
9757                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9758                            finderArgs = new Object[] { groupId, userId, status };
9759                    }
9760                    else {
9761                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9762                            finderArgs = new Object[] {
9763                                            groupId, userId, status,
9764                                            
9765                                            start, end, orderByComparator
9766                                    };
9767                    }
9768    
9769                    List<BlogsEntry> list = null;
9770    
9771                    if (retrieveFromCache) {
9772                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
9773                                            finderArgs, this);
9774    
9775                            if ((list != null) && !list.isEmpty()) {
9776                                    for (BlogsEntry blogsEntry : list) {
9777                                            if ((groupId != blogsEntry.getGroupId()) ||
9778                                                            (userId != blogsEntry.getUserId()) ||
9779                                                            (status != blogsEntry.getStatus())) {
9780                                                    list = null;
9781    
9782                                                    break;
9783                                            }
9784                                    }
9785                            }
9786                    }
9787    
9788                    if (list == null) {
9789                            StringBundler query = null;
9790    
9791                            if (orderByComparator != null) {
9792                                    query = new StringBundler(5 +
9793                                                    (orderByComparator.getOrderByFields().length * 3));
9794                            }
9795                            else {
9796                                    query = new StringBundler(5);
9797                            }
9798    
9799                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9800    
9801                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9802    
9803                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9804    
9805                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9806    
9807                            if (orderByComparator != null) {
9808                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9809                                            orderByComparator);
9810                            }
9811                            else
9812                             if (pagination) {
9813                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9814                            }
9815    
9816                            String sql = query.toString();
9817    
9818                            Session session = null;
9819    
9820                            try {
9821                                    session = openSession();
9822    
9823                                    Query q = session.createQuery(sql);
9824    
9825                                    QueryPos qPos = QueryPos.getInstance(q);
9826    
9827                                    qPos.add(groupId);
9828    
9829                                    qPos.add(userId);
9830    
9831                                    qPos.add(status);
9832    
9833                                    if (!pagination) {
9834                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9835                                                            start, end, false);
9836    
9837                                            Collections.sort(list);
9838    
9839                                            list = Collections.unmodifiableList(list);
9840                                    }
9841                                    else {
9842                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9843                                                            start, end);
9844                                    }
9845    
9846                                    cacheResult(list);
9847    
9848                                    finderCache.putResult(finderPath, finderArgs, list);
9849                            }
9850                            catch (Exception e) {
9851                                    finderCache.removeResult(finderPath, finderArgs);
9852    
9853                                    throw processException(e);
9854                            }
9855                            finally {
9856                                    closeSession(session);
9857                            }
9858                    }
9859    
9860                    return list;
9861            }
9862    
9863            /**
9864             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9865             *
9866             * @param groupId the group ID
9867             * @param userId the user ID
9868             * @param status the status
9869             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9870             * @return the first matching blogs entry
9871             * @throws NoSuchEntryException if a matching blogs entry could not be found
9872             */
9873            @Override
9874            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9875                    OrderByComparator<BlogsEntry> orderByComparator)
9876                    throws NoSuchEntryException {
9877                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9878                                    orderByComparator);
9879    
9880                    if (blogsEntry != null) {
9881                            return blogsEntry;
9882                    }
9883    
9884                    StringBundler msg = new StringBundler(8);
9885    
9886                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9887    
9888                    msg.append("groupId=");
9889                    msg.append(groupId);
9890    
9891                    msg.append(", userId=");
9892                    msg.append(userId);
9893    
9894                    msg.append(", status=");
9895                    msg.append(status);
9896    
9897                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9898    
9899                    throw new NoSuchEntryException(msg.toString());
9900            }
9901    
9902            /**
9903             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9904             *
9905             * @param groupId the group ID
9906             * @param userId the user ID
9907             * @param status the status
9908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9909             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9910             */
9911            @Override
9912            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9913                    OrderByComparator<BlogsEntry> orderByComparator) {
9914                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9915                                    orderByComparator);
9916    
9917                    if (!list.isEmpty()) {
9918                            return list.get(0);
9919                    }
9920    
9921                    return null;
9922            }
9923    
9924            /**
9925             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9926             *
9927             * @param groupId the group ID
9928             * @param userId the user ID
9929             * @param status the status
9930             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9931             * @return the last matching blogs entry
9932             * @throws NoSuchEntryException if a matching blogs entry could not be found
9933             */
9934            @Override
9935            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9936                    OrderByComparator<BlogsEntry> orderByComparator)
9937                    throws NoSuchEntryException {
9938                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9939                                    orderByComparator);
9940    
9941                    if (blogsEntry != null) {
9942                            return blogsEntry;
9943                    }
9944    
9945                    StringBundler msg = new StringBundler(8);
9946    
9947                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9948    
9949                    msg.append("groupId=");
9950                    msg.append(groupId);
9951    
9952                    msg.append(", userId=");
9953                    msg.append(userId);
9954    
9955                    msg.append(", status=");
9956                    msg.append(status);
9957    
9958                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9959    
9960                    throw new NoSuchEntryException(msg.toString());
9961            }
9962    
9963            /**
9964             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9965             *
9966             * @param groupId the group ID
9967             * @param userId the user ID
9968             * @param status the status
9969             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9970             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9971             */
9972            @Override
9973            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
9974                    OrderByComparator<BlogsEntry> orderByComparator) {
9975                    int count = countByG_U_S(groupId, userId, status);
9976    
9977                    if (count == 0) {
9978                            return null;
9979                    }
9980    
9981                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
9982                                    count, orderByComparator);
9983    
9984                    if (!list.isEmpty()) {
9985                            return list.get(0);
9986                    }
9987    
9988                    return null;
9989            }
9990    
9991            /**
9992             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9993             *
9994             * @param entryId the primary key of the current blogs entry
9995             * @param groupId the group ID
9996             * @param userId the user ID
9997             * @param status the status
9998             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9999             * @return the previous, current, and next blogs entry
10000             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10001             */
10002            @Override
10003            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
10004                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10005                    throws NoSuchEntryException {
10006                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10007    
10008                    Session session = null;
10009    
10010                    try {
10011                            session = openSession();
10012    
10013                            BlogsEntry[] array = new BlogsEntryImpl[3];
10014    
10015                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10016                                            userId, status, orderByComparator, true);
10017    
10018                            array[1] = blogsEntry;
10019    
10020                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10021                                            userId, status, orderByComparator, false);
10022    
10023                            return array;
10024                    }
10025                    catch (Exception e) {
10026                            throw processException(e);
10027                    }
10028                    finally {
10029                            closeSession(session);
10030                    }
10031            }
10032    
10033            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
10034                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10035                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10036                    StringBundler query = null;
10037    
10038                    if (orderByComparator != null) {
10039                            query = new StringBundler(6 +
10040                                            (orderByComparator.getOrderByFields().length * 6));
10041                    }
10042                    else {
10043                            query = new StringBundler(3);
10044                    }
10045    
10046                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10047    
10048                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10049    
10050                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10051    
10052                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10053    
10054                    if (orderByComparator != null) {
10055                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10056    
10057                            if (orderByConditionFields.length > 0) {
10058                                    query.append(WHERE_AND);
10059                            }
10060    
10061                            for (int i = 0; i < orderByConditionFields.length; i++) {
10062                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10063                                    query.append(orderByConditionFields[i]);
10064    
10065                                    if ((i + 1) < orderByConditionFields.length) {
10066                                            if (orderByComparator.isAscending() ^ previous) {
10067                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10068                                            }
10069                                            else {
10070                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10071                                            }
10072                                    }
10073                                    else {
10074                                            if (orderByComparator.isAscending() ^ previous) {
10075                                                    query.append(WHERE_GREATER_THAN);
10076                                            }
10077                                            else {
10078                                                    query.append(WHERE_LESSER_THAN);
10079                                            }
10080                                    }
10081                            }
10082    
10083                            query.append(ORDER_BY_CLAUSE);
10084    
10085                            String[] orderByFields = orderByComparator.getOrderByFields();
10086    
10087                            for (int i = 0; i < orderByFields.length; i++) {
10088                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10089                                    query.append(orderByFields[i]);
10090    
10091                                    if ((i + 1) < orderByFields.length) {
10092                                            if (orderByComparator.isAscending() ^ previous) {
10093                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10094                                            }
10095                                            else {
10096                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10097                                            }
10098                                    }
10099                                    else {
10100                                            if (orderByComparator.isAscending() ^ previous) {
10101                                                    query.append(ORDER_BY_ASC);
10102                                            }
10103                                            else {
10104                                                    query.append(ORDER_BY_DESC);
10105                                            }
10106                                    }
10107                            }
10108                    }
10109                    else {
10110                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10111                    }
10112    
10113                    String sql = query.toString();
10114    
10115                    Query q = session.createQuery(sql);
10116    
10117                    q.setFirstResult(0);
10118                    q.setMaxResults(2);
10119    
10120                    QueryPos qPos = QueryPos.getInstance(q);
10121    
10122                    qPos.add(groupId);
10123    
10124                    qPos.add(userId);
10125    
10126                    qPos.add(status);
10127    
10128                    if (orderByComparator != null) {
10129                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10130    
10131                            for (Object value : values) {
10132                                    qPos.add(value);
10133                            }
10134                    }
10135    
10136                    List<BlogsEntry> list = q.list();
10137    
10138                    if (list.size() == 2) {
10139                            return list.get(1);
10140                    }
10141                    else {
10142                            return null;
10143                    }
10144            }
10145    
10146            /**
10147             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10148             *
10149             * @param groupId the group ID
10150             * @param userId the user ID
10151             * @param status the status
10152             * @return the matching blogs entries that the user has permission to view
10153             */
10154            @Override
10155            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10156                    int status) {
10157                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
10158                            QueryUtil.ALL_POS, null);
10159            }
10160    
10161            /**
10162             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10163             *
10164             * <p>
10165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10166             * </p>
10167             *
10168             * @param groupId the group ID
10169             * @param userId the user ID
10170             * @param status the status
10171             * @param start the lower bound of the range of blogs entries
10172             * @param end the upper bound of the range of blogs entries (not inclusive)
10173             * @return the range of matching blogs entries that the user has permission to view
10174             */
10175            @Override
10176            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10177                    int status, int start, int end) {
10178                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
10179            }
10180    
10181            /**
10182             * 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;.
10183             *
10184             * <p>
10185             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10186             * </p>
10187             *
10188             * @param groupId the group ID
10189             * @param userId the user ID
10190             * @param status the status
10191             * @param start the lower bound of the range of blogs entries
10192             * @param end the upper bound of the range of blogs entries (not inclusive)
10193             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10194             * @return the ordered range of matching blogs entries that the user has permission to view
10195             */
10196            @Override
10197            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10198                    int status, int start, int end,
10199                    OrderByComparator<BlogsEntry> orderByComparator) {
10200                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10201                            return findByG_U_S(groupId, userId, status, start, end,
10202                                    orderByComparator);
10203                    }
10204    
10205                    StringBundler query = null;
10206    
10207                    if (orderByComparator != null) {
10208                            query = new StringBundler(5 +
10209                                            (orderByComparator.getOrderByFields().length * 3));
10210                    }
10211                    else {
10212                            query = new StringBundler(5);
10213                    }
10214    
10215                    if (getDB().isSupportsInlineDistinct()) {
10216                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10217                    }
10218                    else {
10219                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10220                    }
10221    
10222                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10223    
10224                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10225    
10226                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10227    
10228                    if (!getDB().isSupportsInlineDistinct()) {
10229                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10230                    }
10231    
10232                    if (orderByComparator != null) {
10233                            if (getDB().isSupportsInlineDistinct()) {
10234                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10235                                            orderByComparator, true);
10236                            }
10237                            else {
10238                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10239                                            orderByComparator, true);
10240                            }
10241                    }
10242                    else {
10243                            if (getDB().isSupportsInlineDistinct()) {
10244                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10245                            }
10246                            else {
10247                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10248                            }
10249                    }
10250    
10251                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10252                                    BlogsEntry.class.getName(),
10253                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10254    
10255                    Session session = null;
10256    
10257                    try {
10258                            session = openSession();
10259    
10260                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10261    
10262                            if (getDB().isSupportsInlineDistinct()) {
10263                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10264                            }
10265                            else {
10266                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10267                            }
10268    
10269                            QueryPos qPos = QueryPos.getInstance(q);
10270    
10271                            qPos.add(groupId);
10272    
10273                            qPos.add(userId);
10274    
10275                            qPos.add(status);
10276    
10277                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10278                    }
10279                    catch (Exception e) {
10280                            throw processException(e);
10281                    }
10282                    finally {
10283                            closeSession(session);
10284                    }
10285            }
10286    
10287            /**
10288             * 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;.
10289             *
10290             * @param entryId the primary key of the current blogs entry
10291             * @param groupId the group ID
10292             * @param userId the user ID
10293             * @param status the status
10294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10295             * @return the previous, current, and next blogs entry
10296             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10297             */
10298            @Override
10299            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
10300                    long groupId, long userId, int status,
10301                    OrderByComparator<BlogsEntry> orderByComparator)
10302                    throws NoSuchEntryException {
10303                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10304                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
10305                                    orderByComparator);
10306                    }
10307    
10308                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10309    
10310                    Session session = null;
10311    
10312                    try {
10313                            session = openSession();
10314    
10315                            BlogsEntry[] array = new BlogsEntryImpl[3];
10316    
10317                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10318                                            groupId, userId, status, orderByComparator, true);
10319    
10320                            array[1] = blogsEntry;
10321    
10322                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10323                                            groupId, userId, status, orderByComparator, false);
10324    
10325                            return array;
10326                    }
10327                    catch (Exception e) {
10328                            throw processException(e);
10329                    }
10330                    finally {
10331                            closeSession(session);
10332                    }
10333            }
10334    
10335            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
10336                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10337                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10338                    StringBundler query = null;
10339    
10340                    if (orderByComparator != null) {
10341                            query = new StringBundler(6 +
10342                                            (orderByComparator.getOrderByFields().length * 6));
10343                    }
10344                    else {
10345                            query = new StringBundler(3);
10346                    }
10347    
10348                    if (getDB().isSupportsInlineDistinct()) {
10349                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10350                    }
10351                    else {
10352                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10353                    }
10354    
10355                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10356    
10357                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10358    
10359                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10360    
10361                    if (!getDB().isSupportsInlineDistinct()) {
10362                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10363                    }
10364    
10365                    if (orderByComparator != null) {
10366                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10367    
10368                            if (orderByConditionFields.length > 0) {
10369                                    query.append(WHERE_AND);
10370                            }
10371    
10372                            for (int i = 0; i < orderByConditionFields.length; i++) {
10373                                    if (getDB().isSupportsInlineDistinct()) {
10374                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10375                                    }
10376                                    else {
10377                                            query.append(_ORDER_BY_ENTITY_TABLE);
10378                                    }
10379    
10380                                    query.append(orderByConditionFields[i]);
10381    
10382                                    if ((i + 1) < orderByConditionFields.length) {
10383                                            if (orderByComparator.isAscending() ^ previous) {
10384                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10385                                            }
10386                                            else {
10387                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10388                                            }
10389                                    }
10390                                    else {
10391                                            if (orderByComparator.isAscending() ^ previous) {
10392                                                    query.append(WHERE_GREATER_THAN);
10393                                            }
10394                                            else {
10395                                                    query.append(WHERE_LESSER_THAN);
10396                                            }
10397                                    }
10398                            }
10399    
10400                            query.append(ORDER_BY_CLAUSE);
10401    
10402                            String[] orderByFields = orderByComparator.getOrderByFields();
10403    
10404                            for (int i = 0; i < orderByFields.length; i++) {
10405                                    if (getDB().isSupportsInlineDistinct()) {
10406                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10407                                    }
10408                                    else {
10409                                            query.append(_ORDER_BY_ENTITY_TABLE);
10410                                    }
10411    
10412                                    query.append(orderByFields[i]);
10413    
10414                                    if ((i + 1) < orderByFields.length) {
10415                                            if (orderByComparator.isAscending() ^ previous) {
10416                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10417                                            }
10418                                            else {
10419                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10420                                            }
10421                                    }
10422                                    else {
10423                                            if (orderByComparator.isAscending() ^ previous) {
10424                                                    query.append(ORDER_BY_ASC);
10425                                            }
10426                                            else {
10427                                                    query.append(ORDER_BY_DESC);
10428                                            }
10429                                    }
10430                            }
10431                    }
10432                    else {
10433                            if (getDB().isSupportsInlineDistinct()) {
10434                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10435                            }
10436                            else {
10437                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10438                            }
10439                    }
10440    
10441                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10442                                    BlogsEntry.class.getName(),
10443                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10444    
10445                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10446    
10447                    q.setFirstResult(0);
10448                    q.setMaxResults(2);
10449    
10450                    if (getDB().isSupportsInlineDistinct()) {
10451                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10452                    }
10453                    else {
10454                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10455                    }
10456    
10457                    QueryPos qPos = QueryPos.getInstance(q);
10458    
10459                    qPos.add(groupId);
10460    
10461                    qPos.add(userId);
10462    
10463                    qPos.add(status);
10464    
10465                    if (orderByComparator != null) {
10466                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10467    
10468                            for (Object value : values) {
10469                                    qPos.add(value);
10470                            }
10471                    }
10472    
10473                    List<BlogsEntry> list = q.list();
10474    
10475                    if (list.size() == 2) {
10476                            return list.get(1);
10477                    }
10478                    else {
10479                            return null;
10480                    }
10481            }
10482    
10483            /**
10484             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10485             *
10486             * @param groupId the group ID
10487             * @param userId the user ID
10488             * @param status the status
10489             */
10490            @Override
10491            public void removeByG_U_S(long groupId, long userId, int status) {
10492                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10493                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10494                            remove(blogsEntry);
10495                    }
10496            }
10497    
10498            /**
10499             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10500             *
10501             * @param groupId the group ID
10502             * @param userId the user ID
10503             * @param status the status
10504             * @return the number of matching blogs entries
10505             */
10506            @Override
10507            public int countByG_U_S(long groupId, long userId, int status) {
10508                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10509    
10510                    Object[] finderArgs = new Object[] { groupId, userId, status };
10511    
10512                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10513    
10514                    if (count == null) {
10515                            StringBundler query = new StringBundler(4);
10516    
10517                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10518    
10519                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10520    
10521                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10522    
10523                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10524    
10525                            String sql = query.toString();
10526    
10527                            Session session = null;
10528    
10529                            try {
10530                                    session = openSession();
10531    
10532                                    Query q = session.createQuery(sql);
10533    
10534                                    QueryPos qPos = QueryPos.getInstance(q);
10535    
10536                                    qPos.add(groupId);
10537    
10538                                    qPos.add(userId);
10539    
10540                                    qPos.add(status);
10541    
10542                                    count = (Long)q.uniqueResult();
10543    
10544                                    finderCache.putResult(finderPath, finderArgs, count);
10545                            }
10546                            catch (Exception e) {
10547                                    finderCache.removeResult(finderPath, finderArgs);
10548    
10549                                    throw processException(e);
10550                            }
10551                            finally {
10552                                    closeSession(session);
10553                            }
10554                    }
10555    
10556                    return count.intValue();
10557            }
10558    
10559            /**
10560             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10561             *
10562             * @param groupId the group ID
10563             * @param userId the user ID
10564             * @param status the status
10565             * @return the number of matching blogs entries that the user has permission to view
10566             */
10567            @Override
10568            public int filterCountByG_U_S(long groupId, long userId, int status) {
10569                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10570                            return countByG_U_S(groupId, userId, status);
10571                    }
10572    
10573                    StringBundler query = new StringBundler(4);
10574    
10575                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
10576    
10577                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10578    
10579                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10580    
10581                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10582    
10583                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10584                                    BlogsEntry.class.getName(),
10585                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10586    
10587                    Session session = null;
10588    
10589                    try {
10590                            session = openSession();
10591    
10592                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10593    
10594                            q.addScalar(COUNT_COLUMN_NAME,
10595                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10596    
10597                            QueryPos qPos = QueryPos.getInstance(q);
10598    
10599                            qPos.add(groupId);
10600    
10601                            qPos.add(userId);
10602    
10603                            qPos.add(status);
10604    
10605                            Long count = (Long)q.uniqueResult();
10606    
10607                            return count.intValue();
10608                    }
10609                    catch (Exception e) {
10610                            throw processException(e);
10611                    }
10612                    finally {
10613                            closeSession(session);
10614                    }
10615            }
10616    
10617            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
10618            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
10619            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
10620            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10621                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10622                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
10623                            new String[] {
10624                                    Long.class.getName(), Long.class.getName(),
10625                                    Integer.class.getName(),
10626                                    
10627                            Integer.class.getName(), Integer.class.getName(),
10628                                    OrderByComparator.class.getName()
10629                            });
10630            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
10631                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10632                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10633                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
10634                            new String[] {
10635                                    Long.class.getName(), Long.class.getName(),
10636                                    Integer.class.getName()
10637                            });
10638    
10639            /**
10640             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10641             *
10642             * @param groupId the group ID
10643             * @param userId the user ID
10644             * @param status the status
10645             * @return the matching blogs entries
10646             */
10647            @Override
10648            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
10649                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
10650                            QueryUtil.ALL_POS, null);
10651            }
10652    
10653            /**
10654             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10655             *
10656             * <p>
10657             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10658             * </p>
10659             *
10660             * @param groupId the group ID
10661             * @param userId the user ID
10662             * @param status the status
10663             * @param start the lower bound of the range of blogs entries
10664             * @param end the upper bound of the range of blogs entries (not inclusive)
10665             * @return the range of matching blogs entries
10666             */
10667            @Override
10668            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10669                    int status, int start, int end) {
10670                    return findByG_U_NotS(groupId, userId, status, start, end, null);
10671            }
10672    
10673            /**
10674             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10675             *
10676             * <p>
10677             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10678             * </p>
10679             *
10680             * @param groupId the group ID
10681             * @param userId the user ID
10682             * @param status the status
10683             * @param start the lower bound of the range of blogs entries
10684             * @param end the upper bound of the range of blogs entries (not inclusive)
10685             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10686             * @return the ordered range of matching blogs entries
10687             */
10688            @Override
10689            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10690                    int status, int start, int end,
10691                    OrderByComparator<BlogsEntry> orderByComparator) {
10692                    return findByG_U_NotS(groupId, userId, status, start, end,
10693                            orderByComparator, true);
10694            }
10695    
10696            /**
10697             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10698             *
10699             * <p>
10700             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10701             * </p>
10702             *
10703             * @param groupId the group ID
10704             * @param userId the user ID
10705             * @param status the status
10706             * @param start the lower bound of the range of blogs entries
10707             * @param end the upper bound of the range of blogs entries (not inclusive)
10708             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10709             * @param retrieveFromCache whether to retrieve from the finder cache
10710             * @return the ordered range of matching blogs entries
10711             */
10712            @Override
10713            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10714                    int status, int start, int end,
10715                    OrderByComparator<BlogsEntry> orderByComparator,
10716                    boolean retrieveFromCache) {
10717                    boolean pagination = true;
10718                    FinderPath finderPath = null;
10719                    Object[] finderArgs = null;
10720    
10721                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
10722                    finderArgs = new Object[] {
10723                                    groupId, userId, status,
10724                                    
10725                                    start, end, orderByComparator
10726                            };
10727    
10728                    List<BlogsEntry> list = null;
10729    
10730                    if (retrieveFromCache) {
10731                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
10732                                            finderArgs, this);
10733    
10734                            if ((list != null) && !list.isEmpty()) {
10735                                    for (BlogsEntry blogsEntry : list) {
10736                                            if ((groupId != blogsEntry.getGroupId()) ||
10737                                                            (userId != blogsEntry.getUserId()) ||
10738                                                            (status == blogsEntry.getStatus())) {
10739                                                    list = null;
10740    
10741                                                    break;
10742                                            }
10743                                    }
10744                            }
10745                    }
10746    
10747                    if (list == null) {
10748                            StringBundler query = null;
10749    
10750                            if (orderByComparator != null) {
10751                                    query = new StringBundler(5 +
10752                                                    (orderByComparator.getOrderByFields().length * 3));
10753                            }
10754                            else {
10755                                    query = new StringBundler(5);
10756                            }
10757    
10758                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10759    
10760                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10761    
10762                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10763    
10764                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10765    
10766                            if (orderByComparator != null) {
10767                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10768                                            orderByComparator);
10769                            }
10770                            else
10771                             if (pagination) {
10772                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10773                            }
10774    
10775                            String sql = query.toString();
10776    
10777                            Session session = null;
10778    
10779                            try {
10780                                    session = openSession();
10781    
10782                                    Query q = session.createQuery(sql);
10783    
10784                                    QueryPos qPos = QueryPos.getInstance(q);
10785    
10786                                    qPos.add(groupId);
10787    
10788                                    qPos.add(userId);
10789    
10790                                    qPos.add(status);
10791    
10792                                    if (!pagination) {
10793                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10794                                                            start, end, false);
10795    
10796                                            Collections.sort(list);
10797    
10798                                            list = Collections.unmodifiableList(list);
10799                                    }
10800                                    else {
10801                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10802                                                            start, end);
10803                                    }
10804    
10805                                    cacheResult(list);
10806    
10807                                    finderCache.putResult(finderPath, finderArgs, list);
10808                            }
10809                            catch (Exception e) {
10810                                    finderCache.removeResult(finderPath, finderArgs);
10811    
10812                                    throw processException(e);
10813                            }
10814                            finally {
10815                                    closeSession(session);
10816                            }
10817                    }
10818    
10819                    return list;
10820            }
10821    
10822            /**
10823             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10824             *
10825             * @param groupId the group ID
10826             * @param userId the user ID
10827             * @param status the status
10828             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10829             * @return the first matching blogs entry
10830             * @throws NoSuchEntryException if a matching blogs entry could not be found
10831             */
10832            @Override
10833            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
10834                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10835                    throws NoSuchEntryException {
10836                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
10837                                    orderByComparator);
10838    
10839                    if (blogsEntry != null) {
10840                            return blogsEntry;
10841                    }
10842    
10843                    StringBundler msg = new StringBundler(8);
10844    
10845                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10846    
10847                    msg.append("groupId=");
10848                    msg.append(groupId);
10849    
10850                    msg.append(", userId=");
10851                    msg.append(userId);
10852    
10853                    msg.append(", status=");
10854                    msg.append(status);
10855    
10856                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10857    
10858                    throw new NoSuchEntryException(msg.toString());
10859            }
10860    
10861            /**
10862             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10863             *
10864             * @param groupId the group ID
10865             * @param userId the user ID
10866             * @param status the status
10867             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10868             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10869             */
10870            @Override
10871            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
10872                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10873                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
10874                                    orderByComparator);
10875    
10876                    if (!list.isEmpty()) {
10877                            return list.get(0);
10878                    }
10879    
10880                    return null;
10881            }
10882    
10883            /**
10884             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10885             *
10886             * @param groupId the group ID
10887             * @param userId the user ID
10888             * @param status the status
10889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10890             * @return the last matching blogs entry
10891             * @throws NoSuchEntryException if a matching blogs entry could not be found
10892             */
10893            @Override
10894            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
10895                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10896                    throws NoSuchEntryException {
10897                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
10898                                    orderByComparator);
10899    
10900                    if (blogsEntry != null) {
10901                            return blogsEntry;
10902                    }
10903    
10904                    StringBundler msg = new StringBundler(8);
10905    
10906                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10907    
10908                    msg.append("groupId=");
10909                    msg.append(groupId);
10910    
10911                    msg.append(", userId=");
10912                    msg.append(userId);
10913    
10914                    msg.append(", status=");
10915                    msg.append(status);
10916    
10917                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10918    
10919                    throw new NoSuchEntryException(msg.toString());
10920            }
10921    
10922            /**
10923             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10924             *
10925             * @param groupId the group ID
10926             * @param userId the user ID
10927             * @param status the status
10928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10929             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10930             */
10931            @Override
10932            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
10933                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10934                    int count = countByG_U_NotS(groupId, userId, status);
10935    
10936                    if (count == 0) {
10937                            return null;
10938                    }
10939    
10940                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
10941                                    count - 1, count, orderByComparator);
10942    
10943                    if (!list.isEmpty()) {
10944                            return list.get(0);
10945                    }
10946    
10947                    return null;
10948            }
10949    
10950            /**
10951             * 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;.
10952             *
10953             * @param entryId the primary key of the current blogs entry
10954             * @param groupId the group ID
10955             * @param userId the user ID
10956             * @param status the status
10957             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10958             * @return the previous, current, and next blogs entry
10959             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10960             */
10961            @Override
10962            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
10963                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10964                    throws NoSuchEntryException {
10965                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10966    
10967                    Session session = null;
10968    
10969                    try {
10970                            session = openSession();
10971    
10972                            BlogsEntry[] array = new BlogsEntryImpl[3];
10973    
10974                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10975                                            userId, status, orderByComparator, true);
10976    
10977                            array[1] = blogsEntry;
10978    
10979                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10980                                            userId, status, orderByComparator, false);
10981    
10982                            return array;
10983                    }
10984                    catch (Exception e) {
10985                            throw processException(e);
10986                    }
10987                    finally {
10988                            closeSession(session);
10989                    }
10990            }
10991    
10992            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
10993                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10994                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10995                    StringBundler query = null;
10996    
10997                    if (orderByComparator != null) {
10998                            query = new StringBundler(6 +
10999                                            (orderByComparator.getOrderByFields().length * 6));
11000                    }
11001                    else {
11002                            query = new StringBundler(3);
11003                    }
11004    
11005                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11006    
11007                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11008    
11009                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11010    
11011                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11012    
11013                    if (orderByComparator != null) {
11014                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11015    
11016                            if (orderByConditionFields.length > 0) {
11017                                    query.append(WHERE_AND);
11018                            }
11019    
11020                            for (int i = 0; i < orderByConditionFields.length; i++) {
11021                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11022                                    query.append(orderByConditionFields[i]);
11023    
11024                                    if ((i + 1) < orderByConditionFields.length) {
11025                                            if (orderByComparator.isAscending() ^ previous) {
11026                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11027                                            }
11028                                            else {
11029                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11030                                            }
11031                                    }
11032                                    else {
11033                                            if (orderByComparator.isAscending() ^ previous) {
11034                                                    query.append(WHERE_GREATER_THAN);
11035                                            }
11036                                            else {
11037                                                    query.append(WHERE_LESSER_THAN);
11038                                            }
11039                                    }
11040                            }
11041    
11042                            query.append(ORDER_BY_CLAUSE);
11043    
11044                            String[] orderByFields = orderByComparator.getOrderByFields();
11045    
11046                            for (int i = 0; i < orderByFields.length; i++) {
11047                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11048                                    query.append(orderByFields[i]);
11049    
11050                                    if ((i + 1) < orderByFields.length) {
11051                                            if (orderByComparator.isAscending() ^ previous) {
11052                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11053                                            }
11054                                            else {
11055                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11056                                            }
11057                                    }
11058                                    else {
11059                                            if (orderByComparator.isAscending() ^ previous) {
11060                                                    query.append(ORDER_BY_ASC);
11061                                            }
11062                                            else {
11063                                                    query.append(ORDER_BY_DESC);
11064                                            }
11065                                    }
11066                            }
11067                    }
11068                    else {
11069                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11070                    }
11071    
11072                    String sql = query.toString();
11073    
11074                    Query q = session.createQuery(sql);
11075    
11076                    q.setFirstResult(0);
11077                    q.setMaxResults(2);
11078    
11079                    QueryPos qPos = QueryPos.getInstance(q);
11080    
11081                    qPos.add(groupId);
11082    
11083                    qPos.add(userId);
11084    
11085                    qPos.add(status);
11086    
11087                    if (orderByComparator != null) {
11088                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11089    
11090                            for (Object value : values) {
11091                                    qPos.add(value);
11092                            }
11093                    }
11094    
11095                    List<BlogsEntry> list = q.list();
11096    
11097                    if (list.size() == 2) {
11098                            return list.get(1);
11099                    }
11100                    else {
11101                            return null;
11102                    }
11103            }
11104    
11105            /**
11106             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11107             *
11108             * @param groupId the group ID
11109             * @param userId the user ID
11110             * @param status the status
11111             * @return the matching blogs entries that the user has permission to view
11112             */
11113            @Override
11114            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11115                    int status) {
11116                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11117                            QueryUtil.ALL_POS, null);
11118            }
11119    
11120            /**
11121             * 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;.
11122             *
11123             * <p>
11124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11125             * </p>
11126             *
11127             * @param groupId the group ID
11128             * @param userId the user ID
11129             * @param status the status
11130             * @param start the lower bound of the range of blogs entries
11131             * @param end the upper bound of the range of blogs entries (not inclusive)
11132             * @return the range of matching blogs entries that the user has permission to view
11133             */
11134            @Override
11135            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11136                    int status, int start, int end) {
11137                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
11138            }
11139    
11140            /**
11141             * 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;.
11142             *
11143             * <p>
11144             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11145             * </p>
11146             *
11147             * @param groupId the group ID
11148             * @param userId the user ID
11149             * @param status the status
11150             * @param start the lower bound of the range of blogs entries
11151             * @param end the upper bound of the range of blogs entries (not inclusive)
11152             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11153             * @return the ordered range of matching blogs entries that the user has permission to view
11154             */
11155            @Override
11156            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11157                    int status, int start, int end,
11158                    OrderByComparator<BlogsEntry> orderByComparator) {
11159                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11160                            return findByG_U_NotS(groupId, userId, status, start, end,
11161                                    orderByComparator);
11162                    }
11163    
11164                    StringBundler query = null;
11165    
11166                    if (orderByComparator != null) {
11167                            query = new StringBundler(5 +
11168                                            (orderByComparator.getOrderByFields().length * 3));
11169                    }
11170                    else {
11171                            query = new StringBundler(5);
11172                    }
11173    
11174                    if (getDB().isSupportsInlineDistinct()) {
11175                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11176                    }
11177                    else {
11178                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11179                    }
11180    
11181                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11182    
11183                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11184    
11185                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11186    
11187                    if (!getDB().isSupportsInlineDistinct()) {
11188                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11189                    }
11190    
11191                    if (orderByComparator != null) {
11192                            if (getDB().isSupportsInlineDistinct()) {
11193                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11194                                            orderByComparator, true);
11195                            }
11196                            else {
11197                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11198                                            orderByComparator, true);
11199                            }
11200                    }
11201                    else {
11202                            if (getDB().isSupportsInlineDistinct()) {
11203                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11204                            }
11205                            else {
11206                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11207                            }
11208                    }
11209    
11210                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11211                                    BlogsEntry.class.getName(),
11212                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11213    
11214                    Session session = null;
11215    
11216                    try {
11217                            session = openSession();
11218    
11219                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11220    
11221                            if (getDB().isSupportsInlineDistinct()) {
11222                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11223                            }
11224                            else {
11225                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11226                            }
11227    
11228                            QueryPos qPos = QueryPos.getInstance(q);
11229    
11230                            qPos.add(groupId);
11231    
11232                            qPos.add(userId);
11233    
11234                            qPos.add(status);
11235    
11236                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11237                    }
11238                    catch (Exception e) {
11239                            throw processException(e);
11240                    }
11241                    finally {
11242                            closeSession(session);
11243                    }
11244            }
11245    
11246            /**
11247             * 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;.
11248             *
11249             * @param entryId the primary key of the current blogs entry
11250             * @param groupId the group ID
11251             * @param userId the user ID
11252             * @param status the status
11253             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11254             * @return the previous, current, and next blogs entry
11255             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11256             */
11257            @Override
11258            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
11259                    long groupId, long userId, int status,
11260                    OrderByComparator<BlogsEntry> orderByComparator)
11261                    throws NoSuchEntryException {
11262                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11263                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
11264                                    orderByComparator);
11265                    }
11266    
11267                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11268    
11269                    Session session = null;
11270    
11271                    try {
11272                            session = openSession();
11273    
11274                            BlogsEntry[] array = new BlogsEntryImpl[3];
11275    
11276                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11277                                            groupId, userId, status, orderByComparator, true);
11278    
11279                            array[1] = blogsEntry;
11280    
11281                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11282                                            groupId, userId, status, orderByComparator, false);
11283    
11284                            return array;
11285                    }
11286                    catch (Exception e) {
11287                            throw processException(e);
11288                    }
11289                    finally {
11290                            closeSession(session);
11291                    }
11292            }
11293    
11294            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
11295                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11296                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11297                    StringBundler query = null;
11298    
11299                    if (orderByComparator != null) {
11300                            query = new StringBundler(6 +
11301                                            (orderByComparator.getOrderByFields().length * 6));
11302                    }
11303                    else {
11304                            query = new StringBundler(3);
11305                    }
11306    
11307                    if (getDB().isSupportsInlineDistinct()) {
11308                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11309                    }
11310                    else {
11311                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11312                    }
11313    
11314                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11315    
11316                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11317    
11318                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11319    
11320                    if (!getDB().isSupportsInlineDistinct()) {
11321                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11322                    }
11323    
11324                    if (orderByComparator != null) {
11325                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11326    
11327                            if (orderByConditionFields.length > 0) {
11328                                    query.append(WHERE_AND);
11329                            }
11330    
11331                            for (int i = 0; i < orderByConditionFields.length; i++) {
11332                                    if (getDB().isSupportsInlineDistinct()) {
11333                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11334                                    }
11335                                    else {
11336                                            query.append(_ORDER_BY_ENTITY_TABLE);
11337                                    }
11338    
11339                                    query.append(orderByConditionFields[i]);
11340    
11341                                    if ((i + 1) < orderByConditionFields.length) {
11342                                            if (orderByComparator.isAscending() ^ previous) {
11343                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11344                                            }
11345                                            else {
11346                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11347                                            }
11348                                    }
11349                                    else {
11350                                            if (orderByComparator.isAscending() ^ previous) {
11351                                                    query.append(WHERE_GREATER_THAN);
11352                                            }
11353                                            else {
11354                                                    query.append(WHERE_LESSER_THAN);
11355                                            }
11356                                    }
11357                            }
11358    
11359                            query.append(ORDER_BY_CLAUSE);
11360    
11361                            String[] orderByFields = orderByComparator.getOrderByFields();
11362    
11363                            for (int i = 0; i < orderByFields.length; i++) {
11364                                    if (getDB().isSupportsInlineDistinct()) {
11365                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11366                                    }
11367                                    else {
11368                                            query.append(_ORDER_BY_ENTITY_TABLE);
11369                                    }
11370    
11371                                    query.append(orderByFields[i]);
11372    
11373                                    if ((i + 1) < orderByFields.length) {
11374                                            if (orderByComparator.isAscending() ^ previous) {
11375                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11376                                            }
11377                                            else {
11378                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11379                                            }
11380                                    }
11381                                    else {
11382                                            if (orderByComparator.isAscending() ^ previous) {
11383                                                    query.append(ORDER_BY_ASC);
11384                                            }
11385                                            else {
11386                                                    query.append(ORDER_BY_DESC);
11387                                            }
11388                                    }
11389                            }
11390                    }
11391                    else {
11392                            if (getDB().isSupportsInlineDistinct()) {
11393                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11394                            }
11395                            else {
11396                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11397                            }
11398                    }
11399    
11400                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11401                                    BlogsEntry.class.getName(),
11402                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11403    
11404                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11405    
11406                    q.setFirstResult(0);
11407                    q.setMaxResults(2);
11408    
11409                    if (getDB().isSupportsInlineDistinct()) {
11410                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11411                    }
11412                    else {
11413                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11414                    }
11415    
11416                    QueryPos qPos = QueryPos.getInstance(q);
11417    
11418                    qPos.add(groupId);
11419    
11420                    qPos.add(userId);
11421    
11422                    qPos.add(status);
11423    
11424                    if (orderByComparator != null) {
11425                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11426    
11427                            for (Object value : values) {
11428                                    qPos.add(value);
11429                            }
11430                    }
11431    
11432                    List<BlogsEntry> list = q.list();
11433    
11434                    if (list.size() == 2) {
11435                            return list.get(1);
11436                    }
11437                    else {
11438                            return null;
11439                    }
11440            }
11441    
11442            /**
11443             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
11444             *
11445             * @param groupId the group ID
11446             * @param userId the user ID
11447             * @param status the status
11448             */
11449            @Override
11450            public void removeByG_U_NotS(long groupId, long userId, int status) {
11451                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
11452                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11453                            remove(blogsEntry);
11454                    }
11455            }
11456    
11457            /**
11458             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11459             *
11460             * @param groupId the group ID
11461             * @param userId the user ID
11462             * @param status the status
11463             * @return the number of matching blogs entries
11464             */
11465            @Override
11466            public int countByG_U_NotS(long groupId, long userId, int status) {
11467                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
11468    
11469                    Object[] finderArgs = new Object[] { groupId, userId, status };
11470    
11471                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
11472    
11473                    if (count == null) {
11474                            StringBundler query = new StringBundler(4);
11475    
11476                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11477    
11478                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11479    
11480                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11481    
11482                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11483    
11484                            String sql = query.toString();
11485    
11486                            Session session = null;
11487    
11488                            try {
11489                                    session = openSession();
11490    
11491                                    Query q = session.createQuery(sql);
11492    
11493                                    QueryPos qPos = QueryPos.getInstance(q);
11494    
11495                                    qPos.add(groupId);
11496    
11497                                    qPos.add(userId);
11498    
11499                                    qPos.add(status);
11500    
11501                                    count = (Long)q.uniqueResult();
11502    
11503                                    finderCache.putResult(finderPath, finderArgs, count);
11504                            }
11505                            catch (Exception e) {
11506                                    finderCache.removeResult(finderPath, finderArgs);
11507    
11508                                    throw processException(e);
11509                            }
11510                            finally {
11511                                    closeSession(session);
11512                            }
11513                    }
11514    
11515                    return count.intValue();
11516            }
11517    
11518            /**
11519             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11520             *
11521             * @param groupId the group ID
11522             * @param userId the user ID
11523             * @param status the status
11524             * @return the number of matching blogs entries that the user has permission to view
11525             */
11526            @Override
11527            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
11528                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11529                            return countByG_U_NotS(groupId, userId, status);
11530                    }
11531    
11532                    StringBundler query = new StringBundler(4);
11533    
11534                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11535    
11536                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11537    
11538                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11539    
11540                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11541    
11542                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11543                                    BlogsEntry.class.getName(),
11544                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11545    
11546                    Session session = null;
11547    
11548                    try {
11549                            session = openSession();
11550    
11551                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11552    
11553                            q.addScalar(COUNT_COLUMN_NAME,
11554                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11555    
11556                            QueryPos qPos = QueryPos.getInstance(q);
11557    
11558                            qPos.add(groupId);
11559    
11560                            qPos.add(userId);
11561    
11562                            qPos.add(status);
11563    
11564                            Long count = (Long)q.uniqueResult();
11565    
11566                            return count.intValue();
11567                    }
11568                    catch (Exception e) {
11569                            throw processException(e);
11570                    }
11571                    finally {
11572                            closeSession(session);
11573                    }
11574            }
11575    
11576            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11577            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
11578            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
11579            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11580                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11581                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
11582                            new String[] {
11583                                    Long.class.getName(), Date.class.getName(),
11584                                    Integer.class.getName(),
11585                                    
11586                            Integer.class.getName(), Integer.class.getName(),
11587                                    OrderByComparator.class.getName()
11588                            });
11589            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11590                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11591                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
11592                            new String[] {
11593                                    Long.class.getName(), Date.class.getName(),
11594                                    Integer.class.getName()
11595                            });
11596    
11597            /**
11598             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11599             *
11600             * @param groupId the group ID
11601             * @param displayDate the display date
11602             * @param status the status
11603             * @return the matching blogs entries
11604             */
11605            @Override
11606            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11607                    int status) {
11608                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
11609                            QueryUtil.ALL_POS, null);
11610            }
11611    
11612            /**
11613             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11614             *
11615             * <p>
11616             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11617             * </p>
11618             *
11619             * @param groupId the group ID
11620             * @param displayDate the display date
11621             * @param status the status
11622             * @param start the lower bound of the range of blogs entries
11623             * @param end the upper bound of the range of blogs entries (not inclusive)
11624             * @return the range of matching blogs entries
11625             */
11626            @Override
11627            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11628                    int status, int start, int end) {
11629                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
11630            }
11631    
11632            /**
11633             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11634             *
11635             * <p>
11636             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11637             * </p>
11638             *
11639             * @param groupId the group ID
11640             * @param displayDate the display date
11641             * @param status the status
11642             * @param start the lower bound of the range of blogs entries
11643             * @param end the upper bound of the range of blogs entries (not inclusive)
11644             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11645             * @return the ordered range of matching blogs entries
11646             */
11647            @Override
11648            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11649                    int status, int start, int end,
11650                    OrderByComparator<BlogsEntry> orderByComparator) {
11651                    return findByG_LtD_S(groupId, displayDate, status, start, end,
11652                            orderByComparator, true);
11653            }
11654    
11655            /**
11656             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11657             *
11658             * <p>
11659             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11660             * </p>
11661             *
11662             * @param groupId the group ID
11663             * @param displayDate the display date
11664             * @param status the status
11665             * @param start the lower bound of the range of blogs entries
11666             * @param end the upper bound of the range of blogs entries (not inclusive)
11667             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11668             * @param retrieveFromCache whether to retrieve from the finder cache
11669             * @return the ordered range of matching blogs entries
11670             */
11671            @Override
11672            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11673                    int status, int start, int end,
11674                    OrderByComparator<BlogsEntry> orderByComparator,
11675                    boolean retrieveFromCache) {
11676                    boolean pagination = true;
11677                    FinderPath finderPath = null;
11678                    Object[] finderArgs = null;
11679    
11680                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
11681                    finderArgs = new Object[] {
11682                                    groupId, displayDate, status,
11683                                    
11684                                    start, end, orderByComparator
11685                            };
11686    
11687                    List<BlogsEntry> list = null;
11688    
11689                    if (retrieveFromCache) {
11690                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
11691                                            finderArgs, this);
11692    
11693                            if ((list != null) && !list.isEmpty()) {
11694                                    for (BlogsEntry blogsEntry : list) {
11695                                            if ((groupId != blogsEntry.getGroupId()) ||
11696                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
11697                                                                                                                                            .getTime()) ||
11698                                                            (status != blogsEntry.getStatus())) {
11699                                                    list = null;
11700    
11701                                                    break;
11702                                            }
11703                                    }
11704                            }
11705                    }
11706    
11707                    if (list == null) {
11708                            StringBundler query = null;
11709    
11710                            if (orderByComparator != null) {
11711                                    query = new StringBundler(5 +
11712                                                    (orderByComparator.getOrderByFields().length * 3));
11713                            }
11714                            else {
11715                                    query = new StringBundler(5);
11716                            }
11717    
11718                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11719    
11720                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11721    
11722                            boolean bindDisplayDate = false;
11723    
11724                            if (displayDate == null) {
11725                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11726                            }
11727                            else {
11728                                    bindDisplayDate = true;
11729    
11730                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11731                            }
11732    
11733                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11734    
11735                            if (orderByComparator != null) {
11736                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11737                                            orderByComparator);
11738                            }
11739                            else
11740                             if (pagination) {
11741                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11742                            }
11743    
11744                            String sql = query.toString();
11745    
11746                            Session session = null;
11747    
11748                            try {
11749                                    session = openSession();
11750    
11751                                    Query q = session.createQuery(sql);
11752    
11753                                    QueryPos qPos = QueryPos.getInstance(q);
11754    
11755                                    qPos.add(groupId);
11756    
11757                                    if (bindDisplayDate) {
11758                                            qPos.add(new Timestamp(displayDate.getTime()));
11759                                    }
11760    
11761                                    qPos.add(status);
11762    
11763                                    if (!pagination) {
11764                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11765                                                            start, end, false);
11766    
11767                                            Collections.sort(list);
11768    
11769                                            list = Collections.unmodifiableList(list);
11770                                    }
11771                                    else {
11772                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11773                                                            start, end);
11774                                    }
11775    
11776                                    cacheResult(list);
11777    
11778                                    finderCache.putResult(finderPath, finderArgs, list);
11779                            }
11780                            catch (Exception e) {
11781                                    finderCache.removeResult(finderPath, finderArgs);
11782    
11783                                    throw processException(e);
11784                            }
11785                            finally {
11786                                    closeSession(session);
11787                            }
11788                    }
11789    
11790                    return list;
11791            }
11792    
11793            /**
11794             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11795             *
11796             * @param groupId the group ID
11797             * @param displayDate the display date
11798             * @param status the status
11799             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11800             * @return the first matching blogs entry
11801             * @throws NoSuchEntryException if a matching blogs entry could not be found
11802             */
11803            @Override
11804            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
11805                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11806                    throws NoSuchEntryException {
11807                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
11808                                    status, orderByComparator);
11809    
11810                    if (blogsEntry != null) {
11811                            return blogsEntry;
11812                    }
11813    
11814                    StringBundler msg = new StringBundler(8);
11815    
11816                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11817    
11818                    msg.append("groupId=");
11819                    msg.append(groupId);
11820    
11821                    msg.append(", displayDate=");
11822                    msg.append(displayDate);
11823    
11824                    msg.append(", status=");
11825                    msg.append(status);
11826    
11827                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11828    
11829                    throw new NoSuchEntryException(msg.toString());
11830            }
11831    
11832            /**
11833             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11834             *
11835             * @param groupId the group ID
11836             * @param displayDate the display date
11837             * @param status the status
11838             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11839             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11840             */
11841            @Override
11842            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
11843                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11844                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
11845                                    1, orderByComparator);
11846    
11847                    if (!list.isEmpty()) {
11848                            return list.get(0);
11849                    }
11850    
11851                    return null;
11852            }
11853    
11854            /**
11855             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11856             *
11857             * @param groupId the group ID
11858             * @param displayDate the display date
11859             * @param status the status
11860             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11861             * @return the last matching blogs entry
11862             * @throws NoSuchEntryException if a matching blogs entry could not be found
11863             */
11864            @Override
11865            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
11866                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11867                    throws NoSuchEntryException {
11868                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
11869                                    status, orderByComparator);
11870    
11871                    if (blogsEntry != null) {
11872                            return blogsEntry;
11873                    }
11874    
11875                    StringBundler msg = new StringBundler(8);
11876    
11877                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11878    
11879                    msg.append("groupId=");
11880                    msg.append(groupId);
11881    
11882                    msg.append(", displayDate=");
11883                    msg.append(displayDate);
11884    
11885                    msg.append(", status=");
11886                    msg.append(status);
11887    
11888                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11889    
11890                    throw new NoSuchEntryException(msg.toString());
11891            }
11892    
11893            /**
11894             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11895             *
11896             * @param groupId the group ID
11897             * @param displayDate the display date
11898             * @param status the status
11899             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11900             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11901             */
11902            @Override
11903            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
11904                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11905                    int count = countByG_LtD_S(groupId, displayDate, status);
11906    
11907                    if (count == 0) {
11908                            return null;
11909                    }
11910    
11911                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
11912                                    count - 1, count, orderByComparator);
11913    
11914                    if (!list.isEmpty()) {
11915                            return list.get(0);
11916                    }
11917    
11918                    return null;
11919            }
11920    
11921            /**
11922             * 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;.
11923             *
11924             * @param entryId the primary key of the current blogs entry
11925             * @param groupId the group ID
11926             * @param displayDate the display date
11927             * @param status the status
11928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11929             * @return the previous, current, and next blogs entry
11930             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11931             */
11932            @Override
11933            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
11934                    Date displayDate, int status,
11935                    OrderByComparator<BlogsEntry> orderByComparator)
11936                    throws NoSuchEntryException {
11937                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11938    
11939                    Session session = null;
11940    
11941                    try {
11942                            session = openSession();
11943    
11944                            BlogsEntry[] array = new BlogsEntryImpl[3];
11945    
11946                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11947                                            displayDate, status, orderByComparator, true);
11948    
11949                            array[1] = blogsEntry;
11950    
11951                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11952                                            displayDate, status, orderByComparator, false);
11953    
11954                            return array;
11955                    }
11956                    catch (Exception e) {
11957                            throw processException(e);
11958                    }
11959                    finally {
11960                            closeSession(session);
11961                    }
11962            }
11963    
11964            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
11965                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
11966                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11967                    StringBundler query = null;
11968    
11969                    if (orderByComparator != null) {
11970                            query = new StringBundler(6 +
11971                                            (orderByComparator.getOrderByFields().length * 6));
11972                    }
11973                    else {
11974                            query = new StringBundler(3);
11975                    }
11976    
11977                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11978    
11979                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11980    
11981                    boolean bindDisplayDate = false;
11982    
11983                    if (displayDate == null) {
11984                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11985                    }
11986                    else {
11987                            bindDisplayDate = true;
11988    
11989                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11990                    }
11991    
11992                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11993    
11994                    if (orderByComparator != null) {
11995                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11996    
11997                            if (orderByConditionFields.length > 0) {
11998                                    query.append(WHERE_AND);
11999                            }
12000    
12001                            for (int i = 0; i < orderByConditionFields.length; i++) {
12002                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12003                                    query.append(orderByConditionFields[i]);
12004    
12005                                    if ((i + 1) < orderByConditionFields.length) {
12006                                            if (orderByComparator.isAscending() ^ previous) {
12007                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12008                                            }
12009                                            else {
12010                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12011                                            }
12012                                    }
12013                                    else {
12014                                            if (orderByComparator.isAscending() ^ previous) {
12015                                                    query.append(WHERE_GREATER_THAN);
12016                                            }
12017                                            else {
12018                                                    query.append(WHERE_LESSER_THAN);
12019                                            }
12020                                    }
12021                            }
12022    
12023                            query.append(ORDER_BY_CLAUSE);
12024    
12025                            String[] orderByFields = orderByComparator.getOrderByFields();
12026    
12027                            for (int i = 0; i < orderByFields.length; i++) {
12028                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12029                                    query.append(orderByFields[i]);
12030    
12031                                    if ((i + 1) < orderByFields.length) {
12032                                            if (orderByComparator.isAscending() ^ previous) {
12033                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12034                                            }
12035                                            else {
12036                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12037                                            }
12038                                    }
12039                                    else {
12040                                            if (orderByComparator.isAscending() ^ previous) {
12041                                                    query.append(ORDER_BY_ASC);
12042                                            }
12043                                            else {
12044                                                    query.append(ORDER_BY_DESC);
12045                                            }
12046                                    }
12047                            }
12048                    }
12049                    else {
12050                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12051                    }
12052    
12053                    String sql = query.toString();
12054    
12055                    Query q = session.createQuery(sql);
12056    
12057                    q.setFirstResult(0);
12058                    q.setMaxResults(2);
12059    
12060                    QueryPos qPos = QueryPos.getInstance(q);
12061    
12062                    qPos.add(groupId);
12063    
12064                    if (bindDisplayDate) {
12065                            qPos.add(new Timestamp(displayDate.getTime()));
12066                    }
12067    
12068                    qPos.add(status);
12069    
12070                    if (orderByComparator != null) {
12071                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12072    
12073                            for (Object value : values) {
12074                                    qPos.add(value);
12075                            }
12076                    }
12077    
12078                    List<BlogsEntry> list = q.list();
12079    
12080                    if (list.size() == 2) {
12081                            return list.get(1);
12082                    }
12083                    else {
12084                            return null;
12085                    }
12086            }
12087    
12088            /**
12089             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12090             *
12091             * @param groupId the group ID
12092             * @param displayDate the display date
12093             * @param status the status
12094             * @return the matching blogs entries that the user has permission to view
12095             */
12096            @Override
12097            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12098                    int status) {
12099                    return filterFindByG_LtD_S(groupId, displayDate, status,
12100                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12101            }
12102    
12103            /**
12104             * 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;.
12105             *
12106             * <p>
12107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12108             * </p>
12109             *
12110             * @param groupId the group ID
12111             * @param displayDate the display date
12112             * @param status the status
12113             * @param start the lower bound of the range of blogs entries
12114             * @param end the upper bound of the range of blogs entries (not inclusive)
12115             * @return the range of matching blogs entries that the user has permission to view
12116             */
12117            @Override
12118            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12119                    int status, int start, int end) {
12120                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
12121                            null);
12122            }
12123    
12124            /**
12125             * 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;.
12126             *
12127             * <p>
12128             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12129             * </p>
12130             *
12131             * @param groupId the group ID
12132             * @param displayDate the display date
12133             * @param status the status
12134             * @param start the lower bound of the range of blogs entries
12135             * @param end the upper bound of the range of blogs entries (not inclusive)
12136             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12137             * @return the ordered range of matching blogs entries that the user has permission to view
12138             */
12139            @Override
12140            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12141                    int status, int start, int end,
12142                    OrderByComparator<BlogsEntry> orderByComparator) {
12143                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12144                            return findByG_LtD_S(groupId, displayDate, status, start, end,
12145                                    orderByComparator);
12146                    }
12147    
12148                    StringBundler query = null;
12149    
12150                    if (orderByComparator != null) {
12151                            query = new StringBundler(5 +
12152                                            (orderByComparator.getOrderByFields().length * 3));
12153                    }
12154                    else {
12155                            query = new StringBundler(5);
12156                    }
12157    
12158                    if (getDB().isSupportsInlineDistinct()) {
12159                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12160                    }
12161                    else {
12162                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12163                    }
12164    
12165                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12166    
12167                    boolean bindDisplayDate = false;
12168    
12169                    if (displayDate == null) {
12170                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12171                    }
12172                    else {
12173                            bindDisplayDate = true;
12174    
12175                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12176                    }
12177    
12178                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12179    
12180                    if (!getDB().isSupportsInlineDistinct()) {
12181                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12182                    }
12183    
12184                    if (orderByComparator != null) {
12185                            if (getDB().isSupportsInlineDistinct()) {
12186                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12187                                            orderByComparator, true);
12188                            }
12189                            else {
12190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12191                                            orderByComparator, true);
12192                            }
12193                    }
12194                    else {
12195                            if (getDB().isSupportsInlineDistinct()) {
12196                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12197                            }
12198                            else {
12199                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12200                            }
12201                    }
12202    
12203                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12204                                    BlogsEntry.class.getName(),
12205                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12206    
12207                    Session session = null;
12208    
12209                    try {
12210                            session = openSession();
12211    
12212                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12213    
12214                            if (getDB().isSupportsInlineDistinct()) {
12215                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12216                            }
12217                            else {
12218                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12219                            }
12220    
12221                            QueryPos qPos = QueryPos.getInstance(q);
12222    
12223                            qPos.add(groupId);
12224    
12225                            if (bindDisplayDate) {
12226                                    qPos.add(new Timestamp(displayDate.getTime()));
12227                            }
12228    
12229                            qPos.add(status);
12230    
12231                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12232                    }
12233                    catch (Exception e) {
12234                            throw processException(e);
12235                    }
12236                    finally {
12237                            closeSession(session);
12238                    }
12239            }
12240    
12241            /**
12242             * 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;.
12243             *
12244             * @param entryId the primary key of the current blogs entry
12245             * @param groupId the group ID
12246             * @param displayDate the display date
12247             * @param status the status
12248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12249             * @return the previous, current, and next blogs entry
12250             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12251             */
12252            @Override
12253            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
12254                    long groupId, Date displayDate, int status,
12255                    OrderByComparator<BlogsEntry> orderByComparator)
12256                    throws NoSuchEntryException {
12257                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12258                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
12259                                    status, orderByComparator);
12260                    }
12261    
12262                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12263    
12264                    Session session = null;
12265    
12266                    try {
12267                            session = openSession();
12268    
12269                            BlogsEntry[] array = new BlogsEntryImpl[3];
12270    
12271                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12272                                            groupId, displayDate, status, orderByComparator, true);
12273    
12274                            array[1] = blogsEntry;
12275    
12276                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12277                                            groupId, displayDate, status, orderByComparator, false);
12278    
12279                            return array;
12280                    }
12281                    catch (Exception e) {
12282                            throw processException(e);
12283                    }
12284                    finally {
12285                            closeSession(session);
12286                    }
12287            }
12288    
12289            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
12290                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12291                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12292                    StringBundler query = null;
12293    
12294                    if (orderByComparator != null) {
12295                            query = new StringBundler(6 +
12296                                            (orderByComparator.getOrderByFields().length * 6));
12297                    }
12298                    else {
12299                            query = new StringBundler(3);
12300                    }
12301    
12302                    if (getDB().isSupportsInlineDistinct()) {
12303                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12304                    }
12305                    else {
12306                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12307                    }
12308    
12309                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12310    
12311                    boolean bindDisplayDate = false;
12312    
12313                    if (displayDate == null) {
12314                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12315                    }
12316                    else {
12317                            bindDisplayDate = true;
12318    
12319                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12320                    }
12321    
12322                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12323    
12324                    if (!getDB().isSupportsInlineDistinct()) {
12325                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12326                    }
12327    
12328                    if (orderByComparator != null) {
12329                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12330    
12331                            if (orderByConditionFields.length > 0) {
12332                                    query.append(WHERE_AND);
12333                            }
12334    
12335                            for (int i = 0; i < orderByConditionFields.length; i++) {
12336                                    if (getDB().isSupportsInlineDistinct()) {
12337                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12338                                    }
12339                                    else {
12340                                            query.append(_ORDER_BY_ENTITY_TABLE);
12341                                    }
12342    
12343                                    query.append(orderByConditionFields[i]);
12344    
12345                                    if ((i + 1) < orderByConditionFields.length) {
12346                                            if (orderByComparator.isAscending() ^ previous) {
12347                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12348                                            }
12349                                            else {
12350                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12351                                            }
12352                                    }
12353                                    else {
12354                                            if (orderByComparator.isAscending() ^ previous) {
12355                                                    query.append(WHERE_GREATER_THAN);
12356                                            }
12357                                            else {
12358                                                    query.append(WHERE_LESSER_THAN);
12359                                            }
12360                                    }
12361                            }
12362    
12363                            query.append(ORDER_BY_CLAUSE);
12364    
12365                            String[] orderByFields = orderByComparator.getOrderByFields();
12366    
12367                            for (int i = 0; i < orderByFields.length; i++) {
12368                                    if (getDB().isSupportsInlineDistinct()) {
12369                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12370                                    }
12371                                    else {
12372                                            query.append(_ORDER_BY_ENTITY_TABLE);
12373                                    }
12374    
12375                                    query.append(orderByFields[i]);
12376    
12377                                    if ((i + 1) < orderByFields.length) {
12378                                            if (orderByComparator.isAscending() ^ previous) {
12379                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12380                                            }
12381                                            else {
12382                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12383                                            }
12384                                    }
12385                                    else {
12386                                            if (orderByComparator.isAscending() ^ previous) {
12387                                                    query.append(ORDER_BY_ASC);
12388                                            }
12389                                            else {
12390                                                    query.append(ORDER_BY_DESC);
12391                                            }
12392                                    }
12393                            }
12394                    }
12395                    else {
12396                            if (getDB().isSupportsInlineDistinct()) {
12397                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12398                            }
12399                            else {
12400                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12401                            }
12402                    }
12403    
12404                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12405                                    BlogsEntry.class.getName(),
12406                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12407    
12408                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12409    
12410                    q.setFirstResult(0);
12411                    q.setMaxResults(2);
12412    
12413                    if (getDB().isSupportsInlineDistinct()) {
12414                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12415                    }
12416                    else {
12417                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12418                    }
12419    
12420                    QueryPos qPos = QueryPos.getInstance(q);
12421    
12422                    qPos.add(groupId);
12423    
12424                    if (bindDisplayDate) {
12425                            qPos.add(new Timestamp(displayDate.getTime()));
12426                    }
12427    
12428                    qPos.add(status);
12429    
12430                    if (orderByComparator != null) {
12431                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12432    
12433                            for (Object value : values) {
12434                                    qPos.add(value);
12435                            }
12436                    }
12437    
12438                    List<BlogsEntry> list = q.list();
12439    
12440                    if (list.size() == 2) {
12441                            return list.get(1);
12442                    }
12443                    else {
12444                            return null;
12445                    }
12446            }
12447    
12448            /**
12449             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
12450             *
12451             * @param groupId the group ID
12452             * @param displayDate the display date
12453             * @param status the status
12454             */
12455            @Override
12456            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
12457                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
12458                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12459                            remove(blogsEntry);
12460                    }
12461            }
12462    
12463            /**
12464             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12465             *
12466             * @param groupId the group ID
12467             * @param displayDate the display date
12468             * @param status the status
12469             * @return the number of matching blogs entries
12470             */
12471            @Override
12472            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
12473                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
12474    
12475                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
12476    
12477                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12478    
12479                    if (count == null) {
12480                            StringBundler query = new StringBundler(4);
12481    
12482                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12483    
12484                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12485    
12486                            boolean bindDisplayDate = false;
12487    
12488                            if (displayDate == null) {
12489                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12490                            }
12491                            else {
12492                                    bindDisplayDate = true;
12493    
12494                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12495                            }
12496    
12497                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12498    
12499                            String sql = query.toString();
12500    
12501                            Session session = null;
12502    
12503                            try {
12504                                    session = openSession();
12505    
12506                                    Query q = session.createQuery(sql);
12507    
12508                                    QueryPos qPos = QueryPos.getInstance(q);
12509    
12510                                    qPos.add(groupId);
12511    
12512                                    if (bindDisplayDate) {
12513                                            qPos.add(new Timestamp(displayDate.getTime()));
12514                                    }
12515    
12516                                    qPos.add(status);
12517    
12518                                    count = (Long)q.uniqueResult();
12519    
12520                                    finderCache.putResult(finderPath, finderArgs, count);
12521                            }
12522                            catch (Exception e) {
12523                                    finderCache.removeResult(finderPath, finderArgs);
12524    
12525                                    throw processException(e);
12526                            }
12527                            finally {
12528                                    closeSession(session);
12529                            }
12530                    }
12531    
12532                    return count.intValue();
12533            }
12534    
12535            /**
12536             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12537             *
12538             * @param groupId the group ID
12539             * @param displayDate the display date
12540             * @param status the status
12541             * @return the number of matching blogs entries that the user has permission to view
12542             */
12543            @Override
12544            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
12545                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12546                            return countByG_LtD_S(groupId, displayDate, status);
12547                    }
12548    
12549                    StringBundler query = new StringBundler(4);
12550    
12551                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12552    
12553                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12554    
12555                    boolean bindDisplayDate = false;
12556    
12557                    if (displayDate == null) {
12558                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12559                    }
12560                    else {
12561                            bindDisplayDate = true;
12562    
12563                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12564                    }
12565    
12566                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12567    
12568                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12569                                    BlogsEntry.class.getName(),
12570                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12571    
12572                    Session session = null;
12573    
12574                    try {
12575                            session = openSession();
12576    
12577                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12578    
12579                            q.addScalar(COUNT_COLUMN_NAME,
12580                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12581    
12582                            QueryPos qPos = QueryPos.getInstance(q);
12583    
12584                            qPos.add(groupId);
12585    
12586                            if (bindDisplayDate) {
12587                                    qPos.add(new Timestamp(displayDate.getTime()));
12588                            }
12589    
12590                            qPos.add(status);
12591    
12592                            Long count = (Long)q.uniqueResult();
12593    
12594                            return count.intValue();
12595                    }
12596                    catch (Exception e) {
12597                            throw processException(e);
12598                    }
12599                    finally {
12600                            closeSession(session);
12601                    }
12602            }
12603    
12604            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12605            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
12606            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12607            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12608            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
12609                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12610                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12611                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
12612                            new String[] {
12613                                    Long.class.getName(), Date.class.getName(),
12614                                    Integer.class.getName(),
12615                                    
12616                            Integer.class.getName(), Integer.class.getName(),
12617                                    OrderByComparator.class.getName()
12618                            });
12619            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
12620                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12621                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12622                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
12623                            new String[] {
12624                                    Long.class.getName(), Date.class.getName(),
12625                                    Integer.class.getName()
12626                            });
12627    
12628            /**
12629             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12630             *
12631             * @param groupId the group ID
12632             * @param displayDate the display date
12633             * @param status the status
12634             * @return the matching blogs entries
12635             */
12636            @Override
12637            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12638                    int status) {
12639                    return findByG_LtD_NotS(groupId, displayDate, status,
12640                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12641            }
12642    
12643            /**
12644             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12645             *
12646             * <p>
12647             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12648             * </p>
12649             *
12650             * @param groupId the group ID
12651             * @param displayDate the display date
12652             * @param status the status
12653             * @param start the lower bound of the range of blogs entries
12654             * @param end the upper bound of the range of blogs entries (not inclusive)
12655             * @return the range of matching blogs entries
12656             */
12657            @Override
12658            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12659                    int status, int start, int end) {
12660                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
12661            }
12662    
12663            /**
12664             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12665             *
12666             * <p>
12667             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12668             * </p>
12669             *
12670             * @param groupId the group ID
12671             * @param displayDate the display date
12672             * @param status the status
12673             * @param start the lower bound of the range of blogs entries
12674             * @param end the upper bound of the range of blogs entries (not inclusive)
12675             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12676             * @return the ordered range of matching blogs entries
12677             */
12678            @Override
12679            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12680                    int status, int start, int end,
12681                    OrderByComparator<BlogsEntry> orderByComparator) {
12682                    return findByG_LtD_NotS(groupId, displayDate, status, start, end,
12683                            orderByComparator, true);
12684            }
12685    
12686            /**
12687             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12688             *
12689             * <p>
12690             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12691             * </p>
12692             *
12693             * @param groupId the group ID
12694             * @param displayDate the display date
12695             * @param status the status
12696             * @param start the lower bound of the range of blogs entries
12697             * @param end the upper bound of the range of blogs entries (not inclusive)
12698             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12699             * @param retrieveFromCache whether to retrieve from the finder cache
12700             * @return the ordered range of matching blogs entries
12701             */
12702            @Override
12703            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12704                    int status, int start, int end,
12705                    OrderByComparator<BlogsEntry> orderByComparator,
12706                    boolean retrieveFromCache) {
12707                    boolean pagination = true;
12708                    FinderPath finderPath = null;
12709                    Object[] finderArgs = null;
12710    
12711                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
12712                    finderArgs = new Object[] {
12713                                    groupId, displayDate, status,
12714                                    
12715                                    start, end, orderByComparator
12716                            };
12717    
12718                    List<BlogsEntry> list = null;
12719    
12720                    if (retrieveFromCache) {
12721                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
12722                                            finderArgs, this);
12723    
12724                            if ((list != null) && !list.isEmpty()) {
12725                                    for (BlogsEntry blogsEntry : list) {
12726                                            if ((groupId != blogsEntry.getGroupId()) ||
12727                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
12728                                                                                                                                            .getTime()) ||
12729                                                            (status == blogsEntry.getStatus())) {
12730                                                    list = null;
12731    
12732                                                    break;
12733                                            }
12734                                    }
12735                            }
12736                    }
12737    
12738                    if (list == null) {
12739                            StringBundler query = null;
12740    
12741                            if (orderByComparator != null) {
12742                                    query = new StringBundler(5 +
12743                                                    (orderByComparator.getOrderByFields().length * 3));
12744                            }
12745                            else {
12746                                    query = new StringBundler(5);
12747                            }
12748    
12749                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12750    
12751                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12752    
12753                            boolean bindDisplayDate = false;
12754    
12755                            if (displayDate == null) {
12756                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12757                            }
12758                            else {
12759                                    bindDisplayDate = true;
12760    
12761                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12762                            }
12763    
12764                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12765    
12766                            if (orderByComparator != null) {
12767                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12768                                            orderByComparator);
12769                            }
12770                            else
12771                             if (pagination) {
12772                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12773                            }
12774    
12775                            String sql = query.toString();
12776    
12777                            Session session = null;
12778    
12779                            try {
12780                                    session = openSession();
12781    
12782                                    Query q = session.createQuery(sql);
12783    
12784                                    QueryPos qPos = QueryPos.getInstance(q);
12785    
12786                                    qPos.add(groupId);
12787    
12788                                    if (bindDisplayDate) {
12789                                            qPos.add(new Timestamp(displayDate.getTime()));
12790                                    }
12791    
12792                                    qPos.add(status);
12793    
12794                                    if (!pagination) {
12795                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12796                                                            start, end, false);
12797    
12798                                            Collections.sort(list);
12799    
12800                                            list = Collections.unmodifiableList(list);
12801                                    }
12802                                    else {
12803                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12804                                                            start, end);
12805                                    }
12806    
12807                                    cacheResult(list);
12808    
12809                                    finderCache.putResult(finderPath, finderArgs, list);
12810                            }
12811                            catch (Exception e) {
12812                                    finderCache.removeResult(finderPath, finderArgs);
12813    
12814                                    throw processException(e);
12815                            }
12816                            finally {
12817                                    closeSession(session);
12818                            }
12819                    }
12820    
12821                    return list;
12822            }
12823    
12824            /**
12825             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12826             *
12827             * @param groupId the group ID
12828             * @param displayDate the display date
12829             * @param status the status
12830             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12831             * @return the first matching blogs entry
12832             * @throws NoSuchEntryException if a matching blogs entry could not be found
12833             */
12834            @Override
12835            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
12836                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12837                    throws NoSuchEntryException {
12838                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
12839                                    status, orderByComparator);
12840    
12841                    if (blogsEntry != null) {
12842                            return blogsEntry;
12843                    }
12844    
12845                    StringBundler msg = new StringBundler(8);
12846    
12847                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12848    
12849                    msg.append("groupId=");
12850                    msg.append(groupId);
12851    
12852                    msg.append(", displayDate=");
12853                    msg.append(displayDate);
12854    
12855                    msg.append(", status=");
12856                    msg.append(status);
12857    
12858                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12859    
12860                    throw new NoSuchEntryException(msg.toString());
12861            }
12862    
12863            /**
12864             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12865             *
12866             * @param groupId the group ID
12867             * @param displayDate the display date
12868             * @param status the status
12869             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12870             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12871             */
12872            @Override
12873            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
12874                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12875                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12876                                    0, 1, orderByComparator);
12877    
12878                    if (!list.isEmpty()) {
12879                            return list.get(0);
12880                    }
12881    
12882                    return null;
12883            }
12884    
12885            /**
12886             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12887             *
12888             * @param groupId the group ID
12889             * @param displayDate the display date
12890             * @param status the status
12891             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12892             * @return the last matching blogs entry
12893             * @throws NoSuchEntryException if a matching blogs entry could not be found
12894             */
12895            @Override
12896            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
12897                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12898                    throws NoSuchEntryException {
12899                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
12900                                    status, orderByComparator);
12901    
12902                    if (blogsEntry != null) {
12903                            return blogsEntry;
12904                    }
12905    
12906                    StringBundler msg = new StringBundler(8);
12907    
12908                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12909    
12910                    msg.append("groupId=");
12911                    msg.append(groupId);
12912    
12913                    msg.append(", displayDate=");
12914                    msg.append(displayDate);
12915    
12916                    msg.append(", status=");
12917                    msg.append(status);
12918    
12919                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12920    
12921                    throw new NoSuchEntryException(msg.toString());
12922            }
12923    
12924            /**
12925             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12926             *
12927             * @param groupId the group ID
12928             * @param displayDate the display date
12929             * @param status the status
12930             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12931             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12932             */
12933            @Override
12934            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
12935                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12936                    int count = countByG_LtD_NotS(groupId, displayDate, status);
12937    
12938                    if (count == 0) {
12939                            return null;
12940                    }
12941    
12942                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12943                                    count - 1, count, orderByComparator);
12944    
12945                    if (!list.isEmpty()) {
12946                            return list.get(0);
12947                    }
12948    
12949                    return null;
12950            }
12951    
12952            /**
12953             * 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;.
12954             *
12955             * @param entryId the primary key of the current blogs entry
12956             * @param groupId the group ID
12957             * @param displayDate the display date
12958             * @param status the status
12959             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12960             * @return the previous, current, and next blogs entry
12961             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12962             */
12963            @Override
12964            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
12965                    long groupId, Date displayDate, int status,
12966                    OrderByComparator<BlogsEntry> orderByComparator)
12967                    throws NoSuchEntryException {
12968                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12969    
12970                    Session session = null;
12971    
12972                    try {
12973                            session = openSession();
12974    
12975                            BlogsEntry[] array = new BlogsEntryImpl[3];
12976    
12977                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12978                                            groupId, displayDate, status, orderByComparator, true);
12979    
12980                            array[1] = blogsEntry;
12981    
12982                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12983                                            groupId, displayDate, status, orderByComparator, false);
12984    
12985                            return array;
12986                    }
12987                    catch (Exception e) {
12988                            throw processException(e);
12989                    }
12990                    finally {
12991                            closeSession(session);
12992                    }
12993            }
12994    
12995            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
12996                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12997                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12998                    StringBundler query = null;
12999    
13000                    if (orderByComparator != null) {
13001                            query = new StringBundler(6 +
13002                                            (orderByComparator.getOrderByFields().length * 6));
13003                    }
13004                    else {
13005                            query = new StringBundler(3);
13006                    }
13007    
13008                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13009    
13010                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13011    
13012                    boolean bindDisplayDate = false;
13013    
13014                    if (displayDate == null) {
13015                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13016                    }
13017                    else {
13018                            bindDisplayDate = true;
13019    
13020                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13021                    }
13022    
13023                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13024    
13025                    if (orderByComparator != null) {
13026                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13027    
13028                            if (orderByConditionFields.length > 0) {
13029                                    query.append(WHERE_AND);
13030                            }
13031    
13032                            for (int i = 0; i < orderByConditionFields.length; i++) {
13033                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13034                                    query.append(orderByConditionFields[i]);
13035    
13036                                    if ((i + 1) < orderByConditionFields.length) {
13037                                            if (orderByComparator.isAscending() ^ previous) {
13038                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13039                                            }
13040                                            else {
13041                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13042                                            }
13043                                    }
13044                                    else {
13045                                            if (orderByComparator.isAscending() ^ previous) {
13046                                                    query.append(WHERE_GREATER_THAN);
13047                                            }
13048                                            else {
13049                                                    query.append(WHERE_LESSER_THAN);
13050                                            }
13051                                    }
13052                            }
13053    
13054                            query.append(ORDER_BY_CLAUSE);
13055    
13056                            String[] orderByFields = orderByComparator.getOrderByFields();
13057    
13058                            for (int i = 0; i < orderByFields.length; i++) {
13059                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13060                                    query.append(orderByFields[i]);
13061    
13062                                    if ((i + 1) < orderByFields.length) {
13063                                            if (orderByComparator.isAscending() ^ previous) {
13064                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13065                                            }
13066                                            else {
13067                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13068                                            }
13069                                    }
13070                                    else {
13071                                            if (orderByComparator.isAscending() ^ previous) {
13072                                                    query.append(ORDER_BY_ASC);
13073                                            }
13074                                            else {
13075                                                    query.append(ORDER_BY_DESC);
13076                                            }
13077                                    }
13078                            }
13079                    }
13080                    else {
13081                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13082                    }
13083    
13084                    String sql = query.toString();
13085    
13086                    Query q = session.createQuery(sql);
13087    
13088                    q.setFirstResult(0);
13089                    q.setMaxResults(2);
13090    
13091                    QueryPos qPos = QueryPos.getInstance(q);
13092    
13093                    qPos.add(groupId);
13094    
13095                    if (bindDisplayDate) {
13096                            qPos.add(new Timestamp(displayDate.getTime()));
13097                    }
13098    
13099                    qPos.add(status);
13100    
13101                    if (orderByComparator != null) {
13102                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13103    
13104                            for (Object value : values) {
13105                                    qPos.add(value);
13106                            }
13107                    }
13108    
13109                    List<BlogsEntry> list = q.list();
13110    
13111                    if (list.size() == 2) {
13112                            return list.get(1);
13113                    }
13114                    else {
13115                            return null;
13116                    }
13117            }
13118    
13119            /**
13120             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13121             *
13122             * @param groupId the group ID
13123             * @param displayDate the display date
13124             * @param status the status
13125             * @return the matching blogs entries that the user has permission to view
13126             */
13127            @Override
13128            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13129                    Date displayDate, int status) {
13130                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
13131                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13132            }
13133    
13134            /**
13135             * 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;.
13136             *
13137             * <p>
13138             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13139             * </p>
13140             *
13141             * @param groupId the group ID
13142             * @param displayDate the display date
13143             * @param status the status
13144             * @param start the lower bound of the range of blogs entries
13145             * @param end the upper bound of the range of blogs entries (not inclusive)
13146             * @return the range of matching blogs entries that the user has permission to view
13147             */
13148            @Override
13149            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13150                    Date displayDate, int status, int start, int end) {
13151                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13152                            null);
13153            }
13154    
13155            /**
13156             * 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;.
13157             *
13158             * <p>
13159             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13160             * </p>
13161             *
13162             * @param groupId the group ID
13163             * @param displayDate the display date
13164             * @param status the status
13165             * @param start the lower bound of the range of blogs entries
13166             * @param end the upper bound of the range of blogs entries (not inclusive)
13167             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13168             * @return the ordered range of matching blogs entries that the user has permission to view
13169             */
13170            @Override
13171            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13172                    Date displayDate, int status, int start, int end,
13173                    OrderByComparator<BlogsEntry> orderByComparator) {
13174                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13175                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13176                                    orderByComparator);
13177                    }
13178    
13179                    StringBundler query = null;
13180    
13181                    if (orderByComparator != null) {
13182                            query = new StringBundler(5 +
13183                                            (orderByComparator.getOrderByFields().length * 3));
13184                    }
13185                    else {
13186                            query = new StringBundler(5);
13187                    }
13188    
13189                    if (getDB().isSupportsInlineDistinct()) {
13190                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13191                    }
13192                    else {
13193                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13194                    }
13195    
13196                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13197    
13198                    boolean bindDisplayDate = false;
13199    
13200                    if (displayDate == null) {
13201                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13202                    }
13203                    else {
13204                            bindDisplayDate = true;
13205    
13206                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13207                    }
13208    
13209                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13210    
13211                    if (!getDB().isSupportsInlineDistinct()) {
13212                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13213                    }
13214    
13215                    if (orderByComparator != null) {
13216                            if (getDB().isSupportsInlineDistinct()) {
13217                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13218                                            orderByComparator, true);
13219                            }
13220                            else {
13221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13222                                            orderByComparator, true);
13223                            }
13224                    }
13225                    else {
13226                            if (getDB().isSupportsInlineDistinct()) {
13227                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13228                            }
13229                            else {
13230                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13231                            }
13232                    }
13233    
13234                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13235                                    BlogsEntry.class.getName(),
13236                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13237    
13238                    Session session = null;
13239    
13240                    try {
13241                            session = openSession();
13242    
13243                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13244    
13245                            if (getDB().isSupportsInlineDistinct()) {
13246                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13247                            }
13248                            else {
13249                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13250                            }
13251    
13252                            QueryPos qPos = QueryPos.getInstance(q);
13253    
13254                            qPos.add(groupId);
13255    
13256                            if (bindDisplayDate) {
13257                                    qPos.add(new Timestamp(displayDate.getTime()));
13258                            }
13259    
13260                            qPos.add(status);
13261    
13262                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13263                    }
13264                    catch (Exception e) {
13265                            throw processException(e);
13266                    }
13267                    finally {
13268                            closeSession(session);
13269                    }
13270            }
13271    
13272            /**
13273             * 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;.
13274             *
13275             * @param entryId the primary key of the current blogs entry
13276             * @param groupId the group ID
13277             * @param displayDate the display date
13278             * @param status the status
13279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13280             * @return the previous, current, and next blogs entry
13281             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13282             */
13283            @Override
13284            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
13285                    long groupId, Date displayDate, int status,
13286                    OrderByComparator<BlogsEntry> orderByComparator)
13287                    throws NoSuchEntryException {
13288                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13289                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
13290                                    status, orderByComparator);
13291                    }
13292    
13293                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13294    
13295                    Session session = null;
13296    
13297                    try {
13298                            session = openSession();
13299    
13300                            BlogsEntry[] array = new BlogsEntryImpl[3];
13301    
13302                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13303                                            groupId, displayDate, status, orderByComparator, true);
13304    
13305                            array[1] = blogsEntry;
13306    
13307                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13308                                            groupId, displayDate, status, orderByComparator, false);
13309    
13310                            return array;
13311                    }
13312                    catch (Exception e) {
13313                            throw processException(e);
13314                    }
13315                    finally {
13316                            closeSession(session);
13317                    }
13318            }
13319    
13320            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
13321                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13322                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13323                    StringBundler query = null;
13324    
13325                    if (orderByComparator != null) {
13326                            query = new StringBundler(6 +
13327                                            (orderByComparator.getOrderByFields().length * 6));
13328                    }
13329                    else {
13330                            query = new StringBundler(3);
13331                    }
13332    
13333                    if (getDB().isSupportsInlineDistinct()) {
13334                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13335                    }
13336                    else {
13337                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13338                    }
13339    
13340                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13341    
13342                    boolean bindDisplayDate = false;
13343    
13344                    if (displayDate == null) {
13345                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13346                    }
13347                    else {
13348                            bindDisplayDate = true;
13349    
13350                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13351                    }
13352    
13353                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13354    
13355                    if (!getDB().isSupportsInlineDistinct()) {
13356                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13357                    }
13358    
13359                    if (orderByComparator != null) {
13360                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13361    
13362                            if (orderByConditionFields.length > 0) {
13363                                    query.append(WHERE_AND);
13364                            }
13365    
13366                            for (int i = 0; i < orderByConditionFields.length; i++) {
13367                                    if (getDB().isSupportsInlineDistinct()) {
13368                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13369                                    }
13370                                    else {
13371                                            query.append(_ORDER_BY_ENTITY_TABLE);
13372                                    }
13373    
13374                                    query.append(orderByConditionFields[i]);
13375    
13376                                    if ((i + 1) < orderByConditionFields.length) {
13377                                            if (orderByComparator.isAscending() ^ previous) {
13378                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13379                                            }
13380                                            else {
13381                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13382                                            }
13383                                    }
13384                                    else {
13385                                            if (orderByComparator.isAscending() ^ previous) {
13386                                                    query.append(WHERE_GREATER_THAN);
13387                                            }
13388                                            else {
13389                                                    query.append(WHERE_LESSER_THAN);
13390                                            }
13391                                    }
13392                            }
13393    
13394                            query.append(ORDER_BY_CLAUSE);
13395    
13396                            String[] orderByFields = orderByComparator.getOrderByFields();
13397    
13398                            for (int i = 0; i < orderByFields.length; i++) {
13399                                    if (getDB().isSupportsInlineDistinct()) {
13400                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13401                                    }
13402                                    else {
13403                                            query.append(_ORDER_BY_ENTITY_TABLE);
13404                                    }
13405    
13406                                    query.append(orderByFields[i]);
13407    
13408                                    if ((i + 1) < orderByFields.length) {
13409                                            if (orderByComparator.isAscending() ^ previous) {
13410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13411                                            }
13412                                            else {
13413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13414                                            }
13415                                    }
13416                                    else {
13417                                            if (orderByComparator.isAscending() ^ previous) {
13418                                                    query.append(ORDER_BY_ASC);
13419                                            }
13420                                            else {
13421                                                    query.append(ORDER_BY_DESC);
13422                                            }
13423                                    }
13424                            }
13425                    }
13426                    else {
13427                            if (getDB().isSupportsInlineDistinct()) {
13428                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13429                            }
13430                            else {
13431                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13432                            }
13433                    }
13434    
13435                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13436                                    BlogsEntry.class.getName(),
13437                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13438    
13439                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
13440    
13441                    q.setFirstResult(0);
13442                    q.setMaxResults(2);
13443    
13444                    if (getDB().isSupportsInlineDistinct()) {
13445                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13446                    }
13447                    else {
13448                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13449                    }
13450    
13451                    QueryPos qPos = QueryPos.getInstance(q);
13452    
13453                    qPos.add(groupId);
13454    
13455                    if (bindDisplayDate) {
13456                            qPos.add(new Timestamp(displayDate.getTime()));
13457                    }
13458    
13459                    qPos.add(status);
13460    
13461                    if (orderByComparator != null) {
13462                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13463    
13464                            for (Object value : values) {
13465                                    qPos.add(value);
13466                            }
13467                    }
13468    
13469                    List<BlogsEntry> list = q.list();
13470    
13471                    if (list.size() == 2) {
13472                            return list.get(1);
13473                    }
13474                    else {
13475                            return null;
13476                    }
13477            }
13478    
13479            /**
13480             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
13481             *
13482             * @param groupId the group ID
13483             * @param displayDate the display date
13484             * @param status the status
13485             */
13486            @Override
13487            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
13488                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
13489                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13490                            remove(blogsEntry);
13491                    }
13492            }
13493    
13494            /**
13495             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13496             *
13497             * @param groupId the group ID
13498             * @param displayDate the display date
13499             * @param status the status
13500             * @return the number of matching blogs entries
13501             */
13502            @Override
13503            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
13504                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
13505    
13506                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13507    
13508                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
13509    
13510                    if (count == null) {
13511                            StringBundler query = new StringBundler(4);
13512    
13513                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13514    
13515                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13516    
13517                            boolean bindDisplayDate = false;
13518    
13519                            if (displayDate == null) {
13520                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13521                            }
13522                            else {
13523                                    bindDisplayDate = true;
13524    
13525                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13526                            }
13527    
13528                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13529    
13530                            String sql = query.toString();
13531    
13532                            Session session = null;
13533    
13534                            try {
13535                                    session = openSession();
13536    
13537                                    Query q = session.createQuery(sql);
13538    
13539                                    QueryPos qPos = QueryPos.getInstance(q);
13540    
13541                                    qPos.add(groupId);
13542    
13543                                    if (bindDisplayDate) {
13544                                            qPos.add(new Timestamp(displayDate.getTime()));
13545                                    }
13546    
13547                                    qPos.add(status);
13548    
13549                                    count = (Long)q.uniqueResult();
13550    
13551                                    finderCache.putResult(finderPath, finderArgs, count);
13552                            }
13553                            catch (Exception e) {
13554                                    finderCache.removeResult(finderPath, finderArgs);
13555    
13556                                    throw processException(e);
13557                            }
13558                            finally {
13559                                    closeSession(session);
13560                            }
13561                    }
13562    
13563                    return count.intValue();
13564            }
13565    
13566            /**
13567             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13568             *
13569             * @param groupId the group ID
13570             * @param displayDate the display date
13571             * @param status the status
13572             * @return the number of matching blogs entries that the user has permission to view
13573             */
13574            @Override
13575            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
13576                    int status) {
13577                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13578                            return countByG_LtD_NotS(groupId, displayDate, status);
13579                    }
13580    
13581                    StringBundler query = new StringBundler(4);
13582    
13583                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13584    
13585                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13586    
13587                    boolean bindDisplayDate = false;
13588    
13589                    if (displayDate == null) {
13590                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13591                    }
13592                    else {
13593                            bindDisplayDate = true;
13594    
13595                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13596                    }
13597    
13598                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13599    
13600                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13601                                    BlogsEntry.class.getName(),
13602                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13603    
13604                    Session session = null;
13605    
13606                    try {
13607                            session = openSession();
13608    
13609                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13610    
13611                            q.addScalar(COUNT_COLUMN_NAME,
13612                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13613    
13614                            QueryPos qPos = QueryPos.getInstance(q);
13615    
13616                            qPos.add(groupId);
13617    
13618                            if (bindDisplayDate) {
13619                                    qPos.add(new Timestamp(displayDate.getTime()));
13620                            }
13621    
13622                            qPos.add(status);
13623    
13624                            Long count = (Long)q.uniqueResult();
13625    
13626                            return count.intValue();
13627                    }
13628                    catch (Exception e) {
13629                            throw processException(e);
13630                    }
13631                    finally {
13632                            closeSession(session);
13633                    }
13634            }
13635    
13636            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13637            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
13638            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13639            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
13640            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13641                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13642                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
13643                            new String[] {
13644                                    Long.class.getName(), Long.class.getName(),
13645                                    Integer.class.getName(),
13646                                    
13647                            Integer.class.getName(), Integer.class.getName(),
13648                                    OrderByComparator.class.getName()
13649                            });
13650            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13651                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13652                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
13653                            new String[] {
13654                                    Long.class.getName(), Long.class.getName(),
13655                                    Integer.class.getName()
13656                            },
13657                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
13658                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
13659                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
13660                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
13661                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
13662            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13663                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13664                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
13665                            new String[] {
13666                                    Long.class.getName(), Long.class.getName(),
13667                                    Integer.class.getName()
13668                            });
13669    
13670            /**
13671             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13672             *
13673             * @param companyId the company ID
13674             * @param userId the user ID
13675             * @param status the status
13676             * @return the matching blogs entries
13677             */
13678            @Override
13679            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
13680                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
13681                            QueryUtil.ALL_POS, null);
13682            }
13683    
13684            /**
13685             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13686             *
13687             * <p>
13688             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13689             * </p>
13690             *
13691             * @param companyId the company ID
13692             * @param userId the user ID
13693             * @param status the status
13694             * @param start the lower bound of the range of blogs entries
13695             * @param end the upper bound of the range of blogs entries (not inclusive)
13696             * @return the range of matching blogs entries
13697             */
13698            @Override
13699            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13700                    int status, int start, int end) {
13701                    return findByC_U_S(companyId, userId, status, start, end, null);
13702            }
13703    
13704            /**
13705             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13706             *
13707             * <p>
13708             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13709             * </p>
13710             *
13711             * @param companyId the company ID
13712             * @param userId the user ID
13713             * @param status the status
13714             * @param start the lower bound of the range of blogs entries
13715             * @param end the upper bound of the range of blogs entries (not inclusive)
13716             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13717             * @return the ordered range of matching blogs entries
13718             */
13719            @Override
13720            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13721                    int status, int start, int end,
13722                    OrderByComparator<BlogsEntry> orderByComparator) {
13723                    return findByC_U_S(companyId, userId, status, start, end,
13724                            orderByComparator, true);
13725            }
13726    
13727            /**
13728             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13729             *
13730             * <p>
13731             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13732             * </p>
13733             *
13734             * @param companyId the company ID
13735             * @param userId the user ID
13736             * @param status the status
13737             * @param start the lower bound of the range of blogs entries
13738             * @param end the upper bound of the range of blogs entries (not inclusive)
13739             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13740             * @param retrieveFromCache whether to retrieve from the finder cache
13741             * @return the ordered range of matching blogs entries
13742             */
13743            @Override
13744            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13745                    int status, int start, int end,
13746                    OrderByComparator<BlogsEntry> orderByComparator,
13747                    boolean retrieveFromCache) {
13748                    boolean pagination = true;
13749                    FinderPath finderPath = null;
13750                    Object[] finderArgs = null;
13751    
13752                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13753                                    (orderByComparator == null)) {
13754                            pagination = false;
13755                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
13756                            finderArgs = new Object[] { companyId, userId, status };
13757                    }
13758                    else {
13759                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
13760                            finderArgs = new Object[] {
13761                                            companyId, userId, status,
13762                                            
13763                                            start, end, orderByComparator
13764                                    };
13765                    }
13766    
13767                    List<BlogsEntry> list = null;
13768    
13769                    if (retrieveFromCache) {
13770                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
13771                                            finderArgs, this);
13772    
13773                            if ((list != null) && !list.isEmpty()) {
13774                                    for (BlogsEntry blogsEntry : list) {
13775                                            if ((companyId != blogsEntry.getCompanyId()) ||
13776                                                            (userId != blogsEntry.getUserId()) ||
13777                                                            (status != blogsEntry.getStatus())) {
13778                                                    list = null;
13779    
13780                                                    break;
13781                                            }
13782                                    }
13783                            }
13784                    }
13785    
13786                    if (list == null) {
13787                            StringBundler query = null;
13788    
13789                            if (orderByComparator != null) {
13790                                    query = new StringBundler(5 +
13791                                                    (orderByComparator.getOrderByFields().length * 3));
13792                            }
13793                            else {
13794                                    query = new StringBundler(5);
13795                            }
13796    
13797                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13798    
13799                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13800    
13801                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13802    
13803                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13804    
13805                            if (orderByComparator != null) {
13806                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13807                                            orderByComparator);
13808                            }
13809                            else
13810                             if (pagination) {
13811                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13812                            }
13813    
13814                            String sql = query.toString();
13815    
13816                            Session session = null;
13817    
13818                            try {
13819                                    session = openSession();
13820    
13821                                    Query q = session.createQuery(sql);
13822    
13823                                    QueryPos qPos = QueryPos.getInstance(q);
13824    
13825                                    qPos.add(companyId);
13826    
13827                                    qPos.add(userId);
13828    
13829                                    qPos.add(status);
13830    
13831                                    if (!pagination) {
13832                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13833                                                            start, end, false);
13834    
13835                                            Collections.sort(list);
13836    
13837                                            list = Collections.unmodifiableList(list);
13838                                    }
13839                                    else {
13840                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13841                                                            start, end);
13842                                    }
13843    
13844                                    cacheResult(list);
13845    
13846                                    finderCache.putResult(finderPath, finderArgs, list);
13847                            }
13848                            catch (Exception e) {
13849                                    finderCache.removeResult(finderPath, finderArgs);
13850    
13851                                    throw processException(e);
13852                            }
13853                            finally {
13854                                    closeSession(session);
13855                            }
13856                    }
13857    
13858                    return list;
13859            }
13860    
13861            /**
13862             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13863             *
13864             * @param companyId the company ID
13865             * @param userId the user ID
13866             * @param status the status
13867             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13868             * @return the first matching blogs entry
13869             * @throws NoSuchEntryException if a matching blogs entry could not be found
13870             */
13871            @Override
13872            public BlogsEntry findByC_U_S_First(long companyId, long userId,
13873                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13874                    throws NoSuchEntryException {
13875                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
13876                                    orderByComparator);
13877    
13878                    if (blogsEntry != null) {
13879                            return blogsEntry;
13880                    }
13881    
13882                    StringBundler msg = new StringBundler(8);
13883    
13884                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13885    
13886                    msg.append("companyId=");
13887                    msg.append(companyId);
13888    
13889                    msg.append(", userId=");
13890                    msg.append(userId);
13891    
13892                    msg.append(", status=");
13893                    msg.append(status);
13894    
13895                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13896    
13897                    throw new NoSuchEntryException(msg.toString());
13898            }
13899    
13900            /**
13901             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13902             *
13903             * @param companyId the company ID
13904             * @param userId the user ID
13905             * @param status the status
13906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13907             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13908             */
13909            @Override
13910            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
13911                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13912                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
13913                                    orderByComparator);
13914    
13915                    if (!list.isEmpty()) {
13916                            return list.get(0);
13917                    }
13918    
13919                    return null;
13920            }
13921    
13922            /**
13923             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13924             *
13925             * @param companyId the company ID
13926             * @param userId the user ID
13927             * @param status the status
13928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13929             * @return the last matching blogs entry
13930             * @throws NoSuchEntryException if a matching blogs entry could not be found
13931             */
13932            @Override
13933            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
13934                    OrderByComparator<BlogsEntry> orderByComparator)
13935                    throws NoSuchEntryException {
13936                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
13937                                    orderByComparator);
13938    
13939                    if (blogsEntry != null) {
13940                            return blogsEntry;
13941                    }
13942    
13943                    StringBundler msg = new StringBundler(8);
13944    
13945                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13946    
13947                    msg.append("companyId=");
13948                    msg.append(companyId);
13949    
13950                    msg.append(", userId=");
13951                    msg.append(userId);
13952    
13953                    msg.append(", status=");
13954                    msg.append(status);
13955    
13956                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13957    
13958                    throw new NoSuchEntryException(msg.toString());
13959            }
13960    
13961            /**
13962             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13963             *
13964             * @param companyId the company ID
13965             * @param userId the user ID
13966             * @param status the status
13967             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13968             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13969             */
13970            @Override
13971            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
13972                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13973                    int count = countByC_U_S(companyId, userId, status);
13974    
13975                    if (count == 0) {
13976                            return null;
13977                    }
13978    
13979                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
13980                                    count - 1, count, orderByComparator);
13981    
13982                    if (!list.isEmpty()) {
13983                            return list.get(0);
13984                    }
13985    
13986                    return null;
13987            }
13988    
13989            /**
13990             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13991             *
13992             * @param entryId the primary key of the current blogs entry
13993             * @param companyId the company ID
13994             * @param userId the user ID
13995             * @param status the status
13996             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13997             * @return the previous, current, and next blogs entry
13998             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13999             */
14000            @Override
14001            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
14002                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
14003                    throws NoSuchEntryException {
14004                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14005    
14006                    Session session = null;
14007    
14008                    try {
14009                            session = openSession();
14010    
14011                            BlogsEntry[] array = new BlogsEntryImpl[3];
14012    
14013                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14014                                            userId, status, orderByComparator, true);
14015    
14016                            array[1] = blogsEntry;
14017    
14018                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14019                                            userId, status, orderByComparator, false);
14020    
14021                            return array;
14022                    }
14023                    catch (Exception e) {
14024                            throw processException(e);
14025                    }
14026                    finally {
14027                            closeSession(session);
14028                    }
14029            }
14030    
14031            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
14032                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14033                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14034                    StringBundler query = null;
14035    
14036                    if (orderByComparator != null) {
14037                            query = new StringBundler(6 +
14038                                            (orderByComparator.getOrderByFields().length * 6));
14039                    }
14040                    else {
14041                            query = new StringBundler(3);
14042                    }
14043    
14044                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14045    
14046                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14047    
14048                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14049    
14050                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14051    
14052                    if (orderByComparator != null) {
14053                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14054    
14055                            if (orderByConditionFields.length > 0) {
14056                                    query.append(WHERE_AND);
14057                            }
14058    
14059                            for (int i = 0; i < orderByConditionFields.length; i++) {
14060                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14061                                    query.append(orderByConditionFields[i]);
14062    
14063                                    if ((i + 1) < orderByConditionFields.length) {
14064                                            if (orderByComparator.isAscending() ^ previous) {
14065                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14066                                            }
14067                                            else {
14068                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14069                                            }
14070                                    }
14071                                    else {
14072                                            if (orderByComparator.isAscending() ^ previous) {
14073                                                    query.append(WHERE_GREATER_THAN);
14074                                            }
14075                                            else {
14076                                                    query.append(WHERE_LESSER_THAN);
14077                                            }
14078                                    }
14079                            }
14080    
14081                            query.append(ORDER_BY_CLAUSE);
14082    
14083                            String[] orderByFields = orderByComparator.getOrderByFields();
14084    
14085                            for (int i = 0; i < orderByFields.length; i++) {
14086                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14087                                    query.append(orderByFields[i]);
14088    
14089                                    if ((i + 1) < orderByFields.length) {
14090                                            if (orderByComparator.isAscending() ^ previous) {
14091                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14092                                            }
14093                                            else {
14094                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14095                                            }
14096                                    }
14097                                    else {
14098                                            if (orderByComparator.isAscending() ^ previous) {
14099                                                    query.append(ORDER_BY_ASC);
14100                                            }
14101                                            else {
14102                                                    query.append(ORDER_BY_DESC);
14103                                            }
14104                                    }
14105                            }
14106                    }
14107                    else {
14108                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14109                    }
14110    
14111                    String sql = query.toString();
14112    
14113                    Query q = session.createQuery(sql);
14114    
14115                    q.setFirstResult(0);
14116                    q.setMaxResults(2);
14117    
14118                    QueryPos qPos = QueryPos.getInstance(q);
14119    
14120                    qPos.add(companyId);
14121    
14122                    qPos.add(userId);
14123    
14124                    qPos.add(status);
14125    
14126                    if (orderByComparator != null) {
14127                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14128    
14129                            for (Object value : values) {
14130                                    qPos.add(value);
14131                            }
14132                    }
14133    
14134                    List<BlogsEntry> list = q.list();
14135    
14136                    if (list.size() == 2) {
14137                            return list.get(1);
14138                    }
14139                    else {
14140                            return null;
14141                    }
14142            }
14143    
14144            /**
14145             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
14146             *
14147             * @param companyId the company ID
14148             * @param userId the user ID
14149             * @param status the status
14150             */
14151            @Override
14152            public void removeByC_U_S(long companyId, long userId, int status) {
14153                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
14154                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14155                            remove(blogsEntry);
14156                    }
14157            }
14158    
14159            /**
14160             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14161             *
14162             * @param companyId the company ID
14163             * @param userId the user ID
14164             * @param status the status
14165             * @return the number of matching blogs entries
14166             */
14167            @Override
14168            public int countByC_U_S(long companyId, long userId, int status) {
14169                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
14170    
14171                    Object[] finderArgs = new Object[] { companyId, userId, status };
14172    
14173                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14174    
14175                    if (count == null) {
14176                            StringBundler query = new StringBundler(4);
14177    
14178                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14179    
14180                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14181    
14182                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14183    
14184                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14185    
14186                            String sql = query.toString();
14187    
14188                            Session session = null;
14189    
14190                            try {
14191                                    session = openSession();
14192    
14193                                    Query q = session.createQuery(sql);
14194    
14195                                    QueryPos qPos = QueryPos.getInstance(q);
14196    
14197                                    qPos.add(companyId);
14198    
14199                                    qPos.add(userId);
14200    
14201                                    qPos.add(status);
14202    
14203                                    count = (Long)q.uniqueResult();
14204    
14205                                    finderCache.putResult(finderPath, finderArgs, count);
14206                            }
14207                            catch (Exception e) {
14208                                    finderCache.removeResult(finderPath, finderArgs);
14209    
14210                                    throw processException(e);
14211                            }
14212                            finally {
14213                                    closeSession(session);
14214                            }
14215                    }
14216    
14217                    return count.intValue();
14218            }
14219    
14220            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14221            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
14222            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
14223            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14224                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14225                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
14226                            new String[] {
14227                                    Long.class.getName(), Long.class.getName(),
14228                                    Integer.class.getName(),
14229                                    
14230                            Integer.class.getName(), Integer.class.getName(),
14231                                    OrderByComparator.class.getName()
14232                            });
14233            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
14234                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14235                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14236                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
14237                            new String[] {
14238                                    Long.class.getName(), Long.class.getName(),
14239                                    Integer.class.getName()
14240                            });
14241    
14242            /**
14243             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14244             *
14245             * @param companyId the company ID
14246             * @param userId the user ID
14247             * @param status the status
14248             * @return the matching blogs entries
14249             */
14250            @Override
14251            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14252                    int status) {
14253                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
14254                            QueryUtil.ALL_POS, null);
14255            }
14256    
14257            /**
14258             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14259             *
14260             * <p>
14261             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14262             * </p>
14263             *
14264             * @param companyId the company ID
14265             * @param userId the user ID
14266             * @param status the status
14267             * @param start the lower bound of the range of blogs entries
14268             * @param end the upper bound of the range of blogs entries (not inclusive)
14269             * @return the range of matching blogs entries
14270             */
14271            @Override
14272            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14273                    int status, int start, int end) {
14274                    return findByC_U_NotS(companyId, userId, status, start, end, null);
14275            }
14276    
14277            /**
14278             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14279             *
14280             * <p>
14281             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14282             * </p>
14283             *
14284             * @param companyId the company ID
14285             * @param userId the user ID
14286             * @param status the status
14287             * @param start the lower bound of the range of blogs entries
14288             * @param end the upper bound of the range of blogs entries (not inclusive)
14289             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14290             * @return the ordered range of matching blogs entries
14291             */
14292            @Override
14293            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14294                    int status, int start, int end,
14295                    OrderByComparator<BlogsEntry> orderByComparator) {
14296                    return findByC_U_NotS(companyId, userId, status, start, end,
14297                            orderByComparator, true);
14298            }
14299    
14300            /**
14301             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14302             *
14303             * <p>
14304             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14305             * </p>
14306             *
14307             * @param companyId the company ID
14308             * @param userId the user ID
14309             * @param status the status
14310             * @param start the lower bound of the range of blogs entries
14311             * @param end the upper bound of the range of blogs entries (not inclusive)
14312             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14313             * @param retrieveFromCache whether to retrieve from the finder cache
14314             * @return the ordered range of matching blogs entries
14315             */
14316            @Override
14317            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14318                    int status, int start, int end,
14319                    OrderByComparator<BlogsEntry> orderByComparator,
14320                    boolean retrieveFromCache) {
14321                    boolean pagination = true;
14322                    FinderPath finderPath = null;
14323                    Object[] finderArgs = null;
14324    
14325                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
14326                    finderArgs = new Object[] {
14327                                    companyId, userId, status,
14328                                    
14329                                    start, end, orderByComparator
14330                            };
14331    
14332                    List<BlogsEntry> list = null;
14333    
14334                    if (retrieveFromCache) {
14335                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14336                                            finderArgs, this);
14337    
14338                            if ((list != null) && !list.isEmpty()) {
14339                                    for (BlogsEntry blogsEntry : list) {
14340                                            if ((companyId != blogsEntry.getCompanyId()) ||
14341                                                            (userId != blogsEntry.getUserId()) ||
14342                                                            (status == blogsEntry.getStatus())) {
14343                                                    list = null;
14344    
14345                                                    break;
14346                                            }
14347                                    }
14348                            }
14349                    }
14350    
14351                    if (list == null) {
14352                            StringBundler query = null;
14353    
14354                            if (orderByComparator != null) {
14355                                    query = new StringBundler(5 +
14356                                                    (orderByComparator.getOrderByFields().length * 3));
14357                            }
14358                            else {
14359                                    query = new StringBundler(5);
14360                            }
14361    
14362                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14363    
14364                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14365    
14366                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14367    
14368                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14369    
14370                            if (orderByComparator != null) {
14371                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14372                                            orderByComparator);
14373                            }
14374                            else
14375                             if (pagination) {
14376                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14377                            }
14378    
14379                            String sql = query.toString();
14380    
14381                            Session session = null;
14382    
14383                            try {
14384                                    session = openSession();
14385    
14386                                    Query q = session.createQuery(sql);
14387    
14388                                    QueryPos qPos = QueryPos.getInstance(q);
14389    
14390                                    qPos.add(companyId);
14391    
14392                                    qPos.add(userId);
14393    
14394                                    qPos.add(status);
14395    
14396                                    if (!pagination) {
14397                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14398                                                            start, end, false);
14399    
14400                                            Collections.sort(list);
14401    
14402                                            list = Collections.unmodifiableList(list);
14403                                    }
14404                                    else {
14405                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14406                                                            start, end);
14407                                    }
14408    
14409                                    cacheResult(list);
14410    
14411                                    finderCache.putResult(finderPath, finderArgs, list);
14412                            }
14413                            catch (Exception e) {
14414                                    finderCache.removeResult(finderPath, finderArgs);
14415    
14416                                    throw processException(e);
14417                            }
14418                            finally {
14419                                    closeSession(session);
14420                            }
14421                    }
14422    
14423                    return list;
14424            }
14425    
14426            /**
14427             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14428             *
14429             * @param companyId the company ID
14430             * @param userId the user ID
14431             * @param status the status
14432             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14433             * @return the first matching blogs entry
14434             * @throws NoSuchEntryException if a matching blogs entry could not be found
14435             */
14436            @Override
14437            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
14438                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14439                    throws NoSuchEntryException {
14440                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
14441                                    status, orderByComparator);
14442    
14443                    if (blogsEntry != null) {
14444                            return blogsEntry;
14445                    }
14446    
14447                    StringBundler msg = new StringBundler(8);
14448    
14449                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14450    
14451                    msg.append("companyId=");
14452                    msg.append(companyId);
14453    
14454                    msg.append(", userId=");
14455                    msg.append(userId);
14456    
14457                    msg.append(", status=");
14458                    msg.append(status);
14459    
14460                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14461    
14462                    throw new NoSuchEntryException(msg.toString());
14463            }
14464    
14465            /**
14466             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14467             *
14468             * @param companyId the company ID
14469             * @param userId the user ID
14470             * @param status the status
14471             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14472             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14473             */
14474            @Override
14475            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
14476                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14477                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
14478                                    orderByComparator);
14479    
14480                    if (!list.isEmpty()) {
14481                            return list.get(0);
14482                    }
14483    
14484                    return null;
14485            }
14486    
14487            /**
14488             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14489             *
14490             * @param companyId the company ID
14491             * @param userId the user ID
14492             * @param status the status
14493             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14494             * @return the last matching blogs entry
14495             * @throws NoSuchEntryException if a matching blogs entry could not be found
14496             */
14497            @Override
14498            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
14499                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14500                    throws NoSuchEntryException {
14501                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
14502                                    orderByComparator);
14503    
14504                    if (blogsEntry != null) {
14505                            return blogsEntry;
14506                    }
14507    
14508                    StringBundler msg = new StringBundler(8);
14509    
14510                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14511    
14512                    msg.append("companyId=");
14513                    msg.append(companyId);
14514    
14515                    msg.append(", userId=");
14516                    msg.append(userId);
14517    
14518                    msg.append(", status=");
14519                    msg.append(status);
14520    
14521                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14522    
14523                    throw new NoSuchEntryException(msg.toString());
14524            }
14525    
14526            /**
14527             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14528             *
14529             * @param companyId the company ID
14530             * @param userId the user ID
14531             * @param status the status
14532             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14533             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14534             */
14535            @Override
14536            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
14537                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14538                    int count = countByC_U_NotS(companyId, userId, status);
14539    
14540                    if (count == 0) {
14541                            return null;
14542                    }
14543    
14544                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
14545                                    count - 1, count, orderByComparator);
14546    
14547                    if (!list.isEmpty()) {
14548                            return list.get(0);
14549                    }
14550    
14551                    return null;
14552            }
14553    
14554            /**
14555             * 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;.
14556             *
14557             * @param entryId the primary key of the current blogs entry
14558             * @param companyId the company ID
14559             * @param userId the user ID
14560             * @param status the status
14561             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14562             * @return the previous, current, and next blogs entry
14563             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14564             */
14565            @Override
14566            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
14567                    long companyId, long userId, int status,
14568                    OrderByComparator<BlogsEntry> orderByComparator)
14569                    throws NoSuchEntryException {
14570                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14571    
14572                    Session session = null;
14573    
14574                    try {
14575                            session = openSession();
14576    
14577                            BlogsEntry[] array = new BlogsEntryImpl[3];
14578    
14579                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14580                                            companyId, userId, status, orderByComparator, true);
14581    
14582                            array[1] = blogsEntry;
14583    
14584                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14585                                            companyId, userId, status, orderByComparator, false);
14586    
14587                            return array;
14588                    }
14589                    catch (Exception e) {
14590                            throw processException(e);
14591                    }
14592                    finally {
14593                            closeSession(session);
14594                    }
14595            }
14596    
14597            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
14598                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14599                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14600                    StringBundler query = null;
14601    
14602                    if (orderByComparator != null) {
14603                            query = new StringBundler(6 +
14604                                            (orderByComparator.getOrderByFields().length * 6));
14605                    }
14606                    else {
14607                            query = new StringBundler(3);
14608                    }
14609    
14610                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14611    
14612                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14613    
14614                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14615    
14616                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14617    
14618                    if (orderByComparator != null) {
14619                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14620    
14621                            if (orderByConditionFields.length > 0) {
14622                                    query.append(WHERE_AND);
14623                            }
14624    
14625                            for (int i = 0; i < orderByConditionFields.length; i++) {
14626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14627                                    query.append(orderByConditionFields[i]);
14628    
14629                                    if ((i + 1) < orderByConditionFields.length) {
14630                                            if (orderByComparator.isAscending() ^ previous) {
14631                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14632                                            }
14633                                            else {
14634                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14635                                            }
14636                                    }
14637                                    else {
14638                                            if (orderByComparator.isAscending() ^ previous) {
14639                                                    query.append(WHERE_GREATER_THAN);
14640                                            }
14641                                            else {
14642                                                    query.append(WHERE_LESSER_THAN);
14643                                            }
14644                                    }
14645                            }
14646    
14647                            query.append(ORDER_BY_CLAUSE);
14648    
14649                            String[] orderByFields = orderByComparator.getOrderByFields();
14650    
14651                            for (int i = 0; i < orderByFields.length; i++) {
14652                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14653                                    query.append(orderByFields[i]);
14654    
14655                                    if ((i + 1) < orderByFields.length) {
14656                                            if (orderByComparator.isAscending() ^ previous) {
14657                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14658                                            }
14659                                            else {
14660                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14661                                            }
14662                                    }
14663                                    else {
14664                                            if (orderByComparator.isAscending() ^ previous) {
14665                                                    query.append(ORDER_BY_ASC);
14666                                            }
14667                                            else {
14668                                                    query.append(ORDER_BY_DESC);
14669                                            }
14670                                    }
14671                            }
14672                    }
14673                    else {
14674                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14675                    }
14676    
14677                    String sql = query.toString();
14678    
14679                    Query q = session.createQuery(sql);
14680    
14681                    q.setFirstResult(0);
14682                    q.setMaxResults(2);
14683    
14684                    QueryPos qPos = QueryPos.getInstance(q);
14685    
14686                    qPos.add(companyId);
14687    
14688                    qPos.add(userId);
14689    
14690                    qPos.add(status);
14691    
14692                    if (orderByComparator != null) {
14693                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14694    
14695                            for (Object value : values) {
14696                                    qPos.add(value);
14697                            }
14698                    }
14699    
14700                    List<BlogsEntry> list = q.list();
14701    
14702                    if (list.size() == 2) {
14703                            return list.get(1);
14704                    }
14705                    else {
14706                            return null;
14707                    }
14708            }
14709    
14710            /**
14711             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
14712             *
14713             * @param companyId the company ID
14714             * @param userId the user ID
14715             * @param status the status
14716             */
14717            @Override
14718            public void removeByC_U_NotS(long companyId, long userId, int status) {
14719                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
14720                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14721                            remove(blogsEntry);
14722                    }
14723            }
14724    
14725            /**
14726             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14727             *
14728             * @param companyId the company ID
14729             * @param userId the user ID
14730             * @param status the status
14731             * @return the number of matching blogs entries
14732             */
14733            @Override
14734            public int countByC_U_NotS(long companyId, long userId, int status) {
14735                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
14736    
14737                    Object[] finderArgs = new Object[] { companyId, userId, status };
14738    
14739                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14740    
14741                    if (count == null) {
14742                            StringBundler query = new StringBundler(4);
14743    
14744                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14745    
14746                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14747    
14748                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14749    
14750                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14751    
14752                            String sql = query.toString();
14753    
14754                            Session session = null;
14755    
14756                            try {
14757                                    session = openSession();
14758    
14759                                    Query q = session.createQuery(sql);
14760    
14761                                    QueryPos qPos = QueryPos.getInstance(q);
14762    
14763                                    qPos.add(companyId);
14764    
14765                                    qPos.add(userId);
14766    
14767                                    qPos.add(status);
14768    
14769                                    count = (Long)q.uniqueResult();
14770    
14771                                    finderCache.putResult(finderPath, finderArgs, count);
14772                            }
14773                            catch (Exception e) {
14774                                    finderCache.removeResult(finderPath, finderArgs);
14775    
14776                                    throw processException(e);
14777                            }
14778                            finally {
14779                                    closeSession(session);
14780                            }
14781                    }
14782    
14783                    return count.intValue();
14784            }
14785    
14786            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14787            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
14788            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
14789            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14790                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14791                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
14792                            new String[] {
14793                                    Long.class.getName(), Date.class.getName(),
14794                                    Integer.class.getName(),
14795                                    
14796                            Integer.class.getName(), Integer.class.getName(),
14797                                    OrderByComparator.class.getName()
14798                            });
14799            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14800                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14801                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
14802                            new String[] {
14803                                    Long.class.getName(), Date.class.getName(),
14804                                    Integer.class.getName()
14805                            });
14806    
14807            /**
14808             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14809             *
14810             * @param companyId the company ID
14811             * @param displayDate the display date
14812             * @param status the status
14813             * @return the matching blogs entries
14814             */
14815            @Override
14816            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14817                    int status) {
14818                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
14819                            QueryUtil.ALL_POS, null);
14820            }
14821    
14822            /**
14823             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14824             *
14825             * <p>
14826             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14827             * </p>
14828             *
14829             * @param companyId the company ID
14830             * @param displayDate the display date
14831             * @param status the status
14832             * @param start the lower bound of the range of blogs entries
14833             * @param end the upper bound of the range of blogs entries (not inclusive)
14834             * @return the range of matching blogs entries
14835             */
14836            @Override
14837            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14838                    int status, int start, int end) {
14839                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
14840            }
14841    
14842            /**
14843             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14844             *
14845             * <p>
14846             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14847             * </p>
14848             *
14849             * @param companyId the company ID
14850             * @param displayDate the display date
14851             * @param status the status
14852             * @param start the lower bound of the range of blogs entries
14853             * @param end the upper bound of the range of blogs entries (not inclusive)
14854             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14855             * @return the ordered range of matching blogs entries
14856             */
14857            @Override
14858            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14859                    int status, int start, int end,
14860                    OrderByComparator<BlogsEntry> orderByComparator) {
14861                    return findByC_LtD_S(companyId, displayDate, status, start, end,
14862                            orderByComparator, true);
14863            }
14864    
14865            /**
14866             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14867             *
14868             * <p>
14869             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14870             * </p>
14871             *
14872             * @param companyId the company ID
14873             * @param displayDate the display date
14874             * @param status the status
14875             * @param start the lower bound of the range of blogs entries
14876             * @param end the upper bound of the range of blogs entries (not inclusive)
14877             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14878             * @param retrieveFromCache whether to retrieve from the finder cache
14879             * @return the ordered range of matching blogs entries
14880             */
14881            @Override
14882            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14883                    int status, int start, int end,
14884                    OrderByComparator<BlogsEntry> orderByComparator,
14885                    boolean retrieveFromCache) {
14886                    boolean pagination = true;
14887                    FinderPath finderPath = null;
14888                    Object[] finderArgs = null;
14889    
14890                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
14891                    finderArgs = new Object[] {
14892                                    companyId, displayDate, status,
14893                                    
14894                                    start, end, orderByComparator
14895                            };
14896    
14897                    List<BlogsEntry> list = null;
14898    
14899                    if (retrieveFromCache) {
14900                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14901                                            finderArgs, this);
14902    
14903                            if ((list != null) && !list.isEmpty()) {
14904                                    for (BlogsEntry blogsEntry : list) {
14905                                            if ((companyId != blogsEntry.getCompanyId()) ||
14906                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
14907                                                                                                                                            .getTime()) ||
14908                                                            (status != blogsEntry.getStatus())) {
14909                                                    list = null;
14910    
14911                                                    break;
14912                                            }
14913                                    }
14914                            }
14915                    }
14916    
14917                    if (list == null) {
14918                            StringBundler query = null;
14919    
14920                            if (orderByComparator != null) {
14921                                    query = new StringBundler(5 +
14922                                                    (orderByComparator.getOrderByFields().length * 3));
14923                            }
14924                            else {
14925                                    query = new StringBundler(5);
14926                            }
14927    
14928                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14929    
14930                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14931    
14932                            boolean bindDisplayDate = false;
14933    
14934                            if (displayDate == null) {
14935                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14936                            }
14937                            else {
14938                                    bindDisplayDate = true;
14939    
14940                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14941                            }
14942    
14943                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14944    
14945                            if (orderByComparator != null) {
14946                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14947                                            orderByComparator);
14948                            }
14949                            else
14950                             if (pagination) {
14951                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14952                            }
14953    
14954                            String sql = query.toString();
14955    
14956                            Session session = null;
14957    
14958                            try {
14959                                    session = openSession();
14960    
14961                                    Query q = session.createQuery(sql);
14962    
14963                                    QueryPos qPos = QueryPos.getInstance(q);
14964    
14965                                    qPos.add(companyId);
14966    
14967                                    if (bindDisplayDate) {
14968                                            qPos.add(new Timestamp(displayDate.getTime()));
14969                                    }
14970    
14971                                    qPos.add(status);
14972    
14973                                    if (!pagination) {
14974                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14975                                                            start, end, false);
14976    
14977                                            Collections.sort(list);
14978    
14979                                            list = Collections.unmodifiableList(list);
14980                                    }
14981                                    else {
14982                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14983                                                            start, end);
14984                                    }
14985    
14986                                    cacheResult(list);
14987    
14988                                    finderCache.putResult(finderPath, finderArgs, list);
14989                            }
14990                            catch (Exception e) {
14991                                    finderCache.removeResult(finderPath, finderArgs);
14992    
14993                                    throw processException(e);
14994                            }
14995                            finally {
14996                                    closeSession(session);
14997                            }
14998                    }
14999    
15000                    return list;
15001            }
15002    
15003            /**
15004             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15005             *
15006             * @param companyId the company ID
15007             * @param displayDate the display date
15008             * @param status the status
15009             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15010             * @return the first matching blogs entry
15011             * @throws NoSuchEntryException if a matching blogs entry could not be found
15012             */
15013            @Override
15014            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
15015                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15016                    throws NoSuchEntryException {
15017                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
15018                                    status, orderByComparator);
15019    
15020                    if (blogsEntry != null) {
15021                            return blogsEntry;
15022                    }
15023    
15024                    StringBundler msg = new StringBundler(8);
15025    
15026                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15027    
15028                    msg.append("companyId=");
15029                    msg.append(companyId);
15030    
15031                    msg.append(", displayDate=");
15032                    msg.append(displayDate);
15033    
15034                    msg.append(", status=");
15035                    msg.append(status);
15036    
15037                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15038    
15039                    throw new NoSuchEntryException(msg.toString());
15040            }
15041    
15042            /**
15043             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15044             *
15045             * @param companyId the company ID
15046             * @param displayDate the display date
15047             * @param status the status
15048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15049             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15050             */
15051            @Override
15052            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
15053                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15054                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15055                                    0, 1, orderByComparator);
15056    
15057                    if (!list.isEmpty()) {
15058                            return list.get(0);
15059                    }
15060    
15061                    return null;
15062            }
15063    
15064            /**
15065             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15066             *
15067             * @param companyId the company ID
15068             * @param displayDate the display date
15069             * @param status the status
15070             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15071             * @return the last matching blogs entry
15072             * @throws NoSuchEntryException if a matching blogs entry could not be found
15073             */
15074            @Override
15075            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
15076                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15077                    throws NoSuchEntryException {
15078                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
15079                                    status, orderByComparator);
15080    
15081                    if (blogsEntry != null) {
15082                            return blogsEntry;
15083                    }
15084    
15085                    StringBundler msg = new StringBundler(8);
15086    
15087                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15088    
15089                    msg.append("companyId=");
15090                    msg.append(companyId);
15091    
15092                    msg.append(", displayDate=");
15093                    msg.append(displayDate);
15094    
15095                    msg.append(", status=");
15096                    msg.append(status);
15097    
15098                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15099    
15100                    throw new NoSuchEntryException(msg.toString());
15101            }
15102    
15103            /**
15104             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15105             *
15106             * @param companyId the company ID
15107             * @param displayDate the display date
15108             * @param status the status
15109             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15110             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15111             */
15112            @Override
15113            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
15114                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15115                    int count = countByC_LtD_S(companyId, displayDate, status);
15116    
15117                    if (count == 0) {
15118                            return null;
15119                    }
15120    
15121                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15122                                    count - 1, count, orderByComparator);
15123    
15124                    if (!list.isEmpty()) {
15125                            return list.get(0);
15126                    }
15127    
15128                    return null;
15129            }
15130    
15131            /**
15132             * 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;.
15133             *
15134             * @param entryId the primary key of the current blogs entry
15135             * @param companyId the company ID
15136             * @param displayDate the display date
15137             * @param status the status
15138             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15139             * @return the previous, current, and next blogs entry
15140             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15141             */
15142            @Override
15143            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
15144                    Date displayDate, int status,
15145                    OrderByComparator<BlogsEntry> orderByComparator)
15146                    throws NoSuchEntryException {
15147                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15148    
15149                    Session session = null;
15150    
15151                    try {
15152                            session = openSession();
15153    
15154                            BlogsEntry[] array = new BlogsEntryImpl[3];
15155    
15156                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15157                                            displayDate, status, orderByComparator, true);
15158    
15159                            array[1] = blogsEntry;
15160    
15161                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15162                                            displayDate, status, orderByComparator, false);
15163    
15164                            return array;
15165                    }
15166                    catch (Exception e) {
15167                            throw processException(e);
15168                    }
15169                    finally {
15170                            closeSession(session);
15171                    }
15172            }
15173    
15174            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
15175                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15176                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15177                    StringBundler query = null;
15178    
15179                    if (orderByComparator != null) {
15180                            query = new StringBundler(6 +
15181                                            (orderByComparator.getOrderByFields().length * 6));
15182                    }
15183                    else {
15184                            query = new StringBundler(3);
15185                    }
15186    
15187                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15188    
15189                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15190    
15191                    boolean bindDisplayDate = false;
15192    
15193                    if (displayDate == null) {
15194                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15195                    }
15196                    else {
15197                            bindDisplayDate = true;
15198    
15199                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15200                    }
15201    
15202                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15203    
15204                    if (orderByComparator != null) {
15205                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15206    
15207                            if (orderByConditionFields.length > 0) {
15208                                    query.append(WHERE_AND);
15209                            }
15210    
15211                            for (int i = 0; i < orderByConditionFields.length; i++) {
15212                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15213                                    query.append(orderByConditionFields[i]);
15214    
15215                                    if ((i + 1) < orderByConditionFields.length) {
15216                                            if (orderByComparator.isAscending() ^ previous) {
15217                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15218                                            }
15219                                            else {
15220                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15221                                            }
15222                                    }
15223                                    else {
15224                                            if (orderByComparator.isAscending() ^ previous) {
15225                                                    query.append(WHERE_GREATER_THAN);
15226                                            }
15227                                            else {
15228                                                    query.append(WHERE_LESSER_THAN);
15229                                            }
15230                                    }
15231                            }
15232    
15233                            query.append(ORDER_BY_CLAUSE);
15234    
15235                            String[] orderByFields = orderByComparator.getOrderByFields();
15236    
15237                            for (int i = 0; i < orderByFields.length; i++) {
15238                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15239                                    query.append(orderByFields[i]);
15240    
15241                                    if ((i + 1) < orderByFields.length) {
15242                                            if (orderByComparator.isAscending() ^ previous) {
15243                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15244                                            }
15245                                            else {
15246                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15247                                            }
15248                                    }
15249                                    else {
15250                                            if (orderByComparator.isAscending() ^ previous) {
15251                                                    query.append(ORDER_BY_ASC);
15252                                            }
15253                                            else {
15254                                                    query.append(ORDER_BY_DESC);
15255                                            }
15256                                    }
15257                            }
15258                    }
15259                    else {
15260                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15261                    }
15262    
15263                    String sql = query.toString();
15264    
15265                    Query q = session.createQuery(sql);
15266    
15267                    q.setFirstResult(0);
15268                    q.setMaxResults(2);
15269    
15270                    QueryPos qPos = QueryPos.getInstance(q);
15271    
15272                    qPos.add(companyId);
15273    
15274                    if (bindDisplayDate) {
15275                            qPos.add(new Timestamp(displayDate.getTime()));
15276                    }
15277    
15278                    qPos.add(status);
15279    
15280                    if (orderByComparator != null) {
15281                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15282    
15283                            for (Object value : values) {
15284                                    qPos.add(value);
15285                            }
15286                    }
15287    
15288                    List<BlogsEntry> list = q.list();
15289    
15290                    if (list.size() == 2) {
15291                            return list.get(1);
15292                    }
15293                    else {
15294                            return null;
15295                    }
15296            }
15297    
15298            /**
15299             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15300             *
15301             * @param companyId the company ID
15302             * @param displayDate the display date
15303             * @param status the status
15304             */
15305            @Override
15306            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
15307                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
15308                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15309                            remove(blogsEntry);
15310                    }
15311            }
15312    
15313            /**
15314             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15315             *
15316             * @param companyId the company ID
15317             * @param displayDate the display date
15318             * @param status the status
15319             * @return the number of matching blogs entries
15320             */
15321            @Override
15322            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
15323                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
15324    
15325                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15326    
15327                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15328    
15329                    if (count == null) {
15330                            StringBundler query = new StringBundler(4);
15331    
15332                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15333    
15334                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15335    
15336                            boolean bindDisplayDate = false;
15337    
15338                            if (displayDate == null) {
15339                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15340                            }
15341                            else {
15342                                    bindDisplayDate = true;
15343    
15344                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15345                            }
15346    
15347                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15348    
15349                            String sql = query.toString();
15350    
15351                            Session session = null;
15352    
15353                            try {
15354                                    session = openSession();
15355    
15356                                    Query q = session.createQuery(sql);
15357    
15358                                    QueryPos qPos = QueryPos.getInstance(q);
15359    
15360                                    qPos.add(companyId);
15361    
15362                                    if (bindDisplayDate) {
15363                                            qPos.add(new Timestamp(displayDate.getTime()));
15364                                    }
15365    
15366                                    qPos.add(status);
15367    
15368                                    count = (Long)q.uniqueResult();
15369    
15370                                    finderCache.putResult(finderPath, finderArgs, count);
15371                            }
15372                            catch (Exception e) {
15373                                    finderCache.removeResult(finderPath, finderArgs);
15374    
15375                                    throw processException(e);
15376                            }
15377                            finally {
15378                                    closeSession(session);
15379                            }
15380                    }
15381    
15382                    return count.intValue();
15383            }
15384    
15385            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15386            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15387            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15388            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15389            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
15390                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15391                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15392                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
15393                            new String[] {
15394                                    Long.class.getName(), Date.class.getName(),
15395                                    Integer.class.getName(),
15396                                    
15397                            Integer.class.getName(), Integer.class.getName(),
15398                                    OrderByComparator.class.getName()
15399                            });
15400            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
15401                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15402                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15403                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
15404                            new String[] {
15405                                    Long.class.getName(), Date.class.getName(),
15406                                    Integer.class.getName()
15407                            });
15408    
15409            /**
15410             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15411             *
15412             * @param companyId the company ID
15413             * @param displayDate the display date
15414             * @param status the status
15415             * @return the matching blogs entries
15416             */
15417            @Override
15418            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15419                    int status) {
15420                    return findByC_LtD_NotS(companyId, displayDate, status,
15421                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15422            }
15423    
15424            /**
15425             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15426             *
15427             * <p>
15428             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
15429             * </p>
15430             *
15431             * @param companyId the company ID
15432             * @param displayDate the display date
15433             * @param status the status
15434             * @param start the lower bound of the range of blogs entries
15435             * @param end the upper bound of the range of blogs entries (not inclusive)
15436             * @return the range of matching blogs entries
15437             */
15438            @Override
15439            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15440                    int status, int start, int end) {
15441                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
15442            }
15443    
15444            /**
15445             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15446             *
15447             * <p>
15448             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
15449             * </p>
15450             *
15451             * @param companyId the company ID
15452             * @param displayDate the display date
15453             * @param status the status
15454             * @param start the lower bound of the range of blogs entries
15455             * @param end the upper bound of the range of blogs entries (not inclusive)
15456             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15457             * @return the ordered range of matching blogs entries
15458             */
15459            @Override
15460            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15461                    int status, int start, int end,
15462                    OrderByComparator<BlogsEntry> orderByComparator) {
15463                    return findByC_LtD_NotS(companyId, displayDate, status, start, end,
15464                            orderByComparator, true);
15465            }
15466    
15467            /**
15468             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15469             *
15470             * <p>
15471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
15472             * </p>
15473             *
15474             * @param companyId the company ID
15475             * @param displayDate the display date
15476             * @param status the status
15477             * @param start the lower bound of the range of blogs entries
15478             * @param end the upper bound of the range of blogs entries (not inclusive)
15479             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15480             * @param retrieveFromCache whether to retrieve from the finder cache
15481             * @return the ordered range of matching blogs entries
15482             */
15483            @Override
15484            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15485                    int status, int start, int end,
15486                    OrderByComparator<BlogsEntry> orderByComparator,
15487                    boolean retrieveFromCache) {
15488                    boolean pagination = true;
15489                    FinderPath finderPath = null;
15490                    Object[] finderArgs = null;
15491    
15492                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
15493                    finderArgs = new Object[] {
15494                                    companyId, displayDate, status,
15495                                    
15496                                    start, end, orderByComparator
15497                            };
15498    
15499                    List<BlogsEntry> list = null;
15500    
15501                    if (retrieveFromCache) {
15502                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
15503                                            finderArgs, this);
15504    
15505                            if ((list != null) && !list.isEmpty()) {
15506                                    for (BlogsEntry blogsEntry : list) {
15507                                            if ((companyId != blogsEntry.getCompanyId()) ||
15508                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
15509                                                                                                                                            .getTime()) ||
15510                                                            (status == blogsEntry.getStatus())) {
15511                                                    list = null;
15512    
15513                                                    break;
15514                                            }
15515                                    }
15516                            }
15517                    }
15518    
15519                    if (list == null) {
15520                            StringBundler query = null;
15521    
15522                            if (orderByComparator != null) {
15523                                    query = new StringBundler(5 +
15524                                                    (orderByComparator.getOrderByFields().length * 3));
15525                            }
15526                            else {
15527                                    query = new StringBundler(5);
15528                            }
15529    
15530                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15531    
15532                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15533    
15534                            boolean bindDisplayDate = false;
15535    
15536                            if (displayDate == null) {
15537                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15538                            }
15539                            else {
15540                                    bindDisplayDate = true;
15541    
15542                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15543                            }
15544    
15545                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15546    
15547                            if (orderByComparator != null) {
15548                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15549                                            orderByComparator);
15550                            }
15551                            else
15552                             if (pagination) {
15553                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15554                            }
15555    
15556                            String sql = query.toString();
15557    
15558                            Session session = null;
15559    
15560                            try {
15561                                    session = openSession();
15562    
15563                                    Query q = session.createQuery(sql);
15564    
15565                                    QueryPos qPos = QueryPos.getInstance(q);
15566    
15567                                    qPos.add(companyId);
15568    
15569                                    if (bindDisplayDate) {
15570                                            qPos.add(new Timestamp(displayDate.getTime()));
15571                                    }
15572    
15573                                    qPos.add(status);
15574    
15575                                    if (!pagination) {
15576                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15577                                                            start, end, false);
15578    
15579                                            Collections.sort(list);
15580    
15581                                            list = Collections.unmodifiableList(list);
15582                                    }
15583                                    else {
15584                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15585                                                            start, end);
15586                                    }
15587    
15588                                    cacheResult(list);
15589    
15590                                    finderCache.putResult(finderPath, finderArgs, list);
15591                            }
15592                            catch (Exception e) {
15593                                    finderCache.removeResult(finderPath, finderArgs);
15594    
15595                                    throw processException(e);
15596                            }
15597                            finally {
15598                                    closeSession(session);
15599                            }
15600                    }
15601    
15602                    return list;
15603            }
15604    
15605            /**
15606             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15607             *
15608             * @param companyId the company ID
15609             * @param displayDate the display date
15610             * @param status the status
15611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15612             * @return the first matching blogs entry
15613             * @throws NoSuchEntryException if a matching blogs entry could not be found
15614             */
15615            @Override
15616            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
15617                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15618                    throws NoSuchEntryException {
15619                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
15620                                    status, orderByComparator);
15621    
15622                    if (blogsEntry != null) {
15623                            return blogsEntry;
15624                    }
15625    
15626                    StringBundler msg = new StringBundler(8);
15627    
15628                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15629    
15630                    msg.append("companyId=");
15631                    msg.append(companyId);
15632    
15633                    msg.append(", displayDate=");
15634                    msg.append(displayDate);
15635    
15636                    msg.append(", status=");
15637                    msg.append(status);
15638    
15639                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15640    
15641                    throw new NoSuchEntryException(msg.toString());
15642            }
15643    
15644            /**
15645             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15646             *
15647             * @param companyId the company ID
15648             * @param displayDate the display date
15649             * @param status the status
15650             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15651             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15652             */
15653            @Override
15654            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
15655                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15656                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15657                                    status, 0, 1, orderByComparator);
15658    
15659                    if (!list.isEmpty()) {
15660                            return list.get(0);
15661                    }
15662    
15663                    return null;
15664            }
15665    
15666            /**
15667             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15668             *
15669             * @param companyId the company ID
15670             * @param displayDate the display date
15671             * @param status the status
15672             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15673             * @return the last matching blogs entry
15674             * @throws NoSuchEntryException if a matching blogs entry could not be found
15675             */
15676            @Override
15677            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
15678                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15679                    throws NoSuchEntryException {
15680                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
15681                                    status, orderByComparator);
15682    
15683                    if (blogsEntry != null) {
15684                            return blogsEntry;
15685                    }
15686    
15687                    StringBundler msg = new StringBundler(8);
15688    
15689                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15690    
15691                    msg.append("companyId=");
15692                    msg.append(companyId);
15693    
15694                    msg.append(", displayDate=");
15695                    msg.append(displayDate);
15696    
15697                    msg.append(", status=");
15698                    msg.append(status);
15699    
15700                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15701    
15702                    throw new NoSuchEntryException(msg.toString());
15703            }
15704    
15705            /**
15706             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15707             *
15708             * @param companyId the company ID
15709             * @param displayDate the display date
15710             * @param status the status
15711             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15712             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15713             */
15714            @Override
15715            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
15716                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15717                    int count = countByC_LtD_NotS(companyId, displayDate, status);
15718    
15719                    if (count == 0) {
15720                            return null;
15721                    }
15722    
15723                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15724                                    status, count - 1, count, orderByComparator);
15725    
15726                    if (!list.isEmpty()) {
15727                            return list.get(0);
15728                    }
15729    
15730                    return null;
15731            }
15732    
15733            /**
15734             * 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;.
15735             *
15736             * @param entryId the primary key of the current blogs entry
15737             * @param companyId the company ID
15738             * @param displayDate the display date
15739             * @param status the status
15740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15741             * @return the previous, current, and next blogs entry
15742             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15743             */
15744            @Override
15745            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
15746                    long companyId, Date displayDate, int status,
15747                    OrderByComparator<BlogsEntry> orderByComparator)
15748                    throws NoSuchEntryException {
15749                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15750    
15751                    Session session = null;
15752    
15753                    try {
15754                            session = openSession();
15755    
15756                            BlogsEntry[] array = new BlogsEntryImpl[3];
15757    
15758                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15759                                            companyId, displayDate, status, orderByComparator, true);
15760    
15761                            array[1] = blogsEntry;
15762    
15763                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15764                                            companyId, displayDate, status, orderByComparator, false);
15765    
15766                            return array;
15767                    }
15768                    catch (Exception e) {
15769                            throw processException(e);
15770                    }
15771                    finally {
15772                            closeSession(session);
15773                    }
15774            }
15775    
15776            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
15777                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15778                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15779                    StringBundler query = null;
15780    
15781                    if (orderByComparator != null) {
15782                            query = new StringBundler(6 +
15783                                            (orderByComparator.getOrderByFields().length * 6));
15784                    }
15785                    else {
15786                            query = new StringBundler(3);
15787                    }
15788    
15789                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15790    
15791                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15792    
15793                    boolean bindDisplayDate = false;
15794    
15795                    if (displayDate == null) {
15796                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15797                    }
15798                    else {
15799                            bindDisplayDate = true;
15800    
15801                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15802                    }
15803    
15804                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15805    
15806                    if (orderByComparator != null) {
15807                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15808    
15809                            if (orderByConditionFields.length > 0) {
15810                                    query.append(WHERE_AND);
15811                            }
15812    
15813                            for (int i = 0; i < orderByConditionFields.length; i++) {
15814                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15815                                    query.append(orderByConditionFields[i]);
15816    
15817                                    if ((i + 1) < orderByConditionFields.length) {
15818                                            if (orderByComparator.isAscending() ^ previous) {
15819                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15820                                            }
15821                                            else {
15822                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15823                                            }
15824                                    }
15825                                    else {
15826                                            if (orderByComparator.isAscending() ^ previous) {
15827                                                    query.append(WHERE_GREATER_THAN);
15828                                            }
15829                                            else {
15830                                                    query.append(WHERE_LESSER_THAN);
15831                                            }
15832                                    }
15833                            }
15834    
15835                            query.append(ORDER_BY_CLAUSE);
15836    
15837                            String[] orderByFields = orderByComparator.getOrderByFields();
15838    
15839                            for (int i = 0; i < orderByFields.length; i++) {
15840                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15841                                    query.append(orderByFields[i]);
15842    
15843                                    if ((i + 1) < orderByFields.length) {
15844                                            if (orderByComparator.isAscending() ^ previous) {
15845                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15846                                            }
15847                                            else {
15848                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15849                                            }
15850                                    }
15851                                    else {
15852                                            if (orderByComparator.isAscending() ^ previous) {
15853                                                    query.append(ORDER_BY_ASC);
15854                                            }
15855                                            else {
15856                                                    query.append(ORDER_BY_DESC);
15857                                            }
15858                                    }
15859                            }
15860                    }
15861                    else {
15862                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15863                    }
15864    
15865                    String sql = query.toString();
15866    
15867                    Query q = session.createQuery(sql);
15868    
15869                    q.setFirstResult(0);
15870                    q.setMaxResults(2);
15871    
15872                    QueryPos qPos = QueryPos.getInstance(q);
15873    
15874                    qPos.add(companyId);
15875    
15876                    if (bindDisplayDate) {
15877                            qPos.add(new Timestamp(displayDate.getTime()));
15878                    }
15879    
15880                    qPos.add(status);
15881    
15882                    if (orderByComparator != null) {
15883                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15884    
15885                            for (Object value : values) {
15886                                    qPos.add(value);
15887                            }
15888                    }
15889    
15890                    List<BlogsEntry> list = q.list();
15891    
15892                    if (list.size() == 2) {
15893                            return list.get(1);
15894                    }
15895                    else {
15896                            return null;
15897                    }
15898            }
15899    
15900            /**
15901             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15902             *
15903             * @param companyId the company ID
15904             * @param displayDate the display date
15905             * @param status the status
15906             */
15907            @Override
15908            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
15909                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
15910                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15911                            remove(blogsEntry);
15912                    }
15913            }
15914    
15915            /**
15916             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15917             *
15918             * @param companyId the company ID
15919             * @param displayDate the display date
15920             * @param status the status
15921             * @return the number of matching blogs entries
15922             */
15923            @Override
15924            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
15925                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
15926    
15927                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15928    
15929                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15930    
15931                    if (count == null) {
15932                            StringBundler query = new StringBundler(4);
15933    
15934                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15935    
15936                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15937    
15938                            boolean bindDisplayDate = false;
15939    
15940                            if (displayDate == null) {
15941                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15942                            }
15943                            else {
15944                                    bindDisplayDate = true;
15945    
15946                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15947                            }
15948    
15949                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15950    
15951                            String sql = query.toString();
15952    
15953                            Session session = null;
15954    
15955                            try {
15956                                    session = openSession();
15957    
15958                                    Query q = session.createQuery(sql);
15959    
15960                                    QueryPos qPos = QueryPos.getInstance(q);
15961    
15962                                    qPos.add(companyId);
15963    
15964                                    if (bindDisplayDate) {
15965                                            qPos.add(new Timestamp(displayDate.getTime()));
15966                                    }
15967    
15968                                    qPos.add(status);
15969    
15970                                    count = (Long)q.uniqueResult();
15971    
15972                                    finderCache.putResult(finderPath, finderArgs, count);
15973                            }
15974                            catch (Exception e) {
15975                                    finderCache.removeResult(finderPath, finderArgs);
15976    
15977                                    throw processException(e);
15978                            }
15979                            finally {
15980                                    closeSession(session);
15981                            }
15982                    }
15983    
15984                    return count.intValue();
15985            }
15986    
15987            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15988            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15989            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15990            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
15991            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
15992                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15993                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15994                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
15995                            new String[] {
15996                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15997                                    Integer.class.getName(),
15998                                    
15999                            Integer.class.getName(), Integer.class.getName(),
16000                                    OrderByComparator.class.getName()
16001                            });
16002            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16003                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16004                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16005                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16006                            new String[] {
16007                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16008                                    Integer.class.getName()
16009                            });
16010    
16011            /**
16012             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16013             *
16014             * @param groupId the group ID
16015             * @param userId the user ID
16016             * @param displayDate the display date
16017             * @param status the status
16018             * @return the matching blogs entries
16019             */
16020            @Override
16021            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16022                    Date displayDate, int status) {
16023                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16024                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16025            }
16026    
16027            /**
16028             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16029             *
16030             * <p>
16031             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16032             * </p>
16033             *
16034             * @param groupId the group ID
16035             * @param userId the user ID
16036             * @param displayDate the display date
16037             * @param status the status
16038             * @param start the lower bound of the range of blogs entries
16039             * @param end the upper bound of the range of blogs entries (not inclusive)
16040             * @return the range of matching blogs entries
16041             */
16042            @Override
16043            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16044                    Date displayDate, int status, int start, int end) {
16045                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16046                            end, null);
16047            }
16048    
16049            /**
16050             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16051             *
16052             * <p>
16053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16054             * </p>
16055             *
16056             * @param groupId the group ID
16057             * @param userId the user ID
16058             * @param displayDate the display date
16059             * @param status the status
16060             * @param start the lower bound of the range of blogs entries
16061             * @param end the upper bound of the range of blogs entries (not inclusive)
16062             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16063             * @return the ordered range of matching blogs entries
16064             */
16065            @Override
16066            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16067                    Date displayDate, int status, int start, int end,
16068                    OrderByComparator<BlogsEntry> orderByComparator) {
16069                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16070                            end, orderByComparator, true);
16071            }
16072    
16073            /**
16074             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16075             *
16076             * <p>
16077             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16078             * </p>
16079             *
16080             * @param groupId the group ID
16081             * @param userId the user ID
16082             * @param displayDate the display date
16083             * @param status the status
16084             * @param start the lower bound of the range of blogs entries
16085             * @param end the upper bound of the range of blogs entries (not inclusive)
16086             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16087             * @param retrieveFromCache whether to retrieve from the finder cache
16088             * @return the ordered range of matching blogs entries
16089             */
16090            @Override
16091            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16092                    Date displayDate, int status, int start, int end,
16093                    OrderByComparator<BlogsEntry> orderByComparator,
16094                    boolean retrieveFromCache) {
16095                    boolean pagination = true;
16096                    FinderPath finderPath = null;
16097                    Object[] finderArgs = null;
16098    
16099                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16100                    finderArgs = new Object[] {
16101                                    groupId, userId, displayDate, status,
16102                                    
16103                                    start, end, orderByComparator
16104                            };
16105    
16106                    List<BlogsEntry> list = null;
16107    
16108                    if (retrieveFromCache) {
16109                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16110                                            finderArgs, this);
16111    
16112                            if ((list != null) && !list.isEmpty()) {
16113                                    for (BlogsEntry blogsEntry : list) {
16114                                            if ((groupId != blogsEntry.getGroupId()) ||
16115                                                            (userId != blogsEntry.getUserId()) ||
16116                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16117                                                                                                                                            .getTime()) ||
16118                                                            (status != blogsEntry.getStatus())) {
16119                                                    list = null;
16120    
16121                                                    break;
16122                                            }
16123                                    }
16124                            }
16125                    }
16126    
16127                    if (list == null) {
16128                            StringBundler query = null;
16129    
16130                            if (orderByComparator != null) {
16131                                    query = new StringBundler(6 +
16132                                                    (orderByComparator.getOrderByFields().length * 3));
16133                            }
16134                            else {
16135                                    query = new StringBundler(6);
16136                            }
16137    
16138                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16139    
16140                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16141    
16142                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16143    
16144                            boolean bindDisplayDate = false;
16145    
16146                            if (displayDate == null) {
16147                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16148                            }
16149                            else {
16150                                    bindDisplayDate = true;
16151    
16152                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16153                            }
16154    
16155                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16156    
16157                            if (orderByComparator != null) {
16158                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16159                                            orderByComparator);
16160                            }
16161                            else
16162                             if (pagination) {
16163                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16164                            }
16165    
16166                            String sql = query.toString();
16167    
16168                            Session session = null;
16169    
16170                            try {
16171                                    session = openSession();
16172    
16173                                    Query q = session.createQuery(sql);
16174    
16175                                    QueryPos qPos = QueryPos.getInstance(q);
16176    
16177                                    qPos.add(groupId);
16178    
16179                                    qPos.add(userId);
16180    
16181                                    if (bindDisplayDate) {
16182                                            qPos.add(new Timestamp(displayDate.getTime()));
16183                                    }
16184    
16185                                    qPos.add(status);
16186    
16187                                    if (!pagination) {
16188                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16189                                                            start, end, false);
16190    
16191                                            Collections.sort(list);
16192    
16193                                            list = Collections.unmodifiableList(list);
16194                                    }
16195                                    else {
16196                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16197                                                            start, end);
16198                                    }
16199    
16200                                    cacheResult(list);
16201    
16202                                    finderCache.putResult(finderPath, finderArgs, list);
16203                            }
16204                            catch (Exception e) {
16205                                    finderCache.removeResult(finderPath, finderArgs);
16206    
16207                                    throw processException(e);
16208                            }
16209                            finally {
16210                                    closeSession(session);
16211                            }
16212                    }
16213    
16214                    return list;
16215            }
16216    
16217            /**
16218             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16219             *
16220             * @param groupId the group ID
16221             * @param userId the user ID
16222             * @param displayDate the display date
16223             * @param status the status
16224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16225             * @return the first matching blogs entry
16226             * @throws NoSuchEntryException if a matching blogs entry could not be found
16227             */
16228            @Override
16229            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16230                    Date displayDate, int status,
16231                    OrderByComparator<BlogsEntry> orderByComparator)
16232                    throws NoSuchEntryException {
16233                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16234                                    displayDate, status, orderByComparator);
16235    
16236                    if (blogsEntry != null) {
16237                            return blogsEntry;
16238                    }
16239    
16240                    StringBundler msg = new StringBundler(10);
16241    
16242                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16243    
16244                    msg.append("groupId=");
16245                    msg.append(groupId);
16246    
16247                    msg.append(", userId=");
16248                    msg.append(userId);
16249    
16250                    msg.append(", displayDate=");
16251                    msg.append(displayDate);
16252    
16253                    msg.append(", status=");
16254                    msg.append(status);
16255    
16256                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16257    
16258                    throw new NoSuchEntryException(msg.toString());
16259            }
16260    
16261            /**
16262             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16263             *
16264             * @param groupId the group ID
16265             * @param userId the user ID
16266             * @param displayDate the display date
16267             * @param status the status
16268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16269             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16270             */
16271            @Override
16272            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16273                    Date displayDate, int status,
16274                    OrderByComparator<BlogsEntry> orderByComparator) {
16275                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16276                                    status, 0, 1, orderByComparator);
16277    
16278                    if (!list.isEmpty()) {
16279                            return list.get(0);
16280                    }
16281    
16282                    return null;
16283            }
16284    
16285            /**
16286             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16287             *
16288             * @param groupId the group ID
16289             * @param userId the user ID
16290             * @param displayDate the display date
16291             * @param status the status
16292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16293             * @return the last matching blogs entry
16294             * @throws NoSuchEntryException if a matching blogs entry could not be found
16295             */
16296            @Override
16297            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16298                    Date displayDate, int status,
16299                    OrderByComparator<BlogsEntry> orderByComparator)
16300                    throws NoSuchEntryException {
16301                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16302                                    displayDate, status, orderByComparator);
16303    
16304                    if (blogsEntry != null) {
16305                            return blogsEntry;
16306                    }
16307    
16308                    StringBundler msg = new StringBundler(10);
16309    
16310                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16311    
16312                    msg.append("groupId=");
16313                    msg.append(groupId);
16314    
16315                    msg.append(", userId=");
16316                    msg.append(userId);
16317    
16318                    msg.append(", displayDate=");
16319                    msg.append(displayDate);
16320    
16321                    msg.append(", status=");
16322                    msg.append(status);
16323    
16324                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16325    
16326                    throw new NoSuchEntryException(msg.toString());
16327            }
16328    
16329            /**
16330             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16331             *
16332             * @param groupId the group ID
16333             * @param userId the user ID
16334             * @param displayDate the display date
16335             * @param status the status
16336             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16337             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16338             */
16339            @Override
16340            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16341                    Date displayDate, int status,
16342                    OrderByComparator<BlogsEntry> orderByComparator) {
16343                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16344    
16345                    if (count == 0) {
16346                            return null;
16347                    }
16348    
16349                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16350                                    status, count - 1, count, orderByComparator);
16351    
16352                    if (!list.isEmpty()) {
16353                            return list.get(0);
16354                    }
16355    
16356                    return null;
16357            }
16358    
16359            /**
16360             * 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;.
16361             *
16362             * @param entryId the primary key of the current blogs entry
16363             * @param groupId the group ID
16364             * @param userId the user ID
16365             * @param displayDate the display date
16366             * @param status the status
16367             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16368             * @return the previous, current, and next blogs entry
16369             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16370             */
16371            @Override
16372            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16373                    long userId, Date displayDate, int status,
16374                    OrderByComparator<BlogsEntry> orderByComparator)
16375                    throws NoSuchEntryException {
16376                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16377    
16378                    Session session = null;
16379    
16380                    try {
16381                            session = openSession();
16382    
16383                            BlogsEntry[] array = new BlogsEntryImpl[3];
16384    
16385                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16386                                            userId, displayDate, status, orderByComparator, true);
16387    
16388                            array[1] = blogsEntry;
16389    
16390                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16391                                            userId, displayDate, status, orderByComparator, false);
16392    
16393                            return array;
16394                    }
16395                    catch (Exception e) {
16396                            throw processException(e);
16397                    }
16398                    finally {
16399                            closeSession(session);
16400                    }
16401            }
16402    
16403            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16404                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16405                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16406                    boolean previous) {
16407                    StringBundler query = null;
16408    
16409                    if (orderByComparator != null) {
16410                            query = new StringBundler(6 +
16411                                            (orderByComparator.getOrderByFields().length * 6));
16412                    }
16413                    else {
16414                            query = new StringBundler(3);
16415                    }
16416    
16417                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16418    
16419                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16420    
16421                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16422    
16423                    boolean bindDisplayDate = false;
16424    
16425                    if (displayDate == null) {
16426                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16427                    }
16428                    else {
16429                            bindDisplayDate = true;
16430    
16431                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16432                    }
16433    
16434                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16435    
16436                    if (orderByComparator != null) {
16437                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16438    
16439                            if (orderByConditionFields.length > 0) {
16440                                    query.append(WHERE_AND);
16441                            }
16442    
16443                            for (int i = 0; i < orderByConditionFields.length; i++) {
16444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16445                                    query.append(orderByConditionFields[i]);
16446    
16447                                    if ((i + 1) < orderByConditionFields.length) {
16448                                            if (orderByComparator.isAscending() ^ previous) {
16449                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16450                                            }
16451                                            else {
16452                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16453                                            }
16454                                    }
16455                                    else {
16456                                            if (orderByComparator.isAscending() ^ previous) {
16457                                                    query.append(WHERE_GREATER_THAN);
16458                                            }
16459                                            else {
16460                                                    query.append(WHERE_LESSER_THAN);
16461                                            }
16462                                    }
16463                            }
16464    
16465                            query.append(ORDER_BY_CLAUSE);
16466    
16467                            String[] orderByFields = orderByComparator.getOrderByFields();
16468    
16469                            for (int i = 0; i < orderByFields.length; i++) {
16470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16471                                    query.append(orderByFields[i]);
16472    
16473                                    if ((i + 1) < orderByFields.length) {
16474                                            if (orderByComparator.isAscending() ^ previous) {
16475                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16476                                            }
16477                                            else {
16478                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16479                                            }
16480                                    }
16481                                    else {
16482                                            if (orderByComparator.isAscending() ^ previous) {
16483                                                    query.append(ORDER_BY_ASC);
16484                                            }
16485                                            else {
16486                                                    query.append(ORDER_BY_DESC);
16487                                            }
16488                                    }
16489                            }
16490                    }
16491                    else {
16492                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16493                    }
16494    
16495                    String sql = query.toString();
16496    
16497                    Query q = session.createQuery(sql);
16498    
16499                    q.setFirstResult(0);
16500                    q.setMaxResults(2);
16501    
16502                    QueryPos qPos = QueryPos.getInstance(q);
16503    
16504                    qPos.add(groupId);
16505    
16506                    qPos.add(userId);
16507    
16508                    if (bindDisplayDate) {
16509                            qPos.add(new Timestamp(displayDate.getTime()));
16510                    }
16511    
16512                    qPos.add(status);
16513    
16514                    if (orderByComparator != null) {
16515                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16516    
16517                            for (Object value : values) {
16518                                    qPos.add(value);
16519                            }
16520                    }
16521    
16522                    List<BlogsEntry> list = q.list();
16523    
16524                    if (list.size() == 2) {
16525                            return list.get(1);
16526                    }
16527                    else {
16528                            return null;
16529                    }
16530            }
16531    
16532            /**
16533             * 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;.
16534             *
16535             * @param groupId the group ID
16536             * @param userId the user ID
16537             * @param displayDate the display date
16538             * @param status the status
16539             * @return the matching blogs entries that the user has permission to view
16540             */
16541            @Override
16542            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16543                    Date displayDate, int status) {
16544                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16545                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16546            }
16547    
16548            /**
16549             * 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;.
16550             *
16551             * <p>
16552             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16553             * </p>
16554             *
16555             * @param groupId the group ID
16556             * @param userId the user ID
16557             * @param displayDate the display date
16558             * @param status the status
16559             * @param start the lower bound of the range of blogs entries
16560             * @param end the upper bound of the range of blogs entries (not inclusive)
16561             * @return the range of matching blogs entries that the user has permission to view
16562             */
16563            @Override
16564            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16565                    Date displayDate, int status, int start, int end) {
16566                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16567                            start, end, null);
16568            }
16569    
16570            /**
16571             * 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;.
16572             *
16573             * <p>
16574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16575             * </p>
16576             *
16577             * @param groupId the group ID
16578             * @param userId the user ID
16579             * @param displayDate the display date
16580             * @param status the status
16581             * @param start the lower bound of the range of blogs entries
16582             * @param end the upper bound of the range of blogs entries (not inclusive)
16583             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16584             * @return the ordered range of matching blogs entries that the user has permission to view
16585             */
16586            @Override
16587            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16588                    Date displayDate, int status, int start, int end,
16589                    OrderByComparator<BlogsEntry> orderByComparator) {
16590                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16591                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16592                                    end, orderByComparator);
16593                    }
16594    
16595                    StringBundler query = null;
16596    
16597                    if (orderByComparator != null) {
16598                            query = new StringBundler(6 +
16599                                            (orderByComparator.getOrderByFields().length * 3));
16600                    }
16601                    else {
16602                            query = new StringBundler(6);
16603                    }
16604    
16605                    if (getDB().isSupportsInlineDistinct()) {
16606                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16607                    }
16608                    else {
16609                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16610                    }
16611    
16612                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16613    
16614                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16615    
16616                    boolean bindDisplayDate = false;
16617    
16618                    if (displayDate == null) {
16619                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16620                    }
16621                    else {
16622                            bindDisplayDate = true;
16623    
16624                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16625                    }
16626    
16627                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16628    
16629                    if (!getDB().isSupportsInlineDistinct()) {
16630                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16631                    }
16632    
16633                    if (orderByComparator != null) {
16634                            if (getDB().isSupportsInlineDistinct()) {
16635                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16636                                            orderByComparator, true);
16637                            }
16638                            else {
16639                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16640                                            orderByComparator, true);
16641                            }
16642                    }
16643                    else {
16644                            if (getDB().isSupportsInlineDistinct()) {
16645                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16646                            }
16647                            else {
16648                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16649                            }
16650                    }
16651    
16652                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16653                                    BlogsEntry.class.getName(),
16654                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16655    
16656                    Session session = null;
16657    
16658                    try {
16659                            session = openSession();
16660    
16661                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16662    
16663                            if (getDB().isSupportsInlineDistinct()) {
16664                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16665                            }
16666                            else {
16667                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16668                            }
16669    
16670                            QueryPos qPos = QueryPos.getInstance(q);
16671    
16672                            qPos.add(groupId);
16673    
16674                            qPos.add(userId);
16675    
16676                            if (bindDisplayDate) {
16677                                    qPos.add(new Timestamp(displayDate.getTime()));
16678                            }
16679    
16680                            qPos.add(status);
16681    
16682                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16683                    }
16684                    catch (Exception e) {
16685                            throw processException(e);
16686                    }
16687                    finally {
16688                            closeSession(session);
16689                    }
16690            }
16691    
16692            /**
16693             * 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;.
16694             *
16695             * @param entryId the primary key of the current blogs entry
16696             * @param groupId the group ID
16697             * @param userId the user ID
16698             * @param displayDate the display date
16699             * @param status the status
16700             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16701             * @return the previous, current, and next blogs entry
16702             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16703             */
16704            @Override
16705            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
16706                    long groupId, long userId, Date displayDate, int status,
16707                    OrderByComparator<BlogsEntry> orderByComparator)
16708                    throws NoSuchEntryException {
16709                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16710                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
16711                                    displayDate, status, orderByComparator);
16712                    }
16713    
16714                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16715    
16716                    Session session = null;
16717    
16718                    try {
16719                            session = openSession();
16720    
16721                            BlogsEntry[] array = new BlogsEntryImpl[3];
16722    
16723                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16724                                            groupId, userId, displayDate, status, orderByComparator,
16725                                            true);
16726    
16727                            array[1] = blogsEntry;
16728    
16729                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16730                                            groupId, userId, displayDate, status, orderByComparator,
16731                                            false);
16732    
16733                            return array;
16734                    }
16735                    catch (Exception e) {
16736                            throw processException(e);
16737                    }
16738                    finally {
16739                            closeSession(session);
16740                    }
16741            }
16742    
16743            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
16744                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16745                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16746                    boolean previous) {
16747                    StringBundler query = null;
16748    
16749                    if (orderByComparator != null) {
16750                            query = new StringBundler(6 +
16751                                            (orderByComparator.getOrderByFields().length * 6));
16752                    }
16753                    else {
16754                            query = new StringBundler(3);
16755                    }
16756    
16757                    if (getDB().isSupportsInlineDistinct()) {
16758                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16759                    }
16760                    else {
16761                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16762                    }
16763    
16764                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16765    
16766                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16767    
16768                    boolean bindDisplayDate = false;
16769    
16770                    if (displayDate == null) {
16771                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16772                    }
16773                    else {
16774                            bindDisplayDate = true;
16775    
16776                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16777                    }
16778    
16779                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16780    
16781                    if (!getDB().isSupportsInlineDistinct()) {
16782                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16783                    }
16784    
16785                    if (orderByComparator != null) {
16786                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16787    
16788                            if (orderByConditionFields.length > 0) {
16789                                    query.append(WHERE_AND);
16790                            }
16791    
16792                            for (int i = 0; i < orderByConditionFields.length; i++) {
16793                                    if (getDB().isSupportsInlineDistinct()) {
16794                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16795                                    }
16796                                    else {
16797                                            query.append(_ORDER_BY_ENTITY_TABLE);
16798                                    }
16799    
16800                                    query.append(orderByConditionFields[i]);
16801    
16802                                    if ((i + 1) < orderByConditionFields.length) {
16803                                            if (orderByComparator.isAscending() ^ previous) {
16804                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16805                                            }
16806                                            else {
16807                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16808                                            }
16809                                    }
16810                                    else {
16811                                            if (orderByComparator.isAscending() ^ previous) {
16812                                                    query.append(WHERE_GREATER_THAN);
16813                                            }
16814                                            else {
16815                                                    query.append(WHERE_LESSER_THAN);
16816                                            }
16817                                    }
16818                            }
16819    
16820                            query.append(ORDER_BY_CLAUSE);
16821    
16822                            String[] orderByFields = orderByComparator.getOrderByFields();
16823    
16824                            for (int i = 0; i < orderByFields.length; i++) {
16825                                    if (getDB().isSupportsInlineDistinct()) {
16826                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16827                                    }
16828                                    else {
16829                                            query.append(_ORDER_BY_ENTITY_TABLE);
16830                                    }
16831    
16832                                    query.append(orderByFields[i]);
16833    
16834                                    if ((i + 1) < orderByFields.length) {
16835                                            if (orderByComparator.isAscending() ^ previous) {
16836                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16837                                            }
16838                                            else {
16839                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16840                                            }
16841                                    }
16842                                    else {
16843                                            if (orderByComparator.isAscending() ^ previous) {
16844                                                    query.append(ORDER_BY_ASC);
16845                                            }
16846                                            else {
16847                                                    query.append(ORDER_BY_DESC);
16848                                            }
16849                                    }
16850                            }
16851                    }
16852                    else {
16853                            if (getDB().isSupportsInlineDistinct()) {
16854                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16855                            }
16856                            else {
16857                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16858                            }
16859                    }
16860    
16861                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16862                                    BlogsEntry.class.getName(),
16863                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16864    
16865                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
16866    
16867                    q.setFirstResult(0);
16868                    q.setMaxResults(2);
16869    
16870                    if (getDB().isSupportsInlineDistinct()) {
16871                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16872                    }
16873                    else {
16874                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16875                    }
16876    
16877                    QueryPos qPos = QueryPos.getInstance(q);
16878    
16879                    qPos.add(groupId);
16880    
16881                    qPos.add(userId);
16882    
16883                    if (bindDisplayDate) {
16884                            qPos.add(new Timestamp(displayDate.getTime()));
16885                    }
16886    
16887                    qPos.add(status);
16888    
16889                    if (orderByComparator != null) {
16890                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16891    
16892                            for (Object value : values) {
16893                                    qPos.add(value);
16894                            }
16895                    }
16896    
16897                    List<BlogsEntry> list = q.list();
16898    
16899                    if (list.size() == 2) {
16900                            return list.get(1);
16901                    }
16902                    else {
16903                            return null;
16904                    }
16905            }
16906    
16907            /**
16908             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
16909             *
16910             * @param groupId the group ID
16911             * @param userId the user ID
16912             * @param displayDate the display date
16913             * @param status the status
16914             */
16915            @Override
16916            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
16917                    int status) {
16918                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
16919                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16920                            remove(blogsEntry);
16921                    }
16922            }
16923    
16924            /**
16925             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16926             *
16927             * @param groupId the group ID
16928             * @param userId the user ID
16929             * @param displayDate the display date
16930             * @param status the status
16931             * @return the number of matching blogs entries
16932             */
16933            @Override
16934            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
16935                    int status) {
16936                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
16937    
16938                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16939    
16940                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
16941    
16942                    if (count == null) {
16943                            StringBundler query = new StringBundler(5);
16944    
16945                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16946    
16947                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16948    
16949                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16950    
16951                            boolean bindDisplayDate = false;
16952    
16953                            if (displayDate == null) {
16954                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16955                            }
16956                            else {
16957                                    bindDisplayDate = true;
16958    
16959                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16960                            }
16961    
16962                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16963    
16964                            String sql = query.toString();
16965    
16966                            Session session = null;
16967    
16968                            try {
16969                                    session = openSession();
16970    
16971                                    Query q = session.createQuery(sql);
16972    
16973                                    QueryPos qPos = QueryPos.getInstance(q);
16974    
16975                                    qPos.add(groupId);
16976    
16977                                    qPos.add(userId);
16978    
16979                                    if (bindDisplayDate) {
16980                                            qPos.add(new Timestamp(displayDate.getTime()));
16981                                    }
16982    
16983                                    qPos.add(status);
16984    
16985                                    count = (Long)q.uniqueResult();
16986    
16987                                    finderCache.putResult(finderPath, finderArgs, count);
16988                            }
16989                            catch (Exception e) {
16990                                    finderCache.removeResult(finderPath, finderArgs);
16991    
16992                                    throw processException(e);
16993                            }
16994                            finally {
16995                                    closeSession(session);
16996                            }
16997                    }
16998    
16999                    return count.intValue();
17000            }
17001    
17002            /**
17003             * 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;.
17004             *
17005             * @param groupId the group ID
17006             * @param userId the user ID
17007             * @param displayDate the display date
17008             * @param status the status
17009             * @return the number of matching blogs entries that the user has permission to view
17010             */
17011            @Override
17012            public int filterCountByG_U_LtD_S(long groupId, long userId,
17013                    Date displayDate, int status) {
17014                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17015                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17016                    }
17017    
17018                    StringBundler query = new StringBundler(5);
17019    
17020                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17021    
17022                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17023    
17024                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17025    
17026                    boolean bindDisplayDate = false;
17027    
17028                    if (displayDate == null) {
17029                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17030                    }
17031                    else {
17032                            bindDisplayDate = true;
17033    
17034                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17035                    }
17036    
17037                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17038    
17039                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17040                                    BlogsEntry.class.getName(),
17041                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17042    
17043                    Session session = null;
17044    
17045                    try {
17046                            session = openSession();
17047    
17048                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17049    
17050                            q.addScalar(COUNT_COLUMN_NAME,
17051                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17052    
17053                            QueryPos qPos = QueryPos.getInstance(q);
17054    
17055                            qPos.add(groupId);
17056    
17057                            qPos.add(userId);
17058    
17059                            if (bindDisplayDate) {
17060                                    qPos.add(new Timestamp(displayDate.getTime()));
17061                            }
17062    
17063                            qPos.add(status);
17064    
17065                            Long count = (Long)q.uniqueResult();
17066    
17067                            return count.intValue();
17068                    }
17069                    catch (Exception e) {
17070                            throw processException(e);
17071                    }
17072                    finally {
17073                            closeSession(session);
17074                    }
17075            }
17076    
17077            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17078            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17079            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
17080            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17081            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17082            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
17083                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17084                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
17085                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
17086                            new String[] {
17087                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17088                                    Integer.class.getName(),
17089                                    
17090                            Integer.class.getName(), Integer.class.getName(),
17091                                    OrderByComparator.class.getName()
17092                            });
17093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
17094                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17095                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
17096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
17097                            new String[] {
17098                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17099                                    Integer.class.getName()
17100                            });
17101    
17102            /**
17103             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17104             *
17105             * @param groupId the group ID
17106             * @param userId the user ID
17107             * @param displayDate the display date
17108             * @param status the status
17109             * @return the matching blogs entries
17110             */
17111            @Override
17112            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17113                    Date displayDate, int status) {
17114                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17115                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17116            }
17117    
17118            /**
17119             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17120             *
17121             * <p>
17122             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17123             * </p>
17124             *
17125             * @param groupId the group ID
17126             * @param userId the user ID
17127             * @param displayDate the display date
17128             * @param status the status
17129             * @param start the lower bound of the range of blogs entries
17130             * @param end the upper bound of the range of blogs entries (not inclusive)
17131             * @return the range of matching blogs entries
17132             */
17133            @Override
17134            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17135                    Date displayDate, int status, int start, int end) {
17136                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17137                            end, null);
17138            }
17139    
17140            /**
17141             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17142             *
17143             * <p>
17144             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17145             * </p>
17146             *
17147             * @param groupId the group ID
17148             * @param userId the user ID
17149             * @param displayDate the display date
17150             * @param status the status
17151             * @param start the lower bound of the range of blogs entries
17152             * @param end the upper bound of the range of blogs entries (not inclusive)
17153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17154             * @return the ordered range of matching blogs entries
17155             */
17156            @Override
17157            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17158                    Date displayDate, int status, int start, int end,
17159                    OrderByComparator<BlogsEntry> orderByComparator) {
17160                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17161                            end, orderByComparator, true);
17162            }
17163    
17164            /**
17165             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17166             *
17167             * <p>
17168             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17169             * </p>
17170             *
17171             * @param groupId the group ID
17172             * @param userId the user ID
17173             * @param displayDate the display date
17174             * @param status the status
17175             * @param start the lower bound of the range of blogs entries
17176             * @param end the upper bound of the range of blogs entries (not inclusive)
17177             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17178             * @param retrieveFromCache whether to retrieve from the finder cache
17179             * @return the ordered range of matching blogs entries
17180             */
17181            @Override
17182            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17183                    Date displayDate, int status, int start, int end,
17184                    OrderByComparator<BlogsEntry> orderByComparator,
17185                    boolean retrieveFromCache) {
17186                    boolean pagination = true;
17187                    FinderPath finderPath = null;
17188                    Object[] finderArgs = null;
17189    
17190                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
17191                    finderArgs = new Object[] {
17192                                    groupId, userId, displayDate, status,
17193                                    
17194                                    start, end, orderByComparator
17195                            };
17196    
17197                    List<BlogsEntry> list = null;
17198    
17199                    if (retrieveFromCache) {
17200                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
17201                                            finderArgs, this);
17202    
17203                            if ((list != null) && !list.isEmpty()) {
17204                                    for (BlogsEntry blogsEntry : list) {
17205                                            if ((groupId != blogsEntry.getGroupId()) ||
17206                                                            (userId != blogsEntry.getUserId()) ||
17207                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
17208                                                                                                                                            .getTime()) ||
17209                                                            (status == blogsEntry.getStatus())) {
17210                                                    list = null;
17211    
17212                                                    break;
17213                                            }
17214                                    }
17215                            }
17216                    }
17217    
17218                    if (list == null) {
17219                            StringBundler query = null;
17220    
17221                            if (orderByComparator != null) {
17222                                    query = new StringBundler(6 +
17223                                                    (orderByComparator.getOrderByFields().length * 3));
17224                            }
17225                            else {
17226                                    query = new StringBundler(6);
17227                            }
17228    
17229                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17230    
17231                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17232    
17233                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17234    
17235                            boolean bindDisplayDate = false;
17236    
17237                            if (displayDate == null) {
17238                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17239                            }
17240                            else {
17241                                    bindDisplayDate = true;
17242    
17243                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17244                            }
17245    
17246                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17247    
17248                            if (orderByComparator != null) {
17249                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17250                                            orderByComparator);
17251                            }
17252                            else
17253                             if (pagination) {
17254                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17255                            }
17256    
17257                            String sql = query.toString();
17258    
17259                            Session session = null;
17260    
17261                            try {
17262                                    session = openSession();
17263    
17264                                    Query q = session.createQuery(sql);
17265    
17266                                    QueryPos qPos = QueryPos.getInstance(q);
17267    
17268                                    qPos.add(groupId);
17269    
17270                                    qPos.add(userId);
17271    
17272                                    if (bindDisplayDate) {
17273                                            qPos.add(new Timestamp(displayDate.getTime()));
17274                                    }
17275    
17276                                    qPos.add(status);
17277    
17278                                    if (!pagination) {
17279                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17280                                                            start, end, false);
17281    
17282                                            Collections.sort(list);
17283    
17284                                            list = Collections.unmodifiableList(list);
17285                                    }
17286                                    else {
17287                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17288                                                            start, end);
17289                                    }
17290    
17291                                    cacheResult(list);
17292    
17293                                    finderCache.putResult(finderPath, finderArgs, list);
17294                            }
17295                            catch (Exception e) {
17296                                    finderCache.removeResult(finderPath, finderArgs);
17297    
17298                                    throw processException(e);
17299                            }
17300                            finally {
17301                                    closeSession(session);
17302                            }
17303                    }
17304    
17305                    return list;
17306            }
17307    
17308            /**
17309             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17310             *
17311             * @param groupId the group ID
17312             * @param userId the user ID
17313             * @param displayDate the display date
17314             * @param status the status
17315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17316             * @return the first matching blogs entry
17317             * @throws NoSuchEntryException if a matching blogs entry could not be found
17318             */
17319            @Override
17320            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
17321                    Date displayDate, int status,
17322                    OrderByComparator<BlogsEntry> orderByComparator)
17323                    throws NoSuchEntryException {
17324                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
17325                                    displayDate, status, orderByComparator);
17326    
17327                    if (blogsEntry != null) {
17328                            return blogsEntry;
17329                    }
17330    
17331                    StringBundler msg = new StringBundler(10);
17332    
17333                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17334    
17335                    msg.append("groupId=");
17336                    msg.append(groupId);
17337    
17338                    msg.append(", userId=");
17339                    msg.append(userId);
17340    
17341                    msg.append(", displayDate=");
17342                    msg.append(displayDate);
17343    
17344                    msg.append(", status=");
17345                    msg.append(status);
17346    
17347                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17348    
17349                    throw new NoSuchEntryException(msg.toString());
17350            }
17351    
17352            /**
17353             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17354             *
17355             * @param groupId the group ID
17356             * @param userId the user ID
17357             * @param displayDate the display date
17358             * @param status the status
17359             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17360             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17361             */
17362            @Override
17363            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
17364                    Date displayDate, int status,
17365                    OrderByComparator<BlogsEntry> orderByComparator) {
17366                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17367                                    displayDate, status, 0, 1, orderByComparator);
17368    
17369                    if (!list.isEmpty()) {
17370                            return list.get(0);
17371                    }
17372    
17373                    return null;
17374            }
17375    
17376            /**
17377             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17378             *
17379             * @param groupId the group ID
17380             * @param userId the user ID
17381             * @param displayDate the display date
17382             * @param status the status
17383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17384             * @return the last matching blogs entry
17385             * @throws NoSuchEntryException if a matching blogs entry could not be found
17386             */
17387            @Override
17388            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
17389                    Date displayDate, int status,
17390                    OrderByComparator<BlogsEntry> orderByComparator)
17391                    throws NoSuchEntryException {
17392                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
17393                                    displayDate, status, orderByComparator);
17394    
17395                    if (blogsEntry != null) {
17396                            return blogsEntry;
17397                    }
17398    
17399                    StringBundler msg = new StringBundler(10);
17400    
17401                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17402    
17403                    msg.append("groupId=");
17404                    msg.append(groupId);
17405    
17406                    msg.append(", userId=");
17407                    msg.append(userId);
17408    
17409                    msg.append(", displayDate=");
17410                    msg.append(displayDate);
17411    
17412                    msg.append(", status=");
17413                    msg.append(status);
17414    
17415                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17416    
17417                    throw new NoSuchEntryException(msg.toString());
17418            }
17419    
17420            /**
17421             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17422             *
17423             * @param groupId the group ID
17424             * @param userId the user ID
17425             * @param displayDate the display date
17426             * @param status the status
17427             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17428             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17429             */
17430            @Override
17431            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
17432                    Date displayDate, int status,
17433                    OrderByComparator<BlogsEntry> orderByComparator) {
17434                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
17435    
17436                    if (count == 0) {
17437                            return null;
17438                    }
17439    
17440                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17441                                    displayDate, status, count - 1, count, orderByComparator);
17442    
17443                    if (!list.isEmpty()) {
17444                            return list.get(0);
17445                    }
17446    
17447                    return null;
17448            }
17449    
17450            /**
17451             * 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;.
17452             *
17453             * @param entryId the primary key of the current blogs entry
17454             * @param groupId the group ID
17455             * @param userId the user ID
17456             * @param displayDate the display date
17457             * @param status the status
17458             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17459             * @return the previous, current, and next blogs entry
17460             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17461             */
17462            @Override
17463            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
17464                    long groupId, long userId, Date displayDate, int status,
17465                    OrderByComparator<BlogsEntry> orderByComparator)
17466                    throws NoSuchEntryException {
17467                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17468    
17469                    Session session = null;
17470    
17471                    try {
17472                            session = openSession();
17473    
17474                            BlogsEntry[] array = new BlogsEntryImpl[3];
17475    
17476                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17477                                            groupId, userId, displayDate, status, orderByComparator,
17478                                            true);
17479    
17480                            array[1] = blogsEntry;
17481    
17482                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17483                                            groupId, userId, displayDate, status, orderByComparator,
17484                                            false);
17485    
17486                            return array;
17487                    }
17488                    catch (Exception e) {
17489                            throw processException(e);
17490                    }
17491                    finally {
17492                            closeSession(session);
17493                    }
17494            }
17495    
17496            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
17497                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17498                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17499                    boolean previous) {
17500                    StringBundler query = null;
17501    
17502                    if (orderByComparator != null) {
17503                            query = new StringBundler(6 +
17504                                            (orderByComparator.getOrderByFields().length * 6));
17505                    }
17506                    else {
17507                            query = new StringBundler(3);
17508                    }
17509    
17510                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17511    
17512                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17513    
17514                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17515    
17516                    boolean bindDisplayDate = false;
17517    
17518                    if (displayDate == null) {
17519                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17520                    }
17521                    else {
17522                            bindDisplayDate = true;
17523    
17524                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17525                    }
17526    
17527                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17528    
17529                    if (orderByComparator != null) {
17530                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17531    
17532                            if (orderByConditionFields.length > 0) {
17533                                    query.append(WHERE_AND);
17534                            }
17535    
17536                            for (int i = 0; i < orderByConditionFields.length; i++) {
17537                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17538                                    query.append(orderByConditionFields[i]);
17539    
17540                                    if ((i + 1) < orderByConditionFields.length) {
17541                                            if (orderByComparator.isAscending() ^ previous) {
17542                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17543                                            }
17544                                            else {
17545                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17546                                            }
17547                                    }
17548                                    else {
17549                                            if (orderByComparator.isAscending() ^ previous) {
17550                                                    query.append(WHERE_GREATER_THAN);
17551                                            }
17552                                            else {
17553                                                    query.append(WHERE_LESSER_THAN);
17554                                            }
17555                                    }
17556                            }
17557    
17558                            query.append(ORDER_BY_CLAUSE);
17559    
17560                            String[] orderByFields = orderByComparator.getOrderByFields();
17561    
17562                            for (int i = 0; i < orderByFields.length; i++) {
17563                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17564                                    query.append(orderByFields[i]);
17565    
17566                                    if ((i + 1) < orderByFields.length) {
17567                                            if (orderByComparator.isAscending() ^ previous) {
17568                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17569                                            }
17570                                            else {
17571                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17572                                            }
17573                                    }
17574                                    else {
17575                                            if (orderByComparator.isAscending() ^ previous) {
17576                                                    query.append(ORDER_BY_ASC);
17577                                            }
17578                                            else {
17579                                                    query.append(ORDER_BY_DESC);
17580                                            }
17581                                    }
17582                            }
17583                    }
17584                    else {
17585                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17586                    }
17587    
17588                    String sql = query.toString();
17589    
17590                    Query q = session.createQuery(sql);
17591    
17592                    q.setFirstResult(0);
17593                    q.setMaxResults(2);
17594    
17595                    QueryPos qPos = QueryPos.getInstance(q);
17596    
17597                    qPos.add(groupId);
17598    
17599                    qPos.add(userId);
17600    
17601                    if (bindDisplayDate) {
17602                            qPos.add(new Timestamp(displayDate.getTime()));
17603                    }
17604    
17605                    qPos.add(status);
17606    
17607                    if (orderByComparator != null) {
17608                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17609    
17610                            for (Object value : values) {
17611                                    qPos.add(value);
17612                            }
17613                    }
17614    
17615                    List<BlogsEntry> list = q.list();
17616    
17617                    if (list.size() == 2) {
17618                            return list.get(1);
17619                    }
17620                    else {
17621                            return null;
17622                    }
17623            }
17624    
17625            /**
17626             * 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;.
17627             *
17628             * @param groupId the group ID
17629             * @param userId the user ID
17630             * @param displayDate the display date
17631             * @param status the status
17632             * @return the matching blogs entries that the user has permission to view
17633             */
17634            @Override
17635            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17636                    Date displayDate, int status) {
17637                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17638                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17639            }
17640    
17641            /**
17642             * 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;.
17643             *
17644             * <p>
17645             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17646             * </p>
17647             *
17648             * @param groupId the group ID
17649             * @param userId the user ID
17650             * @param displayDate the display date
17651             * @param status the status
17652             * @param start the lower bound of the range of blogs entries
17653             * @param end the upper bound of the range of blogs entries (not inclusive)
17654             * @return the range of matching blogs entries that the user has permission to view
17655             */
17656            @Override
17657            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17658                    Date displayDate, int status, int start, int end) {
17659                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17660                            start, end, null);
17661            }
17662    
17663            /**
17664             * 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;.
17665             *
17666             * <p>
17667             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17668             * </p>
17669             *
17670             * @param groupId the group ID
17671             * @param userId the user ID
17672             * @param displayDate the display date
17673             * @param status the status
17674             * @param start the lower bound of the range of blogs entries
17675             * @param end the upper bound of the range of blogs entries (not inclusive)
17676             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17677             * @return the ordered range of matching blogs entries that the user has permission to view
17678             */
17679            @Override
17680            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17681                    Date displayDate, int status, int start, int end,
17682                    OrderByComparator<BlogsEntry> orderByComparator) {
17683                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17684                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17685                                    start, end, orderByComparator);
17686                    }
17687    
17688                    StringBundler query = null;
17689    
17690                    if (orderByComparator != null) {
17691                            query = new StringBundler(6 +
17692                                            (orderByComparator.getOrderByFields().length * 3));
17693                    }
17694                    else {
17695                            query = new StringBundler(6);
17696                    }
17697    
17698                    if (getDB().isSupportsInlineDistinct()) {
17699                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17700                    }
17701                    else {
17702                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17703                    }
17704    
17705                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17706    
17707                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17708    
17709                    boolean bindDisplayDate = false;
17710    
17711                    if (displayDate == null) {
17712                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17713                    }
17714                    else {
17715                            bindDisplayDate = true;
17716    
17717                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17718                    }
17719    
17720                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17721    
17722                    if (!getDB().isSupportsInlineDistinct()) {
17723                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17724                    }
17725    
17726                    if (orderByComparator != null) {
17727                            if (getDB().isSupportsInlineDistinct()) {
17728                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17729                                            orderByComparator, true);
17730                            }
17731                            else {
17732                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17733                                            orderByComparator, true);
17734                            }
17735                    }
17736                    else {
17737                            if (getDB().isSupportsInlineDistinct()) {
17738                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17739                            }
17740                            else {
17741                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17742                            }
17743                    }
17744    
17745                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17746                                    BlogsEntry.class.getName(),
17747                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17748    
17749                    Session session = null;
17750    
17751                    try {
17752                            session = openSession();
17753    
17754                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17755    
17756                            if (getDB().isSupportsInlineDistinct()) {
17757                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17758                            }
17759                            else {
17760                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17761                            }
17762    
17763                            QueryPos qPos = QueryPos.getInstance(q);
17764    
17765                            qPos.add(groupId);
17766    
17767                            qPos.add(userId);
17768    
17769                            if (bindDisplayDate) {
17770                                    qPos.add(new Timestamp(displayDate.getTime()));
17771                            }
17772    
17773                            qPos.add(status);
17774    
17775                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17776                    }
17777                    catch (Exception e) {
17778                            throw processException(e);
17779                    }
17780                    finally {
17781                            closeSession(session);
17782                    }
17783            }
17784    
17785            /**
17786             * 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;.
17787             *
17788             * @param entryId the primary key of the current blogs entry
17789             * @param groupId the group ID
17790             * @param userId the user ID
17791             * @param displayDate the display date
17792             * @param status the status
17793             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17794             * @return the previous, current, and next blogs entry
17795             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17796             */
17797            @Override
17798            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
17799                    long groupId, long userId, Date displayDate, int status,
17800                    OrderByComparator<BlogsEntry> orderByComparator)
17801                    throws NoSuchEntryException {
17802                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17803                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
17804                                    displayDate, status, orderByComparator);
17805                    }
17806    
17807                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17808    
17809                    Session session = null;
17810    
17811                    try {
17812                            session = openSession();
17813    
17814                            BlogsEntry[] array = new BlogsEntryImpl[3];
17815    
17816                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17817                                            groupId, userId, displayDate, status, orderByComparator,
17818                                            true);
17819    
17820                            array[1] = blogsEntry;
17821    
17822                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17823                                            groupId, userId, displayDate, status, orderByComparator,
17824                                            false);
17825    
17826                            return array;
17827                    }
17828                    catch (Exception e) {
17829                            throw processException(e);
17830                    }
17831                    finally {
17832                            closeSession(session);
17833                    }
17834            }
17835    
17836            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
17837                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17838                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17839                    boolean previous) {
17840                    StringBundler query = null;
17841    
17842                    if (orderByComparator != null) {
17843                            query = new StringBundler(6 +
17844                                            (orderByComparator.getOrderByFields().length * 6));
17845                    }
17846                    else {
17847                            query = new StringBundler(3);
17848                    }
17849    
17850                    if (getDB().isSupportsInlineDistinct()) {
17851                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17852                    }
17853                    else {
17854                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17855                    }
17856    
17857                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17858    
17859                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17860    
17861                    boolean bindDisplayDate = false;
17862    
17863                    if (displayDate == null) {
17864                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17865                    }
17866                    else {
17867                            bindDisplayDate = true;
17868    
17869                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17870                    }
17871    
17872                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17873    
17874                    if (!getDB().isSupportsInlineDistinct()) {
17875                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17876                    }
17877    
17878                    if (orderByComparator != null) {
17879                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17880    
17881                            if (orderByConditionFields.length > 0) {
17882                                    query.append(WHERE_AND);
17883                            }
17884    
17885                            for (int i = 0; i < orderByConditionFields.length; i++) {
17886                                    if (getDB().isSupportsInlineDistinct()) {
17887                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17888                                    }
17889                                    else {
17890                                            query.append(_ORDER_BY_ENTITY_TABLE);
17891                                    }
17892    
17893                                    query.append(orderByConditionFields[i]);
17894    
17895                                    if ((i + 1) < orderByConditionFields.length) {
17896                                            if (orderByComparator.isAscending() ^ previous) {
17897                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17898                                            }
17899                                            else {
17900                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17901                                            }
17902                                    }
17903                                    else {
17904                                            if (orderByComparator.isAscending() ^ previous) {
17905                                                    query.append(WHERE_GREATER_THAN);
17906                                            }
17907                                            else {
17908                                                    query.append(WHERE_LESSER_THAN);
17909                                            }
17910                                    }
17911                            }
17912    
17913                            query.append(ORDER_BY_CLAUSE);
17914    
17915                            String[] orderByFields = orderByComparator.getOrderByFields();
17916    
17917                            for (int i = 0; i < orderByFields.length; i++) {
17918                                    if (getDB().isSupportsInlineDistinct()) {
17919                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17920                                    }
17921                                    else {
17922                                            query.append(_ORDER_BY_ENTITY_TABLE);
17923                                    }
17924    
17925                                    query.append(orderByFields[i]);
17926    
17927                                    if ((i + 1) < orderByFields.length) {
17928                                            if (orderByComparator.isAscending() ^ previous) {
17929                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17930                                            }
17931                                            else {
17932                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17933                                            }
17934                                    }
17935                                    else {
17936                                            if (orderByComparator.isAscending() ^ previous) {
17937                                                    query.append(ORDER_BY_ASC);
17938                                            }
17939                                            else {
17940                                                    query.append(ORDER_BY_DESC);
17941                                            }
17942                                    }
17943                            }
17944                    }
17945                    else {
17946                            if (getDB().isSupportsInlineDistinct()) {
17947                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17948                            }
17949                            else {
17950                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17951                            }
17952                    }
17953    
17954                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17955                                    BlogsEntry.class.getName(),
17956                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17957    
17958                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17959    
17960                    q.setFirstResult(0);
17961                    q.setMaxResults(2);
17962    
17963                    if (getDB().isSupportsInlineDistinct()) {
17964                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17965                    }
17966                    else {
17967                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17968                    }
17969    
17970                    QueryPos qPos = QueryPos.getInstance(q);
17971    
17972                    qPos.add(groupId);
17973    
17974                    qPos.add(userId);
17975    
17976                    if (bindDisplayDate) {
17977                            qPos.add(new Timestamp(displayDate.getTime()));
17978                    }
17979    
17980                    qPos.add(status);
17981    
17982                    if (orderByComparator != null) {
17983                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17984    
17985                            for (Object value : values) {
17986                                    qPos.add(value);
17987                            }
17988                    }
17989    
17990                    List<BlogsEntry> list = q.list();
17991    
17992                    if (list.size() == 2) {
17993                            return list.get(1);
17994                    }
17995                    else {
17996                            return null;
17997                    }
17998            }
17999    
18000            /**
18001             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
18002             *
18003             * @param groupId the group ID
18004             * @param userId the user ID
18005             * @param displayDate the display date
18006             * @param status the status
18007             */
18008            @Override
18009            public void removeByG_U_LtD_NotS(long groupId, long userId,
18010                    Date displayDate, int status) {
18011                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
18012                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18013                            remove(blogsEntry);
18014                    }
18015            }
18016    
18017            /**
18018             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
18019             *
18020             * @param groupId the group ID
18021             * @param userId the user ID
18022             * @param displayDate the display date
18023             * @param status the status
18024             * @return the number of matching blogs entries
18025             */
18026            @Override
18027            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
18028                    int status) {
18029                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
18030    
18031                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
18032    
18033                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
18034    
18035                    if (count == null) {
18036                            StringBundler query = new StringBundler(5);
18037    
18038                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
18039    
18040                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18041    
18042                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18043    
18044                            boolean bindDisplayDate = false;
18045    
18046                            if (displayDate == null) {
18047                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18048                            }
18049                            else {
18050                                    bindDisplayDate = true;
18051    
18052                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18053                            }
18054    
18055                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18056    
18057                            String sql = query.toString();
18058    
18059                            Session session = null;
18060    
18061                            try {
18062                                    session = openSession();
18063    
18064                                    Query q = session.createQuery(sql);
18065    
18066                                    QueryPos qPos = QueryPos.getInstance(q);
18067    
18068                                    qPos.add(groupId);
18069    
18070                                    qPos.add(userId);
18071    
18072                                    if (bindDisplayDate) {
18073                                            qPos.add(new Timestamp(displayDate.getTime()));
18074                                    }
18075    
18076                                    qPos.add(status);
18077    
18078                                    count = (Long)q.uniqueResult();
18079    
18080                                    finderCache.putResult(finderPath, finderArgs, count);
18081                            }
18082                            catch (Exception e) {
18083                                    finderCache.removeResult(finderPath, finderArgs);
18084    
18085                                    throw processException(e);
18086                            }
18087                            finally {
18088                                    closeSession(session);
18089                            }
18090                    }
18091    
18092                    return count.intValue();
18093            }
18094    
18095            /**
18096             * 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;.
18097             *
18098             * @param groupId the group ID
18099             * @param userId the user ID
18100             * @param displayDate the display date
18101             * @param status the status
18102             * @return the number of matching blogs entries that the user has permission to view
18103             */
18104            @Override
18105            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
18106                    Date displayDate, int status) {
18107                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18108                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18109                    }
18110    
18111                    StringBundler query = new StringBundler(5);
18112    
18113                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
18114    
18115                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18116    
18117                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18118    
18119                    boolean bindDisplayDate = false;
18120    
18121                    if (displayDate == null) {
18122                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18123                    }
18124                    else {
18125                            bindDisplayDate = true;
18126    
18127                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18128                    }
18129    
18130                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18131    
18132                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18133                                    BlogsEntry.class.getName(),
18134                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18135    
18136                    Session session = null;
18137    
18138                    try {
18139                            session = openSession();
18140    
18141                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18142    
18143                            q.addScalar(COUNT_COLUMN_NAME,
18144                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18145    
18146                            QueryPos qPos = QueryPos.getInstance(q);
18147    
18148                            qPos.add(groupId);
18149    
18150                            qPos.add(userId);
18151    
18152                            if (bindDisplayDate) {
18153                                    qPos.add(new Timestamp(displayDate.getTime()));
18154                            }
18155    
18156                            qPos.add(status);
18157    
18158                            Long count = (Long)q.uniqueResult();
18159    
18160                            return count.intValue();
18161                    }
18162                    catch (Exception e) {
18163                            throw processException(e);
18164                    }
18165                    finally {
18166                            closeSession(session);
18167                    }
18168            }
18169    
18170            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18171            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
18172            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
18173            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18174            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
18175    
18176            public BlogsEntryPersistenceImpl() {
18177                    setModelClass(BlogsEntry.class);
18178            }
18179    
18180            /**
18181             * Caches the blogs entry in the entity cache if it is enabled.
18182             *
18183             * @param blogsEntry the blogs entry
18184             */
18185            @Override
18186            public void cacheResult(BlogsEntry blogsEntry) {
18187                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18188                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18189    
18190                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
18191                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
18192                            blogsEntry);
18193    
18194                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
18195                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
18196                            blogsEntry);
18197    
18198                    blogsEntry.resetOriginalValues();
18199            }
18200    
18201            /**
18202             * Caches the blogs entries in the entity cache if it is enabled.
18203             *
18204             * @param blogsEntries the blogs entries
18205             */
18206            @Override
18207            public void cacheResult(List<BlogsEntry> blogsEntries) {
18208                    for (BlogsEntry blogsEntry : blogsEntries) {
18209                            if (entityCache.getResult(
18210                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18211                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
18212                                    cacheResult(blogsEntry);
18213                            }
18214                            else {
18215                                    blogsEntry.resetOriginalValues();
18216                            }
18217                    }
18218            }
18219    
18220            /**
18221             * Clears the cache for all blogs entries.
18222             *
18223             * <p>
18224             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18225             * </p>
18226             */
18227            @Override
18228            public void clearCache() {
18229                    entityCache.clearCache(BlogsEntryImpl.class);
18230    
18231                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
18232                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18233                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18234            }
18235    
18236            /**
18237             * Clears the cache for the blogs entry.
18238             *
18239             * <p>
18240             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18241             * </p>
18242             */
18243            @Override
18244            public void clearCache(BlogsEntry blogsEntry) {
18245                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18246                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18247    
18248                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18249                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18250    
18251                    clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18252            }
18253    
18254            @Override
18255            public void clearCache(List<BlogsEntry> blogsEntries) {
18256                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18257                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18258    
18259                    for (BlogsEntry blogsEntry : blogsEntries) {
18260                            entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18261                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18262    
18263                            clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18264                    }
18265            }
18266    
18267            protected void cacheUniqueFindersCache(
18268                    BlogsEntryModelImpl blogsEntryModelImpl, boolean isNew) {
18269                    if (isNew) {
18270                            Object[] args = new Object[] {
18271                                            blogsEntryModelImpl.getUuid(),
18272                                            blogsEntryModelImpl.getGroupId()
18273                                    };
18274    
18275                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18276                                    Long.valueOf(1));
18277                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18278                                    blogsEntryModelImpl);
18279    
18280                            args = new Object[] {
18281                                            blogsEntryModelImpl.getGroupId(),
18282                                            blogsEntryModelImpl.getUrlTitle()
18283                                    };
18284    
18285                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18286                                    Long.valueOf(1));
18287                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18288                                    blogsEntryModelImpl);
18289                    }
18290                    else {
18291                            if ((blogsEntryModelImpl.getColumnBitmask() &
18292                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18293                                    Object[] args = new Object[] {
18294                                                    blogsEntryModelImpl.getUuid(),
18295                                                    blogsEntryModelImpl.getGroupId()
18296                                            };
18297    
18298                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18299                                            Long.valueOf(1));
18300                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18301                                            blogsEntryModelImpl);
18302                            }
18303    
18304                            if ((blogsEntryModelImpl.getColumnBitmask() &
18305                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18306                                    Object[] args = new Object[] {
18307                                                    blogsEntryModelImpl.getGroupId(),
18308                                                    blogsEntryModelImpl.getUrlTitle()
18309                                            };
18310    
18311                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18312                                            Long.valueOf(1));
18313                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18314                                            blogsEntryModelImpl);
18315                            }
18316                    }
18317            }
18318    
18319            protected void clearUniqueFindersCache(
18320                    BlogsEntryModelImpl blogsEntryModelImpl) {
18321                    Object[] args = new Object[] {
18322                                    blogsEntryModelImpl.getUuid(), blogsEntryModelImpl.getGroupId()
18323                            };
18324    
18325                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18326                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18327    
18328                    if ((blogsEntryModelImpl.getColumnBitmask() &
18329                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18330                            args = new Object[] {
18331                                            blogsEntryModelImpl.getOriginalUuid(),
18332                                            blogsEntryModelImpl.getOriginalGroupId()
18333                                    };
18334    
18335                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18336                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18337                    }
18338    
18339                    args = new Object[] {
18340                                    blogsEntryModelImpl.getGroupId(),
18341                                    blogsEntryModelImpl.getUrlTitle()
18342                            };
18343    
18344                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18345                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18346    
18347                    if ((blogsEntryModelImpl.getColumnBitmask() &
18348                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18349                            args = new Object[] {
18350                                            blogsEntryModelImpl.getOriginalGroupId(),
18351                                            blogsEntryModelImpl.getOriginalUrlTitle()
18352                                    };
18353    
18354                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18355                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18356                    }
18357            }
18358    
18359            /**
18360             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18361             *
18362             * @param entryId the primary key for the new blogs entry
18363             * @return the new blogs entry
18364             */
18365            @Override
18366            public BlogsEntry create(long entryId) {
18367                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18368    
18369                    blogsEntry.setNew(true);
18370                    blogsEntry.setPrimaryKey(entryId);
18371    
18372                    String uuid = PortalUUIDUtil.generate();
18373    
18374                    blogsEntry.setUuid(uuid);
18375    
18376                    blogsEntry.setCompanyId(companyProvider.getCompanyId());
18377    
18378                    return blogsEntry;
18379            }
18380    
18381            /**
18382             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18383             *
18384             * @param entryId the primary key of the blogs entry
18385             * @return the blogs entry that was removed
18386             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18387             */
18388            @Override
18389            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
18390                    return remove((Serializable)entryId);
18391            }
18392    
18393            /**
18394             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18395             *
18396             * @param primaryKey the primary key of the blogs entry
18397             * @return the blogs entry that was removed
18398             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18399             */
18400            @Override
18401            public BlogsEntry remove(Serializable primaryKey)
18402                    throws NoSuchEntryException {
18403                    Session session = null;
18404    
18405                    try {
18406                            session = openSession();
18407    
18408                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18409                                            primaryKey);
18410    
18411                            if (blogsEntry == null) {
18412                                    if (_log.isWarnEnabled()) {
18413                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18414                                    }
18415    
18416                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18417                                            primaryKey);
18418                            }
18419    
18420                            return remove(blogsEntry);
18421                    }
18422                    catch (NoSuchEntryException nsee) {
18423                            throw nsee;
18424                    }
18425                    catch (Exception e) {
18426                            throw processException(e);
18427                    }
18428                    finally {
18429                            closeSession(session);
18430                    }
18431            }
18432    
18433            @Override
18434            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
18435                    blogsEntry = toUnwrappedModel(blogsEntry);
18436    
18437                    Session session = null;
18438    
18439                    try {
18440                            session = openSession();
18441    
18442                            if (!session.contains(blogsEntry)) {
18443                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18444                                                    blogsEntry.getPrimaryKeyObj());
18445                            }
18446    
18447                            if (blogsEntry != null) {
18448                                    session.delete(blogsEntry);
18449                            }
18450                    }
18451                    catch (Exception e) {
18452                            throw processException(e);
18453                    }
18454                    finally {
18455                            closeSession(session);
18456                    }
18457    
18458                    if (blogsEntry != null) {
18459                            clearCache(blogsEntry);
18460                    }
18461    
18462                    return blogsEntry;
18463            }
18464    
18465            @Override
18466            public BlogsEntry updateImpl(BlogsEntry blogsEntry) {
18467                    blogsEntry = toUnwrappedModel(blogsEntry);
18468    
18469                    boolean isNew = blogsEntry.isNew();
18470    
18471                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18472    
18473                    if (Validator.isNull(blogsEntry.getUuid())) {
18474                            String uuid = PortalUUIDUtil.generate();
18475    
18476                            blogsEntry.setUuid(uuid);
18477                    }
18478    
18479                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
18480    
18481                    Date now = new Date();
18482    
18483                    if (isNew && (blogsEntry.getCreateDate() == null)) {
18484                            if (serviceContext == null) {
18485                                    blogsEntry.setCreateDate(now);
18486                            }
18487                            else {
18488                                    blogsEntry.setCreateDate(serviceContext.getCreateDate(now));
18489                            }
18490                    }
18491    
18492                    if (!blogsEntryModelImpl.hasSetModifiedDate()) {
18493                            if (serviceContext == null) {
18494                                    blogsEntry.setModifiedDate(now);
18495                            }
18496                            else {
18497                                    blogsEntry.setModifiedDate(serviceContext.getModifiedDate(now));
18498                            }
18499                    }
18500    
18501                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
18502    
18503                    if (userId > 0) {
18504                            long companyId = blogsEntry.getCompanyId();
18505    
18506                            long groupId = blogsEntry.getGroupId();
18507    
18508                            long entryId = 0;
18509    
18510                            if (!isNew) {
18511                                    entryId = blogsEntry.getPrimaryKey();
18512                            }
18513    
18514                            try {
18515                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
18516                                                    userId,
18517                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18518                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
18519                                                    blogsEntry.getTitle(), null));
18520    
18521                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
18522                                                    groupId, userId,
18523                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18524                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
18525                                                    blogsEntry.getContent(), null));
18526                            }
18527                            catch (SanitizerException se) {
18528                                    throw new SystemException(se);
18529                            }
18530                    }
18531    
18532                    Session session = null;
18533    
18534                    try {
18535                            session = openSession();
18536    
18537                            if (blogsEntry.isNew()) {
18538                                    session.save(blogsEntry);
18539    
18540                                    blogsEntry.setNew(false);
18541                            }
18542                            else {
18543                                    blogsEntry = (BlogsEntry)session.merge(blogsEntry);
18544                            }
18545                    }
18546                    catch (Exception e) {
18547                            throw processException(e);
18548                    }
18549                    finally {
18550                            closeSession(session);
18551                    }
18552    
18553                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18554    
18555                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
18556                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18557                    }
18558    
18559                    else {
18560                            if ((blogsEntryModelImpl.getColumnBitmask() &
18561                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
18562                                    Object[] args = new Object[] {
18563                                                    blogsEntryModelImpl.getOriginalUuid()
18564                                            };
18565    
18566                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18567                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18568                                            args);
18569    
18570                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
18571    
18572                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18573                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18574                                            args);
18575                            }
18576    
18577                            if ((blogsEntryModelImpl.getColumnBitmask() &
18578                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
18579                                    Object[] args = new Object[] {
18580                                                    blogsEntryModelImpl.getOriginalUuid(),
18581                                                    blogsEntryModelImpl.getOriginalCompanyId()
18582                                            };
18583    
18584                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18585                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18586                                            args);
18587    
18588                                    args = new Object[] {
18589                                                    blogsEntryModelImpl.getUuid(),
18590                                                    blogsEntryModelImpl.getCompanyId()
18591                                            };
18592    
18593                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18594                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18595                                            args);
18596                            }
18597    
18598                            if ((blogsEntryModelImpl.getColumnBitmask() &
18599                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
18600                                    Object[] args = new Object[] {
18601                                                    blogsEntryModelImpl.getOriginalGroupId()
18602                                            };
18603    
18604                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18605                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18606                                            args);
18607    
18608                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
18609    
18610                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18611                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18612                                            args);
18613                            }
18614    
18615                            if ((blogsEntryModelImpl.getColumnBitmask() &
18616                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
18617                                    Object[] args = new Object[] {
18618                                                    blogsEntryModelImpl.getOriginalCompanyId()
18619                                            };
18620    
18621                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
18622                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18623                                            args);
18624    
18625                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
18626    
18627                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
18628                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18629                                            args);
18630                            }
18631    
18632                            if ((blogsEntryModelImpl.getColumnBitmask() &
18633                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18634                                    Object[] args = new Object[] {
18635                                                    blogsEntryModelImpl.getOriginalGroupId(),
18636                                                    blogsEntryModelImpl.getOriginalStatus()
18637                                            };
18638    
18639                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18640                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18641                                            args);
18642    
18643                                    args = new Object[] {
18644                                                    blogsEntryModelImpl.getGroupId(),
18645                                                    blogsEntryModelImpl.getStatus()
18646                                            };
18647    
18648                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18649                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18650                                            args);
18651                            }
18652    
18653                            if ((blogsEntryModelImpl.getColumnBitmask() &
18654                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
18655                                    Object[] args = new Object[] {
18656                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18657                                                    blogsEntryModelImpl.getOriginalUserId()
18658                                            };
18659    
18660                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18661                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18662                                            args);
18663    
18664                                    args = new Object[] {
18665                                                    blogsEntryModelImpl.getCompanyId(),
18666                                                    blogsEntryModelImpl.getUserId()
18667                                            };
18668    
18669                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18670                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18671                                            args);
18672                            }
18673    
18674                            if ((blogsEntryModelImpl.getColumnBitmask() &
18675                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18676                                    Object[] args = new Object[] {
18677                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18678                                                    blogsEntryModelImpl.getOriginalStatus()
18679                                            };
18680    
18681                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18682                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18683                                            args);
18684    
18685                                    args = new Object[] {
18686                                                    blogsEntryModelImpl.getCompanyId(),
18687                                                    blogsEntryModelImpl.getStatus()
18688                                            };
18689    
18690                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18691                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18692                                            args);
18693                            }
18694    
18695                            if ((blogsEntryModelImpl.getColumnBitmask() &
18696                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18697                                    Object[] args = new Object[] {
18698                                                    blogsEntryModelImpl.getOriginalGroupId(),
18699                                                    blogsEntryModelImpl.getOriginalUserId(),
18700                                                    blogsEntryModelImpl.getOriginalStatus()
18701                                            };
18702    
18703                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18704                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18705                                            args);
18706    
18707                                    args = new Object[] {
18708                                                    blogsEntryModelImpl.getGroupId(),
18709                                                    blogsEntryModelImpl.getUserId(),
18710                                                    blogsEntryModelImpl.getStatus()
18711                                            };
18712    
18713                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18714                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18715                                            args);
18716                            }
18717    
18718                            if ((blogsEntryModelImpl.getColumnBitmask() &
18719                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18720                                    Object[] args = new Object[] {
18721                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18722                                                    blogsEntryModelImpl.getOriginalUserId(),
18723                                                    blogsEntryModelImpl.getOriginalStatus()
18724                                            };
18725    
18726                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18727                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18728                                            args);
18729    
18730                                    args = new Object[] {
18731                                                    blogsEntryModelImpl.getCompanyId(),
18732                                                    blogsEntryModelImpl.getUserId(),
18733                                                    blogsEntryModelImpl.getStatus()
18734                                            };
18735    
18736                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18737                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18738                                            args);
18739                            }
18740                    }
18741    
18742                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18743                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry, false);
18744    
18745                    clearUniqueFindersCache(blogsEntryModelImpl);
18746                    cacheUniqueFindersCache(blogsEntryModelImpl, isNew);
18747    
18748                    blogsEntry.resetOriginalValues();
18749    
18750                    return blogsEntry;
18751            }
18752    
18753            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18754                    if (blogsEntry instanceof BlogsEntryImpl) {
18755                            return blogsEntry;
18756                    }
18757    
18758                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18759    
18760                    blogsEntryImpl.setNew(blogsEntry.isNew());
18761                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18762    
18763                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
18764                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18765                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18766                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18767                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
18768                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
18769                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18770                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18771                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
18772                    blogsEntryImpl.setSubtitle(blogsEntry.getSubtitle());
18773                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18774                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
18775                    blogsEntryImpl.setContent(blogsEntry.getContent());
18776                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18777                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18778                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18779                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18780                    blogsEntryImpl.setCoverImageCaption(blogsEntry.getCoverImageCaption());
18781                    blogsEntryImpl.setCoverImageFileEntryId(blogsEntry.getCoverImageFileEntryId());
18782                    blogsEntryImpl.setCoverImageURL(blogsEntry.getCoverImageURL());
18783                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18784                    blogsEntryImpl.setSmallImageFileEntryId(blogsEntry.getSmallImageFileEntryId());
18785                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18786                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18787                    blogsEntryImpl.setLastPublishDate(blogsEntry.getLastPublishDate());
18788                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
18789                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18790                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18791                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18792    
18793                    return blogsEntryImpl;
18794            }
18795    
18796            /**
18797             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.exception.NoSuchModelException} if it could not be found.
18798             *
18799             * @param primaryKey the primary key of the blogs entry
18800             * @return the blogs entry
18801             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18802             */
18803            @Override
18804            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18805                    throws NoSuchEntryException {
18806                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18807    
18808                    if (blogsEntry == null) {
18809                            if (_log.isWarnEnabled()) {
18810                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18811                            }
18812    
18813                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18814                                    primaryKey);
18815                    }
18816    
18817                    return blogsEntry;
18818            }
18819    
18820            /**
18821             * Returns the blogs entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found.
18822             *
18823             * @param entryId the primary key of the blogs entry
18824             * @return the blogs entry
18825             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18826             */
18827            @Override
18828            public BlogsEntry findByPrimaryKey(long entryId)
18829                    throws NoSuchEntryException {
18830                    return findByPrimaryKey((Serializable)entryId);
18831            }
18832    
18833            /**
18834             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18835             *
18836             * @param primaryKey the primary key of the blogs entry
18837             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18838             */
18839            @Override
18840            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey) {
18841                    BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18842                                    BlogsEntryImpl.class, primaryKey);
18843    
18844                    if (blogsEntry == _nullBlogsEntry) {
18845                            return null;
18846                    }
18847    
18848                    if (blogsEntry == null) {
18849                            Session session = null;
18850    
18851                            try {
18852                                    session = openSession();
18853    
18854                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18855                                                    primaryKey);
18856    
18857                                    if (blogsEntry != null) {
18858                                            cacheResult(blogsEntry);
18859                                    }
18860                                    else {
18861                                            entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18862                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18863                                    }
18864                            }
18865                            catch (Exception e) {
18866                                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18867                                            BlogsEntryImpl.class, primaryKey);
18868    
18869                                    throw processException(e);
18870                            }
18871                            finally {
18872                                    closeSession(session);
18873                            }
18874                    }
18875    
18876                    return blogsEntry;
18877            }
18878    
18879            /**
18880             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18881             *
18882             * @param entryId the primary key of the blogs entry
18883             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18884             */
18885            @Override
18886            public BlogsEntry fetchByPrimaryKey(long entryId) {
18887                    return fetchByPrimaryKey((Serializable)entryId);
18888            }
18889    
18890            @Override
18891            public Map<Serializable, BlogsEntry> fetchByPrimaryKeys(
18892                    Set<Serializable> primaryKeys) {
18893                    if (primaryKeys.isEmpty()) {
18894                            return Collections.emptyMap();
18895                    }
18896    
18897                    Map<Serializable, BlogsEntry> map = new HashMap<Serializable, BlogsEntry>();
18898    
18899                    if (primaryKeys.size() == 1) {
18900                            Iterator<Serializable> iterator = primaryKeys.iterator();
18901    
18902                            Serializable primaryKey = iterator.next();
18903    
18904                            BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18905    
18906                            if (blogsEntry != null) {
18907                                    map.put(primaryKey, blogsEntry);
18908                            }
18909    
18910                            return map;
18911                    }
18912    
18913                    Set<Serializable> uncachedPrimaryKeys = null;
18914    
18915                    for (Serializable primaryKey : primaryKeys) {
18916                            BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18917                                            BlogsEntryImpl.class, primaryKey);
18918    
18919                            if (blogsEntry == null) {
18920                                    if (uncachedPrimaryKeys == null) {
18921                                            uncachedPrimaryKeys = new HashSet<Serializable>();
18922                                    }
18923    
18924                                    uncachedPrimaryKeys.add(primaryKey);
18925                            }
18926                            else {
18927                                    map.put(primaryKey, blogsEntry);
18928                            }
18929                    }
18930    
18931                    if (uncachedPrimaryKeys == null) {
18932                            return map;
18933                    }
18934    
18935                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
18936                                    1);
18937    
18938                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN);
18939    
18940                    for (Serializable primaryKey : uncachedPrimaryKeys) {
18941                            query.append(String.valueOf(primaryKey));
18942    
18943                            query.append(StringPool.COMMA);
18944                    }
18945    
18946                    query.setIndex(query.index() - 1);
18947    
18948                    query.append(StringPool.CLOSE_PARENTHESIS);
18949    
18950                    String sql = query.toString();
18951    
18952                    Session session = null;
18953    
18954                    try {
18955                            session = openSession();
18956    
18957                            Query q = session.createQuery(sql);
18958    
18959                            for (BlogsEntry blogsEntry : (List<BlogsEntry>)q.list()) {
18960                                    map.put(blogsEntry.getPrimaryKeyObj(), blogsEntry);
18961    
18962                                    cacheResult(blogsEntry);
18963    
18964                                    uncachedPrimaryKeys.remove(blogsEntry.getPrimaryKeyObj());
18965                            }
18966    
18967                            for (Serializable primaryKey : uncachedPrimaryKeys) {
18968                                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18969                                            BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18970                            }
18971                    }
18972                    catch (Exception e) {
18973                            throw processException(e);
18974                    }
18975                    finally {
18976                            closeSession(session);
18977                    }
18978    
18979                    return map;
18980            }
18981    
18982            /**
18983             * Returns all the blogs entries.
18984             *
18985             * @return the blogs entries
18986             */
18987            @Override
18988            public List<BlogsEntry> findAll() {
18989                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18990            }
18991    
18992            /**
18993             * Returns a range of all the blogs entries.
18994             *
18995             * <p>
18996             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
18997             * </p>
18998             *
18999             * @param start the lower bound of the range of blogs entries
19000             * @param end the upper bound of the range of blogs entries (not inclusive)
19001             * @return the range of blogs entries
19002             */
19003            @Override
19004            public List<BlogsEntry> findAll(int start, int end) {
19005                    return findAll(start, end, null);
19006            }
19007    
19008            /**
19009             * Returns an ordered range of all the blogs entries.
19010             *
19011             * <p>
19012             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
19013             * </p>
19014             *
19015             * @param start the lower bound of the range of blogs entries
19016             * @param end the upper bound of the range of blogs entries (not inclusive)
19017             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19018             * @return the ordered range of blogs entries
19019             */
19020            @Override
19021            public List<BlogsEntry> findAll(int start, int end,
19022                    OrderByComparator<BlogsEntry> orderByComparator) {
19023                    return findAll(start, end, orderByComparator, true);
19024            }
19025    
19026            /**
19027             * Returns an ordered range of all the blogs entries.
19028             *
19029             * <p>
19030             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
19031             * </p>
19032             *
19033             * @param start the lower bound of the range of blogs entries
19034             * @param end the upper bound of the range of blogs entries (not inclusive)
19035             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19036             * @param retrieveFromCache whether to retrieve from the finder cache
19037             * @return the ordered range of blogs entries
19038             */
19039            @Override
19040            public List<BlogsEntry> findAll(int start, int end,
19041                    OrderByComparator<BlogsEntry> orderByComparator,
19042                    boolean retrieveFromCache) {
19043                    boolean pagination = true;
19044                    FinderPath finderPath = null;
19045                    Object[] finderArgs = null;
19046    
19047                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19048                                    (orderByComparator == null)) {
19049                            pagination = false;
19050                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
19051                            finderArgs = FINDER_ARGS_EMPTY;
19052                    }
19053                    else {
19054                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
19055                            finderArgs = new Object[] { start, end, orderByComparator };
19056                    }
19057    
19058                    List<BlogsEntry> list = null;
19059    
19060                    if (retrieveFromCache) {
19061                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
19062                                            finderArgs, this);
19063                    }
19064    
19065                    if (list == null) {
19066                            StringBundler query = null;
19067                            String sql = null;
19068    
19069                            if (orderByComparator != null) {
19070                                    query = new StringBundler(2 +
19071                                                    (orderByComparator.getOrderByFields().length * 3));
19072    
19073                                    query.append(_SQL_SELECT_BLOGSENTRY);
19074    
19075                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19076                                            orderByComparator);
19077    
19078                                    sql = query.toString();
19079                            }
19080                            else {
19081                                    sql = _SQL_SELECT_BLOGSENTRY;
19082    
19083                                    if (pagination) {
19084                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
19085                                    }
19086                            }
19087    
19088                            Session session = null;
19089    
19090                            try {
19091                                    session = openSession();
19092    
19093                                    Query q = session.createQuery(sql);
19094    
19095                                    if (!pagination) {
19096                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19097                                                            start, end, false);
19098    
19099                                            Collections.sort(list);
19100    
19101                                            list = Collections.unmodifiableList(list);
19102                                    }
19103                                    else {
19104                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19105                                                            start, end);
19106                                    }
19107    
19108                                    cacheResult(list);
19109    
19110                                    finderCache.putResult(finderPath, finderArgs, list);
19111                            }
19112                            catch (Exception e) {
19113                                    finderCache.removeResult(finderPath, finderArgs);
19114    
19115                                    throw processException(e);
19116                            }
19117                            finally {
19118                                    closeSession(session);
19119                            }
19120                    }
19121    
19122                    return list;
19123            }
19124    
19125            /**
19126             * Removes all the blogs entries from the database.
19127             *
19128             */
19129            @Override
19130            public void removeAll() {
19131                    for (BlogsEntry blogsEntry : findAll()) {
19132                            remove(blogsEntry);
19133                    }
19134            }
19135    
19136            /**
19137             * Returns the number of blogs entries.
19138             *
19139             * @return the number of blogs entries
19140             */
19141            @Override
19142            public int countAll() {
19143                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
19144                                    FINDER_ARGS_EMPTY, this);
19145    
19146                    if (count == null) {
19147                            Session session = null;
19148    
19149                            try {
19150                                    session = openSession();
19151    
19152                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
19153    
19154                                    count = (Long)q.uniqueResult();
19155    
19156                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
19157                                            count);
19158                            }
19159                            catch (Exception e) {
19160                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
19161                                            FINDER_ARGS_EMPTY);
19162    
19163                                    throw processException(e);
19164                            }
19165                            finally {
19166                                    closeSession(session);
19167                            }
19168                    }
19169    
19170                    return count.intValue();
19171            }
19172    
19173            @Override
19174            public Set<String> getBadColumnNames() {
19175                    return _badColumnNames;
19176            }
19177    
19178            @Override
19179            protected Map<String, Integer> getTableColumnsMap() {
19180                    return BlogsEntryModelImpl.TABLE_COLUMNS_MAP;
19181            }
19182    
19183            /**
19184             * Initializes the blogs entry persistence.
19185             */
19186            public void afterPropertiesSet() {
19187            }
19188    
19189            public void destroy() {
19190                    entityCache.removeCache(BlogsEntryImpl.class.getName());
19191                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
19192                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
19193                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19194            }
19195    
19196            @BeanReference(type = CompanyProviderWrapper.class)
19197            protected CompanyProvider companyProvider;
19198            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
19199            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
19200            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
19201            private static final String _SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE entryId IN (";
19202            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
19203            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
19204            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
19205            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
19206            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
19207            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
19208                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
19209            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
19210                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
19211            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
19212            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
19213            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
19214            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
19215            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
19216            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
19217            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
19218            private static final Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
19219            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
19220                                    "uuid"
19221                            });
19222            private static final BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
19223                            @Override
19224                            public Object clone() {
19225                                    return this;
19226                            }
19227    
19228                            @Override
19229                            public CacheModel<BlogsEntry> toCacheModel() {
19230                                    return _nullBlogsEntryCacheModel;
19231                            }
19232                    };
19233    
19234            private static final CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
19235                            @Override
19236                            public BlogsEntry toEntityModel() {
19237                                    return _nullBlogsEntry;
19238                            }
19239                    };
19240    }